diff --git a/src/web-ui/src/app/components/panels/content-canvas/hooks/BtwCloseConfirmation.module.css b/src/web-ui/src/app/components/panels/content-canvas/hooks/BtwCloseConfirmation.module.css
new file mode 100644
index 0000000000..1e424e73be
--- /dev/null
+++ b/src/web-ui/src/app/components/panels/content-canvas/hooks/BtwCloseConfirmation.module.css
@@ -0,0 +1,29 @@
+.root {
+ display: flex;
+ min-inline-size: 0;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: var(--openbitfun-space-3);
+}
+
+.message {
+ min-inline-size: 0;
+}
+
+.checkbox {
+ --btw-warning-icon-size: var(--openbitfun-layout-confirm-dialog-icon-glyph-size);
+ --btw-warning-column-gap: var(--openbitfun-layout-confirm-dialog-message-gap);
+ --btw-checkbox-control-size: 12px;
+
+ /* Center the checkbox control in the warning-icon column while keeping its
+ label aligned with the confirmation message column. */
+ align-self: flex-start;
+ margin-inline-start: calc(
+ -1 * (var(--btw-warning-icon-size) + var(--btw-warning-column-gap))
+ + (var(--btw-warning-icon-size) - var(--btw-checkbox-control-size)) / 2
+ );
+ gap: calc(
+ var(--btw-warning-column-gap)
+ + (var(--btw-warning-icon-size) - var(--btw-checkbox-control-size)) / 2
+ );
+}
diff --git a/src/web-ui/src/app/components/panels/content-canvas/hooks/BtwCloseConfirmation.tsx b/src/web-ui/src/app/components/panels/content-canvas/hooks/BtwCloseConfirmation.tsx
new file mode 100644
index 0000000000..7e06dfb485
--- /dev/null
+++ b/src/web-ui/src/app/components/panels/content-canvas/hooks/BtwCloseConfirmation.tsx
@@ -0,0 +1,27 @@
+import { Checkbox } from '@openbitfun/ui';
+import { useI18n } from '@/infrastructure/i18n';
+import styles from './BtwCloseConfirmation.module.css';
+
+interface BtwCloseConfirmationProps {
+ onSkipChange: (skip: boolean) => void;
+}
+
+export function BtwCloseConfirmation({ onSkipChange }: BtwCloseConfirmationProps) {
+ const { t } = useI18n('components');
+
+ return (
+
+
{t('tabs.confirmCloseBtw')}
+
+
+ );
+}
diff --git a/src/web-ui/src/app/components/panels/content-canvas/hooks/useTabLifecycle.btw.test.tsx b/src/web-ui/src/app/components/panels/content-canvas/hooks/useTabLifecycle.btw.test.tsx
index 1e4a239a8a..6b9cc2ba27 100644
--- a/src/web-ui/src/app/components/panels/content-canvas/hooks/useTabLifecycle.btw.test.tsx
+++ b/src/web-ui/src/app/components/panels/content-canvas/hooks/useTabLifecycle.btw.test.tsx
@@ -15,6 +15,7 @@ vi.mock('@/shared/services/destroyTerminalSession', () => ({ destroyTerminalSess
import { useTabLifecycle } from './useTabLifecycle';
import { CanvasStoreModeContext, clearAgentCanvasForPeerSwitch, switchAgentCanvasScope, useAgentCanvasStore } from '../stores';
import { useConfirmDialogStore } from '@/infrastructure/confirm-dialog/confirmDialogService';
+import { BTW_CLOSE_CONFIRMATION_STORAGE_KEY } from '@/infrastructure/preferences/btwCloseConfirmation';
describe('BTW tab close transitions', () => {
let root: Root;
@@ -37,6 +38,7 @@ describe('BTW tab close transitions', () => {
beforeEach(async () => {
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
vi.resetAllMocks();
+ localStorage.removeItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY);
state.sessions.clear();
state.discard.mockResolvedValue(undefined);
state.save.mockResolvedValue(undefined);
@@ -124,6 +126,40 @@ describe('BTW tab close transitions', () => {
expect(useAgentCanvasStore.getState().closedTabs).toEqual([]);
});
+ it('remembers the opt-out only after confirming and skips future warnings', async () => {
+ let id!: string;
+ await act(async () => { id = addBtw('child'); });
+ const { pending } = await beginClose(() => lifecycle.handleCloseWithDirtyCheck(id, 'primary'));
+ const message = useConfirmDialogStore.getState().options?.message as React.ReactElement<{ onSkipChange: (skip: boolean) => void }>;
+ message.props.onSkipChange(true);
+ await act(async () => { useConfirmDialogStore.getState().confirm(); expect(await pending).toBe(true); });
+ expect(localStorage.getItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY)).toBe('true');
+
+ await act(async () => { addBtw('child-2'); });
+ const nextId = useAgentCanvasStore.getState().primaryGroup.tabs.at(-1)!.id;
+ const nextClose = lifecycle.handleCloseWithDirtyCheck(nextId, 'primary');
+ expect(useConfirmDialogStore.getState().isOpen).toBe(false);
+ await expect(nextClose).resolves.toBe(true);
+ expect(state.discard).toHaveBeenCalledWith('child-2');
+ });
+
+ it('does not remember the opt-out when cancelling or saving as a fork', async () => {
+ let id!: string;
+ await act(async () => { id = addBtw('child'); });
+ const { pending } = await beginClose(() => lifecycle.handleCloseWithDirtyCheck(id, 'primary'));
+ const message = useConfirmDialogStore.getState().options?.message as React.ReactElement<{ onSkipChange: (skip: boolean) => void }>;
+ message.props.onSkipChange(true);
+ useConfirmDialogStore.getState().cancel();
+ expect(await pending).toBe(false);
+ expect(localStorage.getItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY)).toBeNull();
+
+ const retry = lifecycle.handleCloseWithDirtyCheck(id, 'primary');
+ const retryMessage = useConfirmDialogStore.getState().options?.message as React.ReactElement<{ onSkipChange: (skip: boolean) => void }>;
+ retryMessage.props.onSkipChange(true);
+ await act(async () => { useConfirmDialogStore.getState().secondary(); expect(await retry).toBe(true); });
+ expect(localStorage.getItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY)).toBeNull();
+ });
+
it('keeps the tab and reports cleanup failure', async () => {
let id!: string;
await act(async () => { id = addBtw('child'); });
@@ -141,7 +177,9 @@ describe('BTW tab close transitions', () => {
useAgentCanvasStore.getState().addTab({ type: 'btw-session', title: 'review', data: { childSessionId: 'review' } }, 'active');
});
const { pending } = await beginClose(() => lifecycle.handleCloseAllWithDirtyCheck('primary'));
- expect(useConfirmDialogStore.getState().options?.message).toBe('tabs.confirmCloseBtw');
+ expect(useConfirmDialogStore.getState().options?.message).toMatchObject({
+ props: { onSkipChange: expect.any(Function) },
+ });
await act(async () => { useConfirmDialogStore.getState().confirm(); expect(await pending).toBe(true); });
expect(state.discard.mock.calls.map(call => call[0]).sort()).toEqual(['child-a', 'child-b']);
expect(useAgentCanvasStore.getState().primaryGroup.tabs.map(tab => tab.title)).toEqual(['pinned-child']);
diff --git a/src/web-ui/src/app/components/panels/content-canvas/hooks/useTabLifecycle.ts b/src/web-ui/src/app/components/panels/content-canvas/hooks/useTabLifecycle.ts
index 6d543237e1..b84a90a5b9 100644
--- a/src/web-ui/src/app/components/panels/content-canvas/hooks/useTabLifecycle.ts
+++ b/src/web-ui/src/app/components/panels/content-canvas/hooks/useTabLifecycle.ts
@@ -8,7 +8,7 @@
* - Pin action -> pinned
*/
-import { useCallback, useEffect } from 'react';
+import { createElement, useCallback, useEffect } from 'react';
import {
useCanvasStore,
useAgentCanvasStore,
@@ -28,6 +28,8 @@ import { flowChatStore } from '@/flow_chat/store/FlowChatStore';
import { canSaveBtwSessionAsFork, discardBtwSession, saveBtwSessionAsFork } from '@/flow_chat/services/BtwSessionLifecycle';
import { getActiveSurfaceScope, isSurfaceChangedError } from '@/infrastructure/peer-device/deviceSurface';
import { notificationService } from '@/shared/notification-system';
+import { shouldConfirmBtwClose, setConfirmBtwClose } from '@/infrastructure/preferences/btwCloseConfirmation';
+import { BtwCloseConfirmation } from './BtwCloseConfirmation';
const log = createLogger('useTabLifecycle');
interface UseTabLifecycleOptions {
@@ -94,9 +96,12 @@ export const useTabLifecycle = (options: UseTabLifecycleOptions = {}): UseTabLif
const confirmBtwClose = useCallback(async (tabs: { title: string; content: PanelContent }[]) => {
const btwTabs = tabs.filter(isBtwTab);
if (btwTabs.length === 0) return 'confirm';
- return confirmDialogChoice({
+ if (!shouldConfirmBtwClose()) return 'confirm';
+
+ let skipConfirmation = false;
+ const choice = await confirmDialogChoice({
title: t('tabs.closeBtwTitle'),
- message: t('tabs.confirmCloseBtw'),
+ message: createElement(BtwCloseConfirmation, { onSkipChange: (checked) => { skipConfirmation = checked; } }),
type: 'warning',
confirmDanger: true,
confirmText: t('tabs.close'),
@@ -105,6 +110,8 @@ export const useTabLifecycle = (options: UseTabLifecycleOptions = {}): UseTabLif
secondaryText: btwTabs.some(tab => canSaveBtwSessionAsFork(tab.content.data.childSessionId))
? t('tabs.saveBtwAsFork') : undefined,
});
+ if (choice === 'confirm' && skipConfirmation) setConfirmBtwClose(false);
+ return choice;
}, [isBtwTab, t]);
const closeTerminalSession = useCallback(async (tab: { content: PanelContent }): Promise => {
diff --git a/src/web-ui/src/app/scenes/settings/pages/application/BtwCloseConfirmationSettingsSection.tsx b/src/web-ui/src/app/scenes/settings/pages/application/BtwCloseConfirmationSettingsSection.tsx
new file mode 100644
index 0000000000..53349122ef
--- /dev/null
+++ b/src/web-ui/src/app/scenes/settings/pages/application/BtwCloseConfirmationSettingsSection.tsx
@@ -0,0 +1,29 @@
+import { useState } from 'react';
+import { Switch } from '@openbitfun/ui';
+import { useI18n } from '@/infrastructure/i18n';
+import { ConfigPageRow, ConfigPageSection } from '@/infrastructure/config/components/common';
+import { setConfirmBtwClose, shouldConfirmBtwClose } from '@/infrastructure/preferences/btwCloseConfirmation';
+import { useSettingsSectionAnchor } from '../shared/useSettingsSectionAnchor';
+
+export default function BtwCloseConfirmationSettingsSection() {
+ const { t } = useI18n('settings/application');
+ const [enabled, setEnabled] = useState(shouldConfirmBtwClose);
+ const sectionAnchor = useSettingsSectionAnchor('btw-close-confirmation', true);
+
+ return (
+
+
+
+ {
+ setEnabled(next);
+ setConfirmBtwClose(next);
+ }}
+ aria-label={t('btwCloseConfirmation.label')}
+ />
+
+
+
+ );
+}
diff --git a/src/web-ui/src/app/scenes/settings/pages/application/InputSettingsPage.tsx b/src/web-ui/src/app/scenes/settings/pages/application/InputSettingsPage.tsx
index c98877babd..f08d963509 100644
--- a/src/web-ui/src/app/scenes/settings/pages/application/InputSettingsPage.tsx
+++ b/src/web-ui/src/app/scenes/settings/pages/application/InputSettingsPage.tsx
@@ -3,12 +3,14 @@ import KeyboardShortcutsSection from './KeyboardShortcutsSection';
import VoiceSettingsSection from './VoiceSettingsSection';
import TextSelectionSettingsSection from './TextSelectionSettingsSection';
import MessageSendingSettingsSection from './MessageSendingSettingsSection';
+import BtwCloseConfirmationSettingsSection from './BtwCloseConfirmationSettingsSection';
export default function InputSettingsPage() {
return (
+
diff --git a/src/web-ui/src/app/scenes/settings/settingsRegistry.test.ts b/src/web-ui/src/app/scenes/settings/settingsRegistry.test.ts
index 8ed368871b..185a82c240 100644
--- a/src/web-ui/src/app/scenes/settings/settingsRegistry.test.ts
+++ b/src/web-ui/src/app/scenes/settings/settingsRegistry.test.ts
@@ -31,7 +31,7 @@ describe('settings information architecture', () => {
expect(new Set(SETTINGS_PAGE_MANIFESTS.map(page => page.id)).size).toBe(20);
expect(SETTINGS_PAGE_MANIFESTS.filter(page => page.views?.length).map(page => page.id)).toEqual(['tools.external-agents']);
expect(getSettingsPageManifest('tools.external-agents').views?.map(view => view.id)).toEqual(['local', 'ssh', 'json']);
- expect(getSettingsPageManifest('application.input').sections?.map(section => section.id)).toEqual(['voice', 'message-sending', 'text-selection', 'shortcuts']);
+ expect(getSettingsPageManifest('application.input').sections?.map(section => section.id)).toEqual(['voice', 'message-sending', 'btw-close-confirmation', 'text-selection', 'shortcuts']);
expect(getSettingsPageManifest('application.pet').sections?.map(section => section.id)).toEqual(['voice-call', 'pet', 'desktop-cards']);
expect(resolveSettingsDestination({ pageId: 'application.appearance', sectionId: 'sidebar-navigation' }))
.toEqual({ pageId: 'application.appearance', sectionId: 'sidebar-navigation' });
diff --git a/src/web-ui/src/app/scenes/settings/settingsRegistry.ts b/src/web-ui/src/app/scenes/settings/settingsRegistry.ts
index 6e234ddb12..f554b85ae2 100644
--- a/src/web-ui/src/app/scenes/settings/settingsRegistry.ts
+++ b/src/web-ui/src/app/scenes/settings/settingsRegistry.ts
@@ -183,6 +183,12 @@ export const SETTINGS_PAGE_MANIFESTS: readonly SettingsPageManifest[] = [
keywords: ['message', 'send', 'queue', 'immediate', 'steering', 'flowchat'],
searchPhrases: [phrase('settings/application', 'messageSending.title'), phrase('settings/application', 'messageSending.duringTurn'), phrase('settings/application', 'messageSending.description')],
},
+ {
+ id: 'btw-close-confirmation',
+ labelKey: 'navigation.sections.btw-close-confirmation',
+ keywords: ['btw', 'side conversation', 'close', 'confirmation', 'prompt'],
+ searchPhrases: [phrase('settings/application', 'btwCloseConfirmation.title'), phrase('settings/application', 'btwCloseConfirmation.label')],
+ },
{
id: 'text-selection',
labelKey: 'navigation.sections.text-selection',
diff --git a/src/web-ui/src/app/scenes/settings/settingsTypes.ts b/src/web-ui/src/app/scenes/settings/settingsTypes.ts
index 325ce8bccd..8877cf69a6 100644
--- a/src/web-ui/src/app/scenes/settings/settingsTypes.ts
+++ b/src/web-ui/src/app/scenes/settings/settingsTypes.ts
@@ -36,6 +36,7 @@ export type SettingsViewId =
export type SettingsSectionId =
| 'sidebar-navigation'
| 'message-sending'
+ | 'btw-close-confirmation'
| 'text-selection'
| 'pet'
| 'desktop-cards'
diff --git a/src/web-ui/src/infrastructure/preferences/btwCloseConfirmation.test.ts b/src/web-ui/src/infrastructure/preferences/btwCloseConfirmation.test.ts
new file mode 100644
index 0000000000..0a9b506bc9
--- /dev/null
+++ b/src/web-ui/src/infrastructure/preferences/btwCloseConfirmation.test.ts
@@ -0,0 +1,25 @@
+// @vitest-environment jsdom
+import { beforeEach, describe, expect, it } from 'vitest';
+import {
+ BTW_CLOSE_CONFIRMATION_STORAGE_KEY,
+ setConfirmBtwClose,
+ shouldConfirmBtwClose,
+} from './btwCloseConfirmation';
+
+describe('BTW close confirmation preference', () => {
+ beforeEach(() => localStorage.clear());
+
+ it('confirms by default', () => {
+ expect(shouldConfirmBtwClose()).toBe(true);
+ });
+
+ it('persists the disabled state and restores it', () => {
+ setConfirmBtwClose(false);
+ expect(localStorage.getItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY)).toBe('true');
+ expect(shouldConfirmBtwClose()).toBe(false);
+
+ setConfirmBtwClose(true);
+ expect(localStorage.getItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY)).toBeNull();
+ expect(shouldConfirmBtwClose()).toBe(true);
+ });
+});
diff --git a/src/web-ui/src/infrastructure/preferences/btwCloseConfirmation.ts b/src/web-ui/src/infrastructure/preferences/btwCloseConfirmation.ts
new file mode 100644
index 0000000000..784bdc707e
--- /dev/null
+++ b/src/web-ui/src/infrastructure/preferences/btwCloseConfirmation.ts
@@ -0,0 +1,18 @@
+export const BTW_CLOSE_CONFIRMATION_STORAGE_KEY = 'openbitfun:preferences:skip-btw-close-confirmation:v1';
+
+export function shouldConfirmBtwClose(): boolean {
+ try {
+ return globalThis.localStorage?.getItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY) !== 'true';
+ } catch {
+ return true;
+ }
+}
+
+export function setConfirmBtwClose(enabled: boolean): void {
+ try {
+ if (enabled) globalThis.localStorage?.removeItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY);
+ else globalThis.localStorage?.setItem(BTW_CLOSE_CONFIRMATION_STORAGE_KEY, 'true');
+ } catch {
+ // A storage failure must not block the settings interaction.
+ }
+}
diff --git a/src/web-ui/src/locales/en-US/components.json b/src/web-ui/src/locales/en-US/components.json
index 7f48142a00..96d973dc7d 100644
--- a/src/web-ui/src/locales/en-US/components.json
+++ b/src/web-ui/src/locales/en-US/components.json
@@ -342,6 +342,7 @@
"saveBtwAsFork": "Save as fork",
"saveBtwFailed": "Could not save. The side thread is still open; try again.",
"confirmCloseBtw": "Closing discards the conversation permanently.",
+ "skipCloseBtwConfirmation": "Don't ask again",
"closeBtwFailed": "Could not close the side conversation. The tab is still open; please try again.",
"popOut": "Pop out as scene",
"closeOthers": "Close Others",
diff --git a/src/web-ui/src/locales/en-US/settings.json b/src/web-ui/src/locales/en-US/settings.json
index 93fee1d160..726bf26cda 100644
--- a/src/web-ui/src/locales/en-US/settings.json
+++ b/src/web-ui/src/locales/en-US/settings.json
@@ -101,6 +101,7 @@
"sections": {
"text-selection": "Text selection",
"message-sending": "Message sending",
+ "btw-close-confirmation": "Side conversation closing",
"voice": "Voice",
"shortcuts": "Keyboard Shortcuts",
"session": "Session Defaults",
diff --git a/src/web-ui/src/locales/en-US/settings/application.json b/src/web-ui/src/locales/en-US/settings/application.json
index d10d1c9cce..1c0d5babb9 100644
--- a/src/web-ui/src/locales/en-US/settings/application.json
+++ b/src/web-ui/src/locales/en-US/settings/application.json
@@ -24,6 +24,11 @@
"loadFailed": "Failed to load text selection preferences",
"saveFailed": "Failed to save text selection preferences"
},
+ "btwCloseConfirmation": {
+ "title": "Side conversation closing",
+ "label": "Confirm before closing side conversations",
+ "description": "Closing a side conversation permanently discards its content. Turn this off to skip the confirmation."
+ },
"applicationGroups": {
"startupAndUpdates": {
"title": "Startup & updates",
diff --git a/src/web-ui/src/locales/zh-CN/components.json b/src/web-ui/src/locales/zh-CN/components.json
index 1421793632..5a94919973 100644
--- a/src/web-ui/src/locales/zh-CN/components.json
+++ b/src/web-ui/src/locales/zh-CN/components.json
@@ -340,6 +340,7 @@
"close": "关闭",
"closeBtwTitle": "关闭侧问?",
"confirmCloseBtw": "关闭后对话将消失,无法恢复。",
+ "skipCloseBtwConfirmation": "不再提示",
"saveBtwAsFork": "保存为 Fork 会话",
"saveBtwFailed": "保存失败,侧问已保留,请重试。",
"closeBtwFailed": "暂时无法关闭侧问,标签页已保留,请重试。",
diff --git a/src/web-ui/src/locales/zh-CN/settings.json b/src/web-ui/src/locales/zh-CN/settings.json
index 9685a796b3..d23a33b89d 100644
--- a/src/web-ui/src/locales/zh-CN/settings.json
+++ b/src/web-ui/src/locales/zh-CN/settings.json
@@ -101,6 +101,7 @@
"sections": {
"text-selection": "文本选择",
"message-sending": "消息发送",
+ "btw-close-confirmation": "侧问关闭",
"voice": "语音",
"shortcuts": "快捷键",
"session": "会话默认行为",
diff --git a/src/web-ui/src/locales/zh-CN/settings/application.json b/src/web-ui/src/locales/zh-CN/settings/application.json
index afc5150642..7e8fd8363c 100644
--- a/src/web-ui/src/locales/zh-CN/settings/application.json
+++ b/src/web-ui/src/locales/zh-CN/settings/application.json
@@ -24,6 +24,11 @@
"loadFailed": "加载文本选择偏好失败",
"saveFailed": "保存文本选择偏好失败"
},
+ "btwCloseConfirmation": {
+ "title": "侧问关闭",
+ "label": "关闭侧问前确认",
+ "description": "关闭侧问会永久丢弃对话内容;关闭后不再显示确认提示。"
+ },
"applicationGroups": {
"startupAndUpdates": {
"title": "启动与更新",
diff --git a/src/web-ui/src/locales/zh-TW/components.json b/src/web-ui/src/locales/zh-TW/components.json
index 475a93bf2a..b4bb70eb02 100644
--- a/src/web-ui/src/locales/zh-TW/components.json
+++ b/src/web-ui/src/locales/zh-TW/components.json
@@ -342,6 +342,7 @@
"saveBtwAsFork": "儲存為 Fork 對話",
"saveBtwFailed": "儲存失敗,側問已保留,請重試。",
"confirmCloseBtw": "關閉後對話將消失,無法復原。",
+ "skipCloseBtwConfirmation": "不再提示",
"closeBtwFailed": "暫時無法關閉側問,標籤頁已保留,請重試。",
"popOut": "彈出為獨立場景",
"closeOthers": "關閉其他",
diff --git a/src/web-ui/src/locales/zh-TW/settings.json b/src/web-ui/src/locales/zh-TW/settings.json
index 14ae4b344c..026e62229b 100644
--- a/src/web-ui/src/locales/zh-TW/settings.json
+++ b/src/web-ui/src/locales/zh-TW/settings.json
@@ -101,6 +101,7 @@
"sections": {
"text-selection": "文字選取",
"message-sending": "訊息傳送",
+ "btw-close-confirmation": "側問關閉",
"voice": "語音",
"shortcuts": "快捷鍵",
"session": "工作階段預設行為",
diff --git a/src/web-ui/src/locales/zh-TW/settings/application.json b/src/web-ui/src/locales/zh-TW/settings/application.json
index 58d267e70a..eba32b1db5 100644
--- a/src/web-ui/src/locales/zh-TW/settings/application.json
+++ b/src/web-ui/src/locales/zh-TW/settings/application.json
@@ -24,6 +24,11 @@
"loadFailed": "載入文字選取偏好失敗",
"saveFailed": "儲存文字選取偏好失敗"
},
+ "btwCloseConfirmation": {
+ "title": "側問關閉",
+ "label": "關閉側問前確認",
+ "description": "關閉側問會永久捨棄對話內容;關閉後不再顯示確認提示。"
+ },
"applicationGroups": {
"startupAndUpdates": {
"title": "啟動與更新",