Files
Netcatty/application/state/windowCommandClose.ts
atoz03 e948a7a869 fix: route Cmd+W through existing tab close flow (#1234)
* fix: route Cmd+W through existing tab close flow

Keep the original tab-close behavior intact, and close the main or settings window only when there is no active closable tab to handle.

* fix: fall back to closing non-listener windows on Cmd+W

Treat BrowserWindow instances that do not participate in Netcatty's command-close bridge as regular closable windows. Keep the existing command-close path for the main and settings windows, and add tests that cover both the fallback close behavior and the renderer-capable send path.
2026-06-04 17:20:44 +08:00

43 lines
1017 B
TypeScript

export type WindowCommandCloseIntent =
| { kind: 'closeTab' }
| { kind: 'closeLogView'; tabId: string }
| { kind: 'closeWindow' };
interface ResolveWindowCommandCloseIntentInput {
activeTabId: string | null;
editorTabIds: string[];
sessionIds: string[];
workspaceIds: string[];
logViewIds: string[];
}
export function resolveWindowCommandCloseIntent({
activeTabId,
editorTabIds,
sessionIds,
workspaceIds,
logViewIds,
}: ResolveWindowCommandCloseIntentInput): WindowCommandCloseIntent {
if (!activeTabId) {
return { kind: 'closeWindow' };
}
if (editorTabIds.includes(activeTabId)) {
return { kind: 'closeTab' };
}
if (sessionIds.includes(activeTabId) || workspaceIds.includes(activeTabId)) {
return { kind: 'closeTab' };
}
if (logViewIds.includes(activeTabId)) {
return { kind: 'closeLogView', tabId: activeTabId };
}
if (activeTabId === 'vault' || activeTabId === 'sftp') {
return { kind: 'closeWindow' };
}
return { kind: 'closeWindow' };
}