Add right panel close controls #4148
Closedcaezium(GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromrefs/pull/4148/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/ChatView.tsx line 3916OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3876,3 +3905,12 @@38763905 return;38773906 }387839073908+ if (command === "rightPanel.closeActiveSurface") {3909+ if (3910+ shouldDeferRightPanelCloseShortcutToDesktopMenu({3911+ desktop: isElectron,3912+ platform: navigator.platform,3913+ })3914+ ) {3915+ return;3916+ }apps/web/src/components/ChatView.tsx line 3178OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3157,3 +3167,12 @@31573167 },31583168 [activeThreadRef, cleanupRightPanelSurfaces, syncActivePreviewSurface],31593169 );3170+ const handleCloseRequest = useEffectEvent((event: Event) => {3171+ // The native macOS menu accelerator runs outside the renderer's keyboard3172+ // event path. Focus can temporarily report <body> while a terminal or3173+ // preview surface owns input, so using DOM focus here can incorrectly fall3174+ // through to window.close(). An open active surface always gets the first3175+ // Cmd+W; only a request with no surface may close the app window.3176+ if (!activeRightPanelSurface) return;3177+ event.preventDefault();3178+ closeRightPanelSurface(activeRightPanelSurface);
- apps/web/src/lib/rightPanelCloseRequest.ts line 28OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +8,21 @@8+ event,9+}: {10+ readonly desktop: boolean;11+ readonly platform: string;12+ readonly event: {13+ readonly key: string;14+ readonly metaKey: boolean;15+ readonly ctrlKey: boolean;16+ readonly shiftKey: boolean;17+ readonly altKey: boolean;18+ };19+}): boolean {20+ return (21+ desktop &&22+ isMacPlatform(platform) &&23+ event.key.toLowerCase() === "w" &&24+ event.metaKey &&25+ !event.ctrlKey &&26+ !event.shiftKey &&27+ !event.altKey28+ );
- apps/web/src/components/ChatView.tsx line 3182OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3157,3 +3168,15 @@31573168 },31583169 [activeThreadRef, cleanupRightPanelSurfaces, syncActivePreviewSurface],31593170 );3171+ const closeActiveRightPanelTarget = useCallback(() => {3172+ const target = resolveRightPanelCloseTarget({3173+ isOpen: rightPanelOpen,3174+ hasActiveSurface: activeRightPanelSurface !== null,3175+ });3176+ if (target === "surface" && activeRightPanelSurface) {3177+ closeRightPanelSurface(activeRightPanelSurface);3178+ } else if (target === "panel" && activeThreadRef) {3179+ setMaximizedRightPanelThreadKey(null);3180+ useRightPanelStore.getState().close(activeThreadRef);3181+ }3182+ return target !== null;apps/web/src/lib/rightPanelFocus.ts line 11OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,11 @@1+/**2+ * Returns true when keyboard focus belongs to the tabbed right-panel chrome3+ * or its active surface. This deliberately excludes other preview-panel4+ * shells so right-panel shortcuts do not affect standalone preview layouts.5+ */6+export function isRightPanelFocused(): boolean {7+ const activeElement = document.activeElement;8+ if (!(activeElement instanceof HTMLElement)) return false;9+ if (!activeElement.isConnected) return false;10+ return activeElement.closest("[data-right-panel-tabbar], [data-right-panel-content]") !== null;11+}packages/shared/src/keybindings.ts line 29OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -26,3 +26,4 @@2626 { key: "mod+shift+d", command: "terminal.splitVertical", when: "terminalFocus" },2727 { key: "mod+n", command: "terminal.new", when: "terminalFocus" },2828 { key: "mod+w", command: "terminal.close", when: "terminalFocus" },29+ { key: "mod+w", command: "rightPanel.closeActiveSurface", when: "rightPanelFocus" },apps/web/src/components/RightPanelTabs.tsx line 362Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -358,4 +358,4 @@358358 <div359359 className={cn(360360 "workspace-topbar gap-1 pl-2",361- props.mode === "inline" ? "pr-28" : "pr-3",361+ props.mode === "inline" ? "pr-36" : "pr-3",apps/desktop/src/window/DesktopApplicationMenu.ts line 187OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -170,4 +176,12 @@170176 },171177 { type: "separator" as const },172178 ]),173- { role: environment.platform === "darwin" ? "close" : "quit" },179+ ...(environment.platform === "darwin"180+ ? [181+ {182+ label: "Close Window",183+ accelerator: "Cmd+W",184+ click: closeWindowClick,185+ },186+ ]187+ : [{ role: "quit" as const }]),
- apps/web/src/components/ChatView.tsx line 3948OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3876,3 +3935,14 @@38763935 return;38773936 }387839373938+ if (command === "rightPanel.closeActiveSurface") {3939+ if (3940+ shouldDeferRightPanelCloseShortcutToDesktopMenu({3941+ desktop: isElectron,3942+ platform: navigator.platform,3943+ event,3944+ })3945+ ) {3946+ return;3947+ }3948+ if (!closeActiveRightPanelTarget()) return;
- apps/web/src/components/ChatView.tsx line 3211OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3159,0 +3191,21 @@3191+ useRightPanelStore.getState().close(activeThreadRef);3192+ }3193+ return target !== null;3194+ }, [3195+ activeRightPanelSurface,3196+ activeThreadRef,3197+ closePanelTerminal,3198+ closeRightPanelSurface,3199+ rightPanelOpen,3200+ ]);3201+ const handleCloseRequest = useEffectEvent((event: Event) => {3202+ // The native macOS menu accelerator runs outside the renderer's keyboard3203+ // event path. Focus can temporarily report <body> while a terminal or3204+ // preview surface owns input, so using DOM focus here can incorrectly fall3205+ // through to window.close(). Focused terminal panes and an open panel get3206+ // the first Cmd+W; only an otherwise unhandled request closes the window.3207+ if (getTerminalFocusOwner() === "drawer" && terminalUiState.terminalOpen) {3208+ event.preventDefault();3209+ closeTerminal(terminalUiState.activeTerminalId);3210+ return;3211+ }
- apps/web/src/components/ChatView.tsx line 3218OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3159,0 +3198,21 @@3198+ [3199+ activeRightPanelSurface,3200+ activeThreadRef,3201+ closePanelTerminal,3202+ closeRightPanelSurface,3203+ rightPanelOpen,3204+ ],3205+ );3206+ const handleCloseRequest = useEffectEvent((event: Event) => {3207+ // The native macOS menu accelerator runs outside the renderer's keyboard3208+ // event path. Focus can temporarily report <body> while a terminal or3209+ // preview surface owns input, so using DOM focus here can incorrectly fall3210+ // through to window.close(). Focused terminal panes and an open panel get3211+ // the first Cmd+W; only an otherwise unhandled request closes the window.3212+ const terminalFocusOwner = consumeDeferredTerminalCloseOwner() ?? getTerminalFocusOwner();3213+ if (terminalFocusOwner === "drawer" && terminalUiState.terminalOpen) {3214+ event.preventDefault();3215+ closeTerminal(terminalUiState.activeTerminalId);3216+ return;3217+ }3218+ if (!closeActiveRightPanelTarget(terminalFocusOwner)) return;apps/web/src/lib/rightPanelCloseRequest.ts line 26OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +6,21 @@6+const DEFERRED_TERMINAL_CLOSE_TTL_MS = 1_000;7+let deferredTerminalCloseIntent: {8+ readonly owner: DeferredTerminalCloseOwner;9+ readonly createdAt: number;10+} | null = null;11+12+export function deferTerminalCloseToDesktopMenu(13+ owner: DeferredTerminalCloseOwner,14+ now = Date.now(),15+): void {16+ deferredTerminalCloseIntent = { owner, createdAt: now };17+}18+19+export function consumeDeferredTerminalCloseOwner(20+ now = Date.now(),21+): DeferredTerminalCloseOwner | null {22+ const intent = deferredTerminalCloseIntent;23+ deferredTerminalCloseIntent = null;24+ if (!intent || now - intent.createdAt > DEFERRED_TERMINAL_CLOSE_TTL_MS) return null;25+ return intent.owner;26+}
- apps/web/src/lib/terminalFocus.ts line 27OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3,7 +11,17 @@11+ retainedTerminalFocusOwner = null;12+}13+314 export function getTerminalFocusOwner(): TerminalFocusOwner | null {415 const activeElement = document.activeElement;5- if (!(activeElement instanceof HTMLElement)) return null;6- if (!activeElement.isConnected) return null;16+ if (!(activeElement instanceof HTMLElement) || !activeElement.isConnected) {17+ return retainedTerminalFocusOwner;18+ }719 const owner = activeElement.closest<HTMLElement>("[data-terminal-owner]")?.dataset.terminalOwner;8- if (owner === "drawer" || owner === "right-panel") return owner;9- return null;20+ if (owner === "drawer" || owner === "right-panel") {21+ retainedTerminalFocusOwner = owner;22+ return owner;23+ }24+ if (activeElement !== document.body) {25+ retainedTerminalFocusOwner = null;26+ }27+ return retainedTerminalFocusOwner;
- apps/web/src/lib/nativeCloseFocus.ts line 37OutdatedResolvedby caezium(GitHub profile, opens in a new tab)@@ -0,0 +17,21 @@17+}18+19+/** Records an in-document focus or pointer transition before native UI can obscure DOM focus. */20+export function recordNativeCloseFocus(target: EventTarget | null): void {21+ retainedOwner = target instanceof Element ? ownerForElement(target) : null;22+}23+24+/**25+ * Clears real in-document focus exits while preserving ownership when focus26+ * temporarily moves into native application UI such as the macOS menu bar.27+ */28+export function recordNativeCloseFocusOut(29+ relatedTarget: EventTarget | null,30+ documentHasFocus: boolean,31+): void {32+ if (relatedTarget instanceof Element) {33+ retainedOwner = ownerForElement(relatedTarget);34+ return;35+ }36+ if (documentHasFocus) retainedOwner = null;37+}
- apps/web/src/lib/nativeCloseFocus.ts line 52OutdatedResolvedby caezium(GitHub profile, opens in a new tab)@@ -0,0 +32,21 @@32+ if (relatedTarget instanceof Element) {33+ retainedOwner = ownerForElement(relatedTarget);34+ return;35+ }36+ if (documentHasFocus) retainedOwner = null;37+}38+39+export function getNativeCloseFocusOwner(): NativeCloseFocusOwner | null {40+ const activeElement = document.activeElement;41+ if (activeElement instanceof Element && activeElement.isConnected) {42+ const liveOwner = ownerForElement(activeElement);43+ if (liveOwner !== null) {44+ retainedOwner = liveOwner;45+ return liveOwner;46+ }47+ if (activeElement !== document.body) {48+ retainedOwner = null;49+ return null;50+ }51+ }52+ return retainedOwner;
- apps/web/src/components/ChatView.tsx line 3326Resolvedby caezium(GitHub profile, opens in a new tab)@@ -3159,0 +3209,21 @@3209+ closeRightPanelSurface,3210+ rightPanelOpen,3211+ ],3212+ );3213+ const handleCloseRequest = useEffectEvent((event: Event) => {3214+ const target = resolveNativeCloseTarget({3215+ focusOwner: getNativeCloseFocusOwner(),3216+ drawerTerminalOpen: terminalUiState.terminalOpen,3217+ rightPanelOpen,3218+ hasActiveRightPanelSurface: activeRightPanelSurface !== null,3219+ activeRightPanelSurfaceIsTerminal: activeRightPanelSurface?.kind === "terminal",3220+ });3221+ if (target === "drawer-terminal") {3222+ closeTerminal(terminalUiState.activeTerminalId);3223+ } else if (target === "right-panel-terminal" && activeRightPanelSurface?.kind === "terminal") {3224+ closePanelTerminal(activeRightPanelSurface.activeTerminalId);3225+ } else if (target === "right-panel-surface" && activeRightPanelSurface) {3226+ closeRightPanelSurface(activeRightPanelSurface);3227+ } else if (target === "right-panel" && activeThreadRef) {3228+ setMaximizedRightPanelThreadKey(null);3229+ useRightPanelStore.getState().close(activeThreadRef);apps/web/src/lib/rightPanelFocus.ts line 15OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,15 @@1+/**2+ * Returns true when keyboard focus belongs to the tabbed right-panel chrome3+ * or its active surface. This deliberately excludes other preview-panel4+ * shells so right-panel shortcuts do not affect standalone preview layouts.5+ */6+export function isRightPanelFocused(): boolean {7+ const activeElement = document.activeElement;8+ if (!(activeElement instanceof HTMLElement)) return false;9+ if (!activeElement.isConnected) return false;10+ return (11+ activeElement.closest(12+ "[data-right-panel-tabbar], [data-right-panel-content], [data-right-panel-control]",13+ ) !== null14+ );15+}apps/web/src/lib/nativeCloseFocus.ts line 37OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +17,21 @@17+ if (element.tagName.toLowerCase() === "webview" || element.closest("[data-preview-viewport]")) {18+ return "right-panel";19+ }20+ return null;21+}22+23+/** Records an in-document focus or pointer transition before native UI can obscure DOM focus. */24+export function recordNativeCloseFocus(target: EventTarget | null): void {25+ retainedOwner = target instanceof Element ? ownerForElement(target) : null;26+}27+28+/** Records pointer intent before a non-focusable target can blur the previous owner to body. */29+export function recordNativeClosePointer(target: EventTarget | null): void {30+ pointerTransitionActive = true;31+ recordNativeCloseFocus(target);32+ queueMicrotask(finishNativeClosePointer);33+}34+35+export function finishNativeClosePointer(): void {36+ pointerTransitionActive = false;37+}apps/web/src/components/chat/PanelLayoutControls.tsx line 63Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -57,3 +58,4 @@5758 render={5859 <Toggle5960 className="shrink-0 [-webkit-app-region:no-drag]"61+ data-right-panel-control
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/web/src/lib/rightPanelFocus.ts line 11OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,11 @@1+/**2+ * Returns true when keyboard focus belongs to the tabbed right-panel chrome3+ * or its active surface. This deliberately excludes other preview-panel4+ * shells so right-panel shortcuts do not affect standalone preview layouts.5+ */6+export function isRightPanelFocused(rightPanelOpen: boolean): boolean {7+ if (!rightPanelOpen) return false;8+ const activeElement = document.activeElement;9+ if (!(activeElement instanceof HTMLElement)) return false;10+ if (!activeElement.isConnected) return false;11+ if (
- apps/web/src/components/ChatView.tsx line 3267OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3159,0 +3247,21 @@3247+ const recordFocusOut = (event: FocusEvent) => {3248+ recordNativeCloseFocusOut(event.relatedTarget, document.hasFocus());3249+ };3250+ const recordPointer = (event: PointerEvent) => {3251+ recordNativeClosePointer(event.target);3252+ };3253+3254+ recordNativeCloseFocus(document.activeElement);3255+ window.addEventListener("focusin", recordFocus, true);3256+ window.addEventListener("focusout", recordFocusOut, true);3257+ window.addEventListener("pointerdown", recordPointer, true);3258+ window.addEventListener("pointerup", finishNativeClosePointer, true);3259+ window.addEventListener("pointercancel", finishNativeClosePointer, true);3260+ window.addEventListener("blur", finishNativeClosePointer);3261+ return () => {3262+ window.removeEventListener("focusin", recordFocus, true);3263+ window.removeEventListener("focusout", recordFocusOut, true);3264+ window.removeEventListener("pointerdown", recordPointer, true);3265+ window.removeEventListener("pointerup", finishNativeClosePointer, true);3266+ window.removeEventListener("pointercancel", finishNativeClosePointer, true);3267+ window.removeEventListener("blur", finishNativeClosePointer);
- apps/web/src/lib/nativeCloseFocus.ts line 19OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,19 @@1+export type NativeCloseFocusOwner = "drawer-terminal" | "right-panel-terminal" | "right-panel";2+3+const RIGHT_PANEL_SELECTOR =4+ "[data-right-panel-tabbar], [data-right-panel-content], [data-right-panel-control]";5+6+let retainedOwner: NativeCloseFocusOwner | null = null;7+let pointerTransitionActive = false;8+9+function ownerForElement(element: Element): NativeCloseFocusOwner | null {10+ if (!element.isConnected) return null;11+12+ const terminalOwner =13+ element.closest<HTMLElement>("[data-terminal-owner]")?.dataset.terminalOwner;14+ if (terminalOwner === "drawer") return "drawer-terminal";15+ if (terminalOwner === "right-panel") return "right-panel-terminal";16+ if (element.closest(RIGHT_PANEL_SELECTOR)) return "right-panel";17+ if (element.tagName.toLowerCase() === "webview" || element.closest("[data-preview-viewport]")) {18+ return "right-panel";19+ }
- apps/web/src/components/ChatView.tsx line 3959OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -3832,3 +3956,4 @@38323956 terminalFocus: terminalFocusOwner !== null,38333957 terminalOpen: Boolean(terminalUiState.terminalOpen),38343958 modelPickerOpen: composerRef.current?.isModelPickerOpen() ?? false,3959+ rightPanelFocus: isRightPanelFocused({apps/desktop/src/window/DesktopWindow.ts line 799OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -772,17 +794,6 @@772794 return;773795 }774796 const targetWindow = Option.isSome(existingWindow) ? existingWindow.value : yield* ensureMain;775-776- const send = () => {777- if (targetWindow.isDestroyed()) return;778- targetWindow.webContents.send(MENU_ACTION_CHANNEL, action);779- void runPromise(electronWindow.reveal(targetWindow));780- };781-782- if (targetWindow.webContents.isLoadingMainFrame()) {783- targetWindow.webContents.once("did-finish-load", send);784- return;785- }786-787- send();797+ yield* sendMenuAction(targetWindow, action, true);788798 }),799+ dispatchMenuActionToMainWindow: Effect.fn("desktop.window.dispatchMenuActionToMainWindow")(
- apps/web/src/components/ChatView.tsx line 3991OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3851,3 +3979,13 @@38513979 });38523980 if (!command) return;385339813982+ if (3983+ shouldDeferCloseCommandToDesktopMenu({3984+ command,3985+ desktop: isElectron,3986+ platform: navigator.platform,3987+ event,3988+ terminalFocused: terminalFocusOwner !== null,3989+ })3990+ ) {3991+ return;apps/web/src/components/ChatView.tsx line 3962OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3832,3 +3956,7 @@38323956 terminalFocus: terminalFocusOwner !== null,38333957 terminalOpen: Boolean(terminalUiState.terminalOpen),38343958 modelPickerOpen: composerRef.current?.isModelPickerOpen() ?? false,3959+ rightPanelFocus: isRightPanelFocused({3960+ rightPanelOpen,3961+ activePreviewTabId: activeRightPanelPreviewTabId,3962+ }),
- apps/web/src/lib/nativeCloseFocus.ts line 85OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +65,21 @@65+ return;66+ }67+ if (documentHasFocus && !pointerTransitionActive) retainedOwner = null;68+}69+70+export function getNativeCloseFocusOwner(71+ activePreviewTabId: string | null,72+): NativeCloseFocusOwner | null {73+ const activeElement = document.activeElement;74+ if (activeElement instanceof Element && activeElement.isConnected) {75+ const liveOwner = ownerForElement(activeElement, activePreviewTabId);76+ if (liveOwner !== null) {77+ retainedOwner = liveOwner;78+ return liveOwner;79+ }80+ if (activeElement !== document.body) {81+ retainedOwner = null;82+ return null;83+ }84+ }85+ return retainedOwner;apps/web/src/lib/nativeCloseFocus.ts line 30OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +10,21 @@10+ element: Element,11+ activePreviewTabId: string | null,12+): NativeCloseFocusOwner | null {13+ if (!element.isConnected) return null;14+15+ const terminalOwner =16+ element.closest<HTMLElement>("[data-terminal-owner]")?.dataset.terminalOwner;17+ if (terminalOwner === "drawer") return "drawer-terminal";18+ if (terminalOwner === "right-panel") return "right-panel-terminal";19+20+ const previewViewport = element.closest<HTMLElement>("[data-preview-viewport]");21+ const focusedPreviewTabId =22+ element.tagName.toLowerCase() === "webview"23+ ? element.getAttribute("data-preview-tab")24+ : (previewViewport?.getAttribute("data-preview-viewport") ?? null);25+ if (focusedPreviewTabId !== null) {26+ return focusedPreviewTabId === activePreviewTabId ? "right-panel" : null;27+ }28+29+ if (element.closest(RIGHT_PANEL_SELECTOR)) return "right-panel";30+ return null;apps/web/src/lib/nativeCloseFocus.ts line 30OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +10,21 @@10+ element: Element,11+ activePreviewTabId: string | null,12+): NativeCloseFocusOwner | null {13+ if (!element.isConnected) return null;14+15+ const terminalOwner =16+ element.closest<HTMLElement>("[data-terminal-owner]")?.dataset.terminalOwner;17+ if (terminalOwner === "drawer") return "drawer-terminal";18+ if (terminalOwner === "right-panel") return "right-panel-terminal";19+20+ const previewViewport = element.closest<HTMLElement>("[data-preview-viewport]");21+ const focusedPreviewTabId =22+ element.tagName.toLowerCase() === "webview"23+ ? element.getAttribute("data-preview-tab")24+ : (previewViewport?.getAttribute("data-preview-viewport") ?? null);25+ if (focusedPreviewTabId !== null) {26+ return focusedPreviewTabId === activePreviewTabId ? "right-panel" : null;27+ }28+29+ if (element.closest(RIGHT_PANEL_SELECTOR)) return "right-panel";30+ return null;
- apps/desktop/src/preview/Manager.ts lines 351 to 379Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -339 +343,21 @@343+ { key: "k", shiftKey: false },344+ // Meta+, → settings (macOS convention)345+ { key: ",", shiftKey: false },339346 ]);347+const DEFAULT_RIGHT_PANEL_CLOSE_SHORTCUTS = Object.freeze([modShortcut("w")]);348+const ELECTRON_KEY_CODES: Readonly<Record<string, string>> = {349+ " ": "Space",350+ arrowdown: "Down",351+ arrowleft: "Left",352+ arrowright: "Right",353+ arrowup: "Up",354+ backspace: "Backspace",355+ delete: "Delete",356+ end: "End",357+ enter: "Enter",358+ escape: "Escape",359+ home: "Home",360+ pagedown: "PageDown",361+ pageup: "PageUp",362+ tab: "Tab",363+};
- @@ -0,0 +118,21 @@118+ documentHasFocus &&119+ !(120+ retainedElement !== null &&121+ retainedRightPanelIsCurrent(context) &&122+ previewTabIdForElement(retainedElement) !== null123+ )124+ ) {125+ clearRetained();126+ }127+ },128+ current: (context) => {129+ if (explicitPointerOwner !== undefined) {130+ if (131+ explicitPointerOwner === "right-panel" &&132+ (!context.rightPanelOpen || explicitPointerPanelScopeKey !== context.rightPanelScopeKey)133+ ) {134+ explicitPointerOwner = null;135+ explicitPointerPanelScopeKey = null;136+ clearRetained();137+ }138+ return explicitPointerOwner;
- apps/web/src/components/RightPanelTabs.tsx line 373Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -369,3 +370,4 @@369370 hideScrollbars370371 scrollFade371372 className={cn("min-w-0 flex-1 rounded-none", ownsDesktopTitleBar && "drag-region")}373+ data-right-panel-drag-region={ownsDesktopTitleBar ? "" : undefined}apps/web/src/components/ChatView.tsx line 4066OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3894,5 +4058,9 @@38944058 if (command === "terminal.close") {38954059 event.preventDefault();38964060 event.stopPropagation();3897- if (terminalFocusOwner === "right-panel" && activeRightPanelSurface?.kind === "terminal") {3898- closePanelTerminal(activeRightPanelSurface.activeTerminalId);4061+ if (4062+ closeRequestTarget !== null &&4063+ closeRequestTarget !== "drawer-terminal" &&4064+ shouldHandleCloseRequest(closeRequestTarget, command)4065+ ) {4066+ closeActiveRightPanelTarget();apps/web/src/components/ChatView.tsx line 4423Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3822,13 +3979,15 @@38223979 if (!activeThreadId || isCommandPaletteOpen()) {38233980 return;38243981 }3825- const terminalFocusOwner = getTerminalFocusOwner();3982+ const {3983+ closeRequestTarget,3984+ context: shortcutContext,3985+ terminalFocusOwner,3986+ } = readShortcutFocus();38263987 if (event.defaultPrevented && terminalFocusOwner === null) {38273988 return;38283989 }3829- const shortcutContext = {3830- terminalFocus: terminalFocusOwner !== null,3831- terminalOpen: Boolean(terminalUiState.terminalOpen),3832- modelPickerOpen: composerRef.current?.isModelPickerOpen() ?? false,3833- };383439903991+ const command = resolveShortcutCommand(event, keybindings, {3992+ context: shortcutContext,3993+ });packages/shared/src/keybindings.ts line 37Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -25,4 +25,13 @@2525 { key: "mod+d", command: "terminal.split", when: "terminalFocus" },2626 { key: "mod+shift+d", command: "terminal.splitVertical", when: "terminalFocus" },2727 { key: "mod+n", command: "terminal.new", when: "terminalFocus" },28- { key: "mod+w", command: "terminal.close", when: "terminalFocus" },28+ {29+ key: "mod+w",30+ command: "terminal.close",31+ when: "terminalFocus && !rightPanelFocus",32+ },33+ {34+ key: "mod+w",35+ command: "rightPanel.closeActiveSurface",36+ when: "rightPanelFocus",37+ },
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/desktop/src/preview/Manager.ts lines 395 to 395OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -339,0 +375,21 @@375+ volumemute: "VolumeMute",376+ volumeup: "VolumeUp",377+};378+379+type ForwardedPreviewShortcutInput = Pick<380+ Electron.Input,381+ "type" | "key" | "code" | "meta" | "shift" | "control" | "alt"382+>;383+384+function electronKeyCodeForShortcut(key: string, inputKey: string): string | null {385+ const namedKeyCode = ELECTRON_KEY_CODES[key];386+ if (namedKeyCode) return namedKeyCode;387+ if (/^f(?:[1-9]|1\d|2[0-4])$/.test(key)) return key.toUpperCase();388+ if (key.length === 1) return key;389+ return normalizeKeybindingEventKey(inputKey) === key ? inputKey : null;390+}391+392+export function resolveForwardedPreviewShortcutKey(393+ input: ForwardedPreviewShortcutInput,394+ platform: NodeJS.Platform,395+ rightPanelCloseShortcuts: ReadonlyArray<KeybindingShortcut> = DEFAULT_RIGHT_PANEL_CLOSE_SHORTCUTS,
- apps/web/src/components/ChatView.tsx line 3334OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3203,0 +3314,21 @@3314+ }3315+ if (action === "close-right-panel-surface") {3316+ return closeActiveRightPanelTarget();3317+ }3318+ return false;3319+ },3320+ [3321+ activeRightPanelSurface,3322+ closeActiveRightPanelTarget,3323+ closePanelTerminal,3324+ closeTerminal,3325+ terminalUiState.activeTerminalId,3326+ ],3327+ );3328+ const handleCloseRequest = useEffectEvent((event: Event) => {3329+ if (event.defaultPrevented) return;3330+ const { closeRequestTarget: target, context } = readShortcutFocus();3331+ if (target === null) return;3332+ const command = resolveShortcutCommand(NATIVE_CLOSE_SHORTCUT, keybindings, { context });3333+ if (!performCloseRequest(target, command)) return;3334+ event.preventDefault();
- apps/desktop/src/preview/Manager.ts line 527Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -414,3 +522,4 @@414522 const actionSequenceRef = yield* Ref.make(0);415523 const pointerSequenceRef = yield* Ref.make(0);416524 const recordingTabIdRef = yield* Ref.make<Option.Option<string>>(Option.none());525+ const rightPanelCloseShortcutsRef = yield* Ref.make<ReadonlyArray<KeybindingShortcut>>([]);
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
6d66ce6a-fe4b-498d-9a58-a70b5be0241cYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share