GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(web): next and previous right panel tab shortcuts · andromidasj/t3code@3effa82

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps
    • desktop/src/preview
      • Manager.ts
    • web/src
      • components
        • ChatView.tsx
        • ReopenClosedViewShortcut.tsx
        • chat
          • useChatShortcuts.ts
          • useRightPanelActions.ts
        • files
          • BrowserDocumentFrame.tsx
      • keybindings.test.ts
      • rightPanelStore.test.ts
      • rightPanelStore.ts
  • docs/user
    • keybindings.md
  • packages
    • contracts/src
      • keybindings.ts
    • shared/src
      • keybindings.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/desktop/src/preview/Manager.ts‎

Copy file name to clipboardExpand all lines: apps/desktop/src/preview/Manager.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,9 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
16061606
if (
16071607
forwarded.command === "workspace.focusNext" ||
16081608
forwarded.command === "workspace.focusPrevious" ||
1609-
forwarded.command === "preview.focusUrl"
1609+
forwarded.command === "preview.focusUrl" ||
1610+
forwarded.command === "rightPanel.nextTab" ||
1611+
forwarded.command === "rightPanel.previousTab"
16101612
) {
16111613
// DOM focus in the renderer cannot by itself release the guest's native keyboard focus.
16121614
host.focus();
Collapse file

‎apps/web/src/components/ChatView.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ChatView.tsx
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,7 @@ export default function ChatView(props: ChatViewProps) {
25492549
: null;
25502550
const {
25512551
activateRightPanelSurfaceStable,
2552+
activateAdjacentRightPanelSurfaceStable,
25522553
addDeviceSurfaceStable,
25532554
addDiffSurfaceStable,
25542555
addFilesSurfaceStable,
@@ -3011,13 +3012,16 @@ export default function ChatView(props: ChatViewProps) {
30113012
if (action === "rightPanel.toggle") toggleRightPanelStable();
30123013
else if (action === "rightPanel.toggleMaximized") toggleRightPanelMaximizedStable();
30133014
else if (action === "rightPanel.close") closeActiveRightPanelSurfaceStable();
3015+
else if (action === "rightPanel.nextTab") activateAdjacentRightPanelSurfaceStable(1);
3016+
else if (action === "rightPanel.previousTab") activateAdjacentRightPanelSurfaceStable(-1);
30143017
});
30153018
}, [
30163019
embedded,
30173020
backgroundThread,
30183021
toggleRightPanelStable,
30193022
toggleRightPanelMaximizedStable,
30203023
closeActiveRightPanelSurfaceStable,
3024+
activateAdjacentRightPanelSurfaceStable,
30213025
]);
30223026

30233027
usePasteToFocusComposer(embedded ? null : activeThreadId, composerRef);
Collapse file

‎apps/web/src/components/ReopenClosedViewShortcut.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ReopenClosedViewShortcut.tsx
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const PREVIEW_FORWARDED_COMMANDS = [
6565
"rightPanel.toggleMaximized",
6666
"rightPanel.new",
6767
"rightPanel.close",
68+
"rightPanel.nextTab",
69+
"rightPanel.previousTab",
6870
"preview.focusUrl",
6971
"preview.zoomIn",
7072
"preview.zoomOut",
Collapse file

‎apps/web/src/components/chat/useChatShortcuts.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/useChatShortcuts.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const SIDE_CHAT_PANE_COMMANDS: ReadonlySet<KeybindingCommand> = new Set([
2727
"rightPanel.toggle",
2828
"rightPanel.close",
2929
"rightPanel.toggleMaximized",
30+
"rightPanel.nextTab",
31+
"rightPanel.previousTab",
3032
]);
3133

3234
interface ChatShortcutsInput {
Collapse file

‎apps/web/src/components/chat/useRightPanelActions.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/useRightPanelActions.ts
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import { useDiffPanelStore } from "../../diffPanelStore";
2222
import { type ThreadPanelPresentation } from "../../rightPanelLayout";
2323
import {
24+
selectAdjacentRightPanelSurface,
2425
selectThreadPanelOpen,
2526
type RightPanelSurface,
2627
useRightPanelStore,
@@ -238,6 +239,18 @@ export function useRightPanelActions(input: RightPanelActionsInput) {
238239
}
239240
};
240241
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+
);
241254
const toggleRightPanel = () => {
242255
if (!activeThreadRef) return;
243256
if (rightPanelOpen) {
@@ -337,12 +350,15 @@ export function useRightPanelActions(input: RightPanelActionsInput) {
337350
if (!activeRightPanelSurface) return false;
338351
if (!event.repeat) closeRightPanelSurface(activeRightPanelSurface);
339352
},
353+
"rightPanel.nextTab": () => activateAdjacentRightPanelSurface(1),
354+
"rightPanel.previousTab": () => activateAdjacentRightPanelSurface(-1),
340355
"diff.toggle": () => onToggleDiff(),
341356
} satisfies ChatShortcutCommands;
342357

343358
return {
344359
shortcuts,
345360
activateRightPanelSurfaceStable,
361+
activateAdjacentRightPanelSurfaceStable,
346362
addDeviceSurfaceStable,
347363
addDiffSurfaceStable,
348364
addFilesSurfaceStable,
Collapse file

‎apps/web/src/components/files/BrowserDocumentFrame.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/files/BrowserDocumentFrame.tsx
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const HTML_RENDER_SHORTCUT_COMMANDS: ReadonlySet<KeybindingCommand> = new Set([
6565
"sidebar.toggle",
6666
"rightPanel.toggle",
6767
"rightPanel.toggleMaximized",
68+
"rightPanel.nextTab",
69+
"rightPanel.previousTab",
6870
"threadPanel.toggle",
6971
"terminal.toggle",
7072
"preview.toggle",
Collapse file

‎apps/web/src/keybindings.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/keybindings.test.ts
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,26 @@ describe("thread navigation helpers", () => {
362362
);
363363
});
364364

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+
365385
it("keeps default thread jumps off the web so the browser can switch tabs", () => {
366386
const input = event({ key: "1", metaKey: true });
367387
assert.isNull(
Collapse file

‎apps/web/src/rightPanelStore.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/rightPanelStore.test.ts
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
pullRequestSurfaceId,
1313
selectActiveRightPanel,
1414
selectActiveRightPanelSurface,
15+
selectAdjacentRightPanelSurface,
1516
selectThreadPanelOpen,
1617
selectThreadPanelVisibility,
1718
selectThreadRightPanelState,
@@ -42,6 +43,26 @@ async function reloadRightPanelStore() {
4243
}
4344

4445
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+
4566
it("opens a hosted side chat's panel actions in its parent's panel until unhosted", () => {
4667
const store = useRightPanelStore.getState();
4768
const unhost = hostRightPanel(refB, refA);
Collapse file

‎apps/web/src/rightPanelStore.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/rightPanelStore.ts
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,19 @@ export function selectActiveRightPanelSurface(
14851485
return selectSelectedRightPanelSurface(byThreadKey, ref);
14861486
}
14871487

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+
14881501
export function selectSelectedRightPanelSurface(
14891502
byThreadKey: Record<string, ThreadRightPanelState>,
14901503
ref: ScopedThreadRef | null | undefined,
Collapse file

‎docs/user/keybindings.md‎

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 numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Configure whether `Enter` sends or requires `mod+Enter` in **Settings → Chat
2525

2626
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.
2727

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+
2832
## Copy pull request and thread references
2933

3034
- `mod+shift+c`: Copies the open PR's URL (or copies a thread chip link when no PR is open).

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.