fix(desktop): route Platform-page close through the page close path
Refs #8244
This commit is contained in:
1 parent
3d445a7ce6
commit
68c2cf069d
5 files changed
+16
-12
No files matched your search
@@ -33,8 +33,8 @@
|
||||
en: ce5622d6d18ed8d1
|
||||
zh: 292932d8edb6e1c3
|
||||
/deepseek-ai-dsh-client-ui-sidebar-right/the-tab-domain:
|
||||
en: dd84612e98aa84ab
|
||||
zh: a41ade6082222fd6
|
||||
en: b6c64c7649203e12
|
||||
zh: c9341bbfd548a5eb
|
||||
/deepseek-ai-dsh-client-ui-sidebar-right/the-guide:
|
||||
en: 68fd575ef382223e
|
||||
zh: 1ab1653ee20c64e9
|
||||
|
||||
@@ -113,7 +113,7 @@ A type's `keepMounted: true` retains visited bodies across tab and Session chang
|
||||
|
||||
Tab owners register `registerCloseHandler(kind, handler)` through an effect. A handler synchronously retains any background cleanup before allowing explicit close or replacement. The resource owner tracks completion and retry; the sidebar does not wait. A thrown handler preserves the tab. Collapse, presentation changes and plugin disposal do not invoke close handlers; the tab abort signal identifies occurrence disposal, not an explicit close.
|
||||
|
||||
Close and refresh commands resolve the focused pane and tab occurrence. Page bodies bind their refresh operation through `tab.actions.bindCommands()` and release it on unmount; ended occurrences cannot regain capabilities. Refresh never reloads the application. Shortcut page opens, sidebar expansion, and all splits focus the selected dock or floating pane after its DOM commits, including singleton reveals and guide replacements. Sidebar expansion focuses the active dock pane; collapse preserves focus inside floating panes. Pane focus preserves existing text selections. If a focused page input or iframe is replaced, focus returns to its visible pane only while no other element owns focus; an outside pointer gesture or explicit blur cancels this restoration. Close checks the captured identity again and uses resource cleanup. After a keyboard or native-menu close, focus moves to a surviving visible pane in the same Session so consecutive close commands continue there. Stale targets and cleanup failures never fall back to closing a window. Modal restrictions follow the [shortcut service](../shortcuts/README.md). The close command first requests the foreground modal’s close action; a modal that declines dismissal, a menu, or an unregistered dialog blocks closing the sidebar or window behind it. Closing the sole docked guide with a shortcut or native menu collapses the sidebar and retains the guide. Desktop requests window closure through the shortcut service only when no modal is open and no sidebar page owns focus, or when the foreground modal is the Desktop Platform page (`platform`), which has only a back action; Web leaves the browser open.
|
||||
Close and refresh commands resolve the focused pane and tab occurrence. Page bodies bind their refresh operation through `tab.actions.bindCommands()` and release it on unmount; ended occurrences cannot regain capabilities. Refresh never reloads the application. Shortcut page opens, sidebar expansion, and all splits focus the selected dock or floating pane after its DOM commits, including singleton reveals and guide replacements. Sidebar expansion focuses the active dock pane; collapse preserves focus inside floating panes. Pane focus preserves existing text selections. If a focused page input or iframe is replaced, focus returns to its visible pane only while no other element owns focus; an outside pointer gesture or explicit blur cancels this restoration. Close checks the captured identity again and uses resource cleanup. After a keyboard or native-menu close, focus moves to a surviving visible pane in the same Session so consecutive close commands continue there. Stale targets and cleanup failures never fall back to closing a window. Modal restrictions follow the [shortcut service](../shortcuts/README.md). The close command first requests the foreground modal’s close action; a modal that declines dismissal, a menu, or an unregistered dialog blocks closing the sidebar or window behind it. Closing the sole docked guide with a shortcut or native menu collapses the sidebar and retains the guide. Desktop requests window closure through the shortcut service only when no modal is open and no sidebar page owns focus, or when the foreground modal is the Desktop Platform page layer (`platform`); Web leaves the browser open.
|
||||
|
||||
<a id="the-guide"></a>
|
||||
## The guide
|
||||
|
||||
@@ -113,7 +113,7 @@ Tab 域按(Session,Tab id)保留品牌化 occurrence id、导航、中止
|
||||
|
||||
标签页所有者通过 effect 注册 `registerCloseHandler(kind, handler)`。handler 在允许显式关闭或替换前同步保存后台清理任务。资源所有者跟踪完成和重试,侧栏不等待清理。handler 抛错时保留标签页。折叠、展示方式改变和插件卸载不调用关闭 handler;tab abort signal 标识 occurrence 卸载,不代表显式关闭。
|
||||
|
||||
关闭与刷新命令解析聚焦 pane 和 tab occurrence。页面通过 `tab.actions.bindCommands()` 绑定刷新操作,并在卸载时释放;已结束的 occurrence 不能重新获得能力。刷新不会重载应用。通过快捷键打开页面、展开侧栏或执行分栏操作后,焦点在 DOM 提交后移至选中的停靠或浮动分栏,包括显示已有单例页面和替换引导页。展开侧栏时聚焦活动停靠分栏;收起时保留浮动分栏内的焦点。分栏获得焦点时保留现有文本选区。聚焦的页面输入框或 iframe 被替换时,仅在没有其他元素持有焦点的情况下将焦点交还其可见分栏;外部指针操作或显式失焦会取消此次恢复。关闭会再次检查捕获的身份并执行资源清理。通过快捷键或原生菜单关闭后,焦点移至同一 Session 中仍可见的分栏,让连续关闭继续作用于右栏。过期目标和清理失败均不会回退为关窗。模态限制遵循[快捷键服务](../shortcuts/README.zh.md)。关闭命令优先请求前台弹窗的关闭操作;弹窗拒绝关闭、菜单或未注册的对话框都会阻止关闭后方侧栏或窗口。通过快捷键或原生菜单关闭唯一的停靠引导页时,收起右栏并保留引导页。Desktop 仅在没有弹窗且焦点没有所属的右栏页面时,或前台弹窗为只有返回操作的 Desktop Platform 页面(`platform`)时,通过快捷键服务请求关闭窗口;Web 保留浏览器窗口。
|
||||
关闭与刷新命令解析聚焦 pane 和 tab occurrence。页面通过 `tab.actions.bindCommands()` 绑定刷新操作,并在卸载时释放;已结束的 occurrence 不能重新获得能力。刷新不会重载应用。通过快捷键打开页面、展开侧栏或执行分栏操作后,焦点在 DOM 提交后移至选中的停靠或浮动分栏,包括显示已有单例页面和替换引导页。展开侧栏时聚焦活动停靠分栏;收起时保留浮动分栏内的焦点。分栏获得焦点时保留现有文本选区。聚焦的页面输入框或 iframe 被替换时,仅在没有其他元素持有焦点的情况下将焦点交还其可见分栏;外部指针操作或显式失焦会取消此次恢复。关闭会再次检查捕获的身份并执行资源清理。通过快捷键或原生菜单关闭后,焦点移至同一 Session 中仍可见的分栏,让连续关闭继续作用于右栏。过期目标和清理失败均不会回退为关窗。模态限制遵循[快捷键服务](../shortcuts/README.zh.md)。关闭命令优先请求前台弹窗的关闭操作;弹窗拒绝关闭、菜单或未注册的对话框都会阻止关闭后方侧栏或窗口。通过快捷键或原生菜单关闭唯一的停靠引导页时,收起右栏并保留引导页。Desktop 仅在没有弹窗且焦点没有所属的右栏页面时,或前台弹窗为 Desktop Platform 页面层(`platform`)时,通过快捷键服务请求关闭窗口;Web 保留浏览器窗口。
|
||||
|
||||
<a id="the-guide"></a>
|
||||
## 引导页
|
||||
|
||||
@@ -71,9 +71,8 @@ export function registerSidebarShortcuts(shortcuts: Pick<Shortcuts, 'register' |
|
||||
'web:windows': web, ...(kind === 'close' ? { 'web:macos': web } : {}) },
|
||||
regions: ['page', 'editable', 'terminal'], modals: kind === 'close' ? ['settings', 'shortcuts', 'platform', 'other'] : [],
|
||||
resolve: ({ target: element, source, modal }) => {
|
||||
// The Desktop Platform page offers only a back action, so Close page closes the window as on a page.
|
||||
if (kind === 'close' && modal === 'platform') return { status: 'handled', run: closeWindow }
|
||||
if (kind === 'close' && modal !== null) {
|
||||
// The Platform page layer registers no close action, so Close page acts as on a page and Desktop closes the window.
|
||||
if (kind === 'close' && modal !== null && modal !== 'platform') {
|
||||
return { status: 'handled', run: () => { closeTopModal(document) } }
|
||||
}
|
||||
const target = sidebar.focusedTarget(element)
|
||||
|
||||
@@ -12,6 +12,8 @@ import { createSidebarRightController } from '../src/client/service.ts'
|
||||
import { createSidebarRightStore } from '../src/client/stores.ts'
|
||||
import { SidebarRightTabRegistry } from '../src/client/tab-registry.ts'
|
||||
import { ShortcutRegistry } from '@deepseek-ai/dsh-client-shortcuts/src/client/registry.ts'
|
||||
import { installNativeKeyboard } from '@deepseek-ai/dsh-client-shortcuts/src/client/native.ts'
|
||||
import type { DesktopShortcutInput } from '@deepseek-ai/dsh-client-shortcuts/protocol'
|
||||
import { makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
|
||||
import { registerSidebarShortcuts } from '../src/client/shortcuts.ts'
|
||||
import { en } from '../src/client/locales.ts'
|
||||
@@ -614,11 +616,14 @@ describe('page close and refresh', () => {
|
||||
const closeWindow = vi.fn(), closeModal = vi.fn()
|
||||
releases.push(registerSidebarShortcuts({ register: command => registry.register(command), runtime: 'desktop' }, h.controller, makeTranslate(en), closeWindow))
|
||||
render(createElement(Modal, { open: true, title: 'Settings', shortcutModal: 'settings', closeLabel: 'Close', onClose: closeModal }))
|
||||
const context = { target: document.activeElement, region: 'page' as const, modal: 'platform' }
|
||||
const gesture = { code: 'KeyW', meta: platform === 'macos', control: platform !== 'macos', alt: false,
|
||||
shift: false, repeat: false, composing: false, defaultPrevented: false }
|
||||
registry.dispatch(gesture, context, vi.fn())
|
||||
registry.invoke('page.close' as ShortcutCommandId, context)
|
||||
render(createElement('div', { role: 'dialog', 'aria-modal': 'true', 'data-shortcut-modal': 'platform' }))
|
||||
let deliver: (input: DesktopShortcutInput) => void = () => {}
|
||||
releases.push(installNativeKeyboard(window, { subscribe: (listener) => { deliver = listener; return () => {} }, closeWindow: vi.fn() },
|
||||
registry, () => registry.config.getSnapshot()))
|
||||
const revision = registry.config.getSnapshot().revision
|
||||
deliver({ kind: 'keyboard', frameName: '', revision, code: 'KeyW', control: platform !== 'macos', alt: false, shift: false,
|
||||
meta: platform === 'macos', repeat: false })
|
||||
deliver({ kind: 'menu', commandId: 'page.close' as ShortcutCommandId, revision })
|
||||
expect(closeWindow).toHaveBeenCalledTimes(2)
|
||||
expect(closeModal).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user