GeezerVison is showing github.com — feat(web): next and previous right panel tab shortcuts · andromidasj/t3code@3effa82
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/preview/Manager.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1606,7 +1606,9 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function | 1606 | 1606 | if ( | 1607 | 1607 | forwarded.command === "workspace.focusNext" || | 1608 | 1608 | forwarded.command === "workspace.focusPrevious" || | 1609 | | - forwarded.command === "preview.focusUrl" | | 1609 | + forwarded.command === "preview.focusUrl" || | | 1610 | + forwarded.command === "rightPanel.nextTab" || | | 1611 | + forwarded.command === "rightPanel.previousTab" | 1610 | 1612 | ) { | 1611 | 1613 | // DOM focus in the renderer cannot by itself release the guest's native keyboard focus. | 1612 | 1614 | host.focus(); | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/ChatView.tsx +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2549,6 +2549,7 @@ export default function ChatView(props: ChatViewProps) { | 2549 | 2549 | : null; | 2550 | 2550 | const { | 2551 | 2551 | activateRightPanelSurfaceStable, | | 2552 | + activateAdjacentRightPanelSurfaceStable, | 2552 | 2553 | addDeviceSurfaceStable, | 2553 | 2554 | addDiffSurfaceStable, | 2554 | 2555 | addFilesSurfaceStable, | @@ -3011,13 +3012,16 @@ export default function ChatView(props: ChatViewProps) { | 3011 | 3012 | if (action === "rightPanel.toggle") toggleRightPanelStable(); | 3012 | 3013 | else if (action === "rightPanel.toggleMaximized") toggleRightPanelMaximizedStable(); | 3013 | 3014 | else if (action === "rightPanel.close") closeActiveRightPanelSurfaceStable(); | | 3015 | + else if (action === "rightPanel.nextTab") activateAdjacentRightPanelSurfaceStable(1); | | 3016 | + else if (action === "rightPanel.previousTab") activateAdjacentRightPanelSurfaceStable(-1); | 3014 | 3017 | }); | 3015 | 3018 | }, [ | 3016 | 3019 | embedded, | 3017 | 3020 | backgroundThread, | 3018 | 3021 | toggleRightPanelStable, | 3019 | 3022 | toggleRightPanelMaximizedStable, | 3020 | 3023 | closeActiveRightPanelSurfaceStable, | | 3024 | + activateAdjacentRightPanelSurfaceStable, | 3021 | 3025 | ]); | 3022 | 3026 |
| 3023 | 3027 | usePasteToFocusComposer(embedded ? null : activeThreadId, composerRef); | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/ReopenClosedViewShortcut.tsx +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -65,6 +65,8 @@ const PREVIEW_FORWARDED_COMMANDS = [ | 65 | 65 | "rightPanel.toggleMaximized", | 66 | 66 | "rightPanel.new", | 67 | 67 | "rightPanel.close", | | 68 | + "rightPanel.nextTab", | | 69 | + "rightPanel.previousTab", | 68 | 70 | "preview.focusUrl", | 69 | 71 | "preview.zoomIn", | 70 | 72 | "preview.zoomOut", | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/useChatShortcuts.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,6 +27,8 @@ const SIDE_CHAT_PANE_COMMANDS: ReadonlySet<KeybindingCommand> = new Set([ | 27 | 27 | "rightPanel.toggle", | 28 | 28 | "rightPanel.close", | 29 | 29 | "rightPanel.toggleMaximized", | | 30 | + "rightPanel.nextTab", | | 31 | + "rightPanel.previousTab", | 30 | 32 | ]); | 31 | 33 |
| 32 | 34 | interface ChatShortcutsInput { | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/useRightPanelActions.ts +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,6 +21,7 @@ import { | 21 | 21 | import { useDiffPanelStore } from "../../diffPanelStore"; | 22 | 22 | import { type ThreadPanelPresentation } from "../../rightPanelLayout"; | 23 | 23 | import { | | 24 | + selectAdjacentRightPanelSurface, | 24 | 25 | selectThreadPanelOpen, | 25 | 26 | type RightPanelSurface, | 26 | 27 | useRightPanelStore, | @@ -238,6 +239,18 @@ export function useRightPanelActions(input: RightPanelActionsInput) { | 238 | 239 | } | 239 | 240 | }; | 240 | 241 | const activateRightPanelSurfaceStable = useStableCallback(activateRightPanelSurface); | | 242 | + const activateAdjacentRightPanelSurface = (step: 1 | -1) => { | | 243 | + const surface = selectAdjacentRightPanelSurface( | | 244 | + useRightPanelStore.getState().byThreadKey, | | 245 | + activeThreadRef, | | 246 | + step, | | 247 | + ); | | 248 | + if (!surface) return false; | | 249 | + activateRightPanelSurface(surface); | | 250 | + }; | | 251 | + const activateAdjacentRightPanelSurfaceStable = useStableCallback( | | 252 | + activateAdjacentRightPanelSurface, | | 253 | + ); | 241 | 254 | const toggleRightPanel = () => { | 242 | 255 | if (!activeThreadRef) return; | 243 | 256 | if (rightPanelOpen) { | @@ -337,12 +350,15 @@ export function useRightPanelActions(input: RightPanelActionsInput) { | 337 | 350 | if (!activeRightPanelSurface) return false; | 338 | 351 | if (!event.repeat) closeRightPanelSurface(activeRightPanelSurface); | 339 | 352 | }, | | 353 | + "rightPanel.nextTab": () => activateAdjacentRightPanelSurface(1), | | 354 | + "rightPanel.previousTab": () => activateAdjacentRightPanelSurface(-1), | 340 | 355 | "diff.toggle": () => onToggleDiff(), | 341 | 356 | } satisfies ChatShortcutCommands; | 342 | 357 |
| 343 | 358 | return { | 344 | 359 | shortcuts, | 345 | 360 | activateRightPanelSurfaceStable, | | 361 | + activateAdjacentRightPanelSurfaceStable, | 346 | 362 | addDeviceSurfaceStable, | 347 | 363 | addDiffSurfaceStable, | 348 | 364 | addFilesSurfaceStable, | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/files/BrowserDocumentFrame.tsx +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -65,6 +65,8 @@ const HTML_RENDER_SHORTCUT_COMMANDS: ReadonlySet<KeybindingCommand> = new Set([ | 65 | 65 | "sidebar.toggle", | 66 | 66 | "rightPanel.toggle", | 67 | 67 | "rightPanel.toggleMaximized", | | 68 | + "rightPanel.nextTab", | | 69 | + "rightPanel.previousTab", | 68 | 70 | "threadPanel.toggle", | 69 | 71 | "terminal.toggle", | 70 | 72 | "preview.toggle", | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/keybindings.test.ts +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -362,6 +362,26 @@ describe("thread navigation helpers", () => { | 362 | 362 | ); | 363 | 363 | }); | 364 | 364 |
| | 365 | + it("switches right panel tabs with mod+alt arrows on macOS", () => { | | 366 | + const options = { platform: "MacIntel", context: { isDesktop: true } }; | | 367 | + assert.strictEqual( | | 368 | + resolveShortcutCommand( | | 369 | + event({ key: "ArrowRight", code: "ArrowRight", metaKey: true, altKey: true }), | | 370 | + DEFAULT_RESOLVED_KEYBINDINGS, | | 371 | + options, | | 372 | + ), | | 373 | + "rightPanel.nextTab", | | 374 | + ); | | 375 | + assert.strictEqual( | | 376 | + resolveShortcutCommand( | | 377 | + event({ key: "ArrowLeft", code: "ArrowLeft", metaKey: true, altKey: true }), | | 378 | + DEFAULT_RESOLVED_KEYBINDINGS, | | 379 | + options, | | 380 | + ), | | 381 | + "rightPanel.previousTab", | | 382 | + ); | | 383 | + }); | | 384 | + | 365 | 385 | it("keeps default thread jumps off the web so the browser can switch tabs", () => { | 366 | 386 | const input = event({ key: "1", metaKey: true }); | 367 | 387 | assert.isNull( | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/rightPanelStore.test.ts +21Lines changed: 21 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,7 @@ import { | 12 | 12 | pullRequestSurfaceId, | 13 | 13 | selectActiveRightPanel, | 14 | 14 | selectActiveRightPanelSurface, | | 15 | + selectAdjacentRightPanelSurface, | 15 | 16 | selectThreadPanelOpen, | 16 | 17 | selectThreadPanelVisibility, | 17 | 18 | selectThreadRightPanelState, | @@ -42,6 +43,26 @@ async function reloadRightPanelStore() { | 42 | 43 | } | 43 | 44 |
| 44 | 45 | describe("rightPanelStore", () => { | | 46 | + it("steps through the open panel's tabs in tab order, wrapping at both ends", () => { | | 47 | + const store = useRightPanelStore.getState(); | | 48 | + const adjacent = (step: 1 | -1) => | | 49 | + selectAdjacentRightPanelSurface(useRightPanelStore.getState().byThreadKey, refA, step)?.id; | | 50 | + store.openFile(refA, "src/app.ts"); | | 51 | + expect(adjacent(1)).toBeUndefined(); | | 52 | + store.openThread(refA, ThreadId.make("side-1")); | | 53 | + store.openThread(refA, ThreadId.make("side-2")); | | 54 | + const ids = selectThreadRightPanelState( | | 55 | + useRightPanelStore.getState().byThreadKey, | | 56 | + refA, | | 57 | + ).surfaces.map((surface) => surface.id); | | 58 | + expect(adjacent(1)).toBe(ids[0]); | | 59 | + expect(adjacent(-1)).toBe(ids[1]); | | 60 | + store.activateSurface(refA, ids[0]!); | | 61 | + expect(adjacent(-1)).toBe(ids[2]); | | 62 | + store.close(refA); | | 63 | + expect(adjacent(1)).toBeUndefined(); | | 64 | + }); | | 65 | + | 45 | 66 | it("opens a hosted side chat's panel actions in its parent's panel until unhosted", () => { | 46 | 67 | const store = useRightPanelStore.getState(); | 47 | 68 | const unhost = hostRightPanel(refB, refA); | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/rightPanelStore.ts +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1485,6 +1485,19 @@ export function selectActiveRightPanelSurface( | 1485 | 1485 | return selectSelectedRightPanelSurface(byThreadKey, ref); | 1486 | 1486 | } | 1487 | 1487 |
| | 1488 | +/** The open panel's tab `step` places from the active one, wrapping; null without another tab. */ | | 1489 | +export function selectAdjacentRightPanelSurface( | | 1490 | + byThreadKey: Record<string, ThreadRightPanelState>, | | 1491 | + ref: ScopedThreadRef | null | undefined, | | 1492 | + step: 1 | -1, | | 1493 | +): RightPanelSurface | null { | | 1494 | + const { surfaces } = selectThreadRightPanelState(byThreadKey, ref); | | 1495 | + const active = selectActiveRightPanelSurface(byThreadKey, ref); | | 1496 | + if (active === null || surfaces.length < 2) return null; | | 1497 | + const index = surfaces.indexOf(active); | | 1498 | + return surfaces[(index + step + surfaces.length) % surfaces.length] ?? null; | | 1499 | +} | | 1500 | + | 1488 | 1501 | export function selectSelectedRightPanelSurface( | 1489 | 1502 | byThreadKey: Record<string, ThreadRightPanelState>, | 1490 | 1503 | ref: ScopedThreadRef | null | undefined, | |
Collapse file Copy file name to clipboardExpand all lines: docs/user/keybindings.md +4Lines changed: 4 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,10 @@ Configure whether `Enter` sends or requires `mod+Enter` in **Settings → Chat | 25 | 25 |
| 26 | 26 | In the model picker, use `Left`/`Shift+Tab` to move to the provider list, `Right` to return to search or move into effort levels, and `Up`/`Down`/`Enter` to select. | 27 | 27 |
| | 28 | +## Switch right panel tabs | | 29 | + | | 30 | +`mod+alt+right` and `mod+alt+left` move to the next and previous tab in the open right panel, wrapping at either end. They work while you type in a side chat too. They are desktop-only by default, because Chrome on macOS keeps those keys for switching browser tabs. In a browser, bind your own keys under **Right Panel: Next Tab** and **Right Panel: Previous Tab**. | | 31 | + | 28 | 32 | ## Copy pull request and thread references | 29 | 33 |
| 30 | 34 | - `mod+shift+c`: Copies the open PR's URL (or copies a thread chip link when no PR is open). | |
|