From ec929230e54c0dc80a2fe134fc18d331ac0a2947 Mon Sep 17 00:00:00 2001 From: bk-agent-01 Date: Wed, 7 Oct 2026 08:25:28 +0000 Subject: [PATCH] feat(web): assignable chat scroll keybinding commands Add chat.scrollPageUp, chat.scrollPageDown and chat.scrollToEnd. They have no default shortcut, so anyone can bind chat scrolling to any key (for example ctrl+w / ctrl+s for one-handed use). Page commands drive the existing PageUp/PageDown controller, so holding the key keeps scrolling; any keyup or window blur releases it. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatView.tsx | 40 +++++++++++++++++++ .../KeybindingsSettings.logic.test.ts | 17 ++++++++ .../settings/KeybindingsSettings.logic.ts | 4 ++ docs/user/keybindings.md | 4 ++ packages/contracts/src/keybindings.ts | 4 ++ 5 files changed, 69 insertions(+) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 9f886e14a85b4..1da3ffcbaccb8 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -6348,6 +6348,22 @@ export default function ChatView(props: ChatViewProps) { const onComposerPageScrollRelease = useCallback(() => { pageScrollControllerRef.current?.releaseActiveKey(); }, []); + // T3-CUSTOM(expbkt3): a held chat.scrollPage* binding stops on the first keyup + // (the bound key or one of its modifiers) or when the window loses focus. + const keybindingPageScrollActiveRef = useRef(false); + useEffect(() => { + const release = () => { + if (!keybindingPageScrollActiveRef.current) return; + keybindingPageScrollActiveRef.current = false; + pageScrollControllerRef.current?.releaseActiveKey(); + }; + window.addEventListener("keyup", release, true); + window.addEventListener("blur", release); + return () => { + window.removeEventListener("keyup", release, true); + window.removeEventListener("blur", release); + }; + }, []); // Live-follow stays active after send/thread-open until an actual list scroll // gesture opts out. const scrollToEnd = useCallback((animated = false) => { @@ -8078,6 +8094,28 @@ export default function ChatView(props: ChatViewProps) { return; } + // T3-CUSTOM(expbkt3): assignable chat scroll commands (no default shortcut). + // The page controller drives the hold, so key repeats are ignored; a keyup releases it. + if (command === "chat.scrollPageUp" || command === "chat.scrollPageDown") { + event.preventDefault(); + event.stopPropagation(); + if (event.repeat) return; + keybindingPageScrollActiveRef.current = true; + pageScrollControllerRef.current?.handleKeyDown( + command === "chat.scrollPageUp" ? "PageUp" : "PageDown", + ); + return; + } + if (command === "chat.scrollToEnd") { + event.preventDefault(); + event.stopPropagation(); + if (event.repeat) return; + pageScrollControllerRef.current?.releaseActiveKey(); + composerRef.current?.restoreAfterTimelineReachedEnd(); + scrollToEnd(true); + return; + } + if (command === "thread.stop") { // An unavailable command should not shadow contextual shortcuts such as Escape to close a dialog. if (!canInterruptRunningThread) return; @@ -8134,6 +8172,8 @@ export default function ChatView(props: ChatViewProps) { toggleThreadPanel, toggleTerminalVisibility, composerRef, + // T3-CUSTOM(expbkt3): chat.scrollToEnd keybinding. + scrollToEnd, draftId, environmentId, envLocked, diff --git a/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts b/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts index 40f24c9bf3bae..53f1c8735feaf 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts +++ b/apps/web/src/components/settings/KeybindingsSettings.logic.test.ts @@ -316,6 +316,23 @@ describe("KeybindingsSettings.logic", () => { } }); + it("offers the chat scroll commands for assignment without a default shortcut", () => { + const options = buildKeybindingCommandOptions(DEFAULT_RESOLVED_KEYBINDINGS); + const expectedLabels = { + "chat.scrollPageUp": "Chat: Scroll Up One Page", + "chat.scrollPageDown": "Chat: Scroll Down One Page", + "chat.scrollToEnd": "Chat: Jump to Latest Message", + } as const; + + for (const [command, label] of Object.entries(expectedLabels)) { + expect(options).toContain(command); + expect(commandLabel(command as keyof typeof expectedLabels)).toBe(label); + expect(DEFAULT_RESOLVED_KEYBINDINGS.some((binding) => binding.command === command)).toBe( + false, + ); + } + }); + it("reports unknown when variables without rejecting parseable expressions", () => { const parsed = parseWhenExpressionDraft("!terminalFocus && terminalFoc"); diff --git a/apps/web/src/components/settings/KeybindingsSettings.logic.ts b/apps/web/src/components/settings/KeybindingsSettings.logic.ts index 4897007d8fdac..57192e1775421 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.logic.ts +++ b/apps/web/src/components/settings/KeybindingsSettings.logic.ts @@ -318,6 +318,10 @@ export function commandLabel(command: KeybindingCommand): string { if (command === "thread.steerQueuedMessage") return "Queue: Send First Queued Message as Steer"; if (command === "thread.editQueuedMessage") return "Queue: Edit Last Queued Message"; if (command === "thread.copyReference") return "Pull Request: Copy Link or Thread ID"; + // T3-CUSTOM(expbkt3): labels for the assignable chat scroll commands. + if (command === "chat.scrollPageUp") return "Chat: Scroll Up One Page"; + if (command === "chat.scrollPageDown") return "Chat: Scroll Down One Page"; + if (command === "chat.scrollToEnd") return "Chat: Jump to Latest Message"; const usageMetric = METRIC_OPTIONS.find((option) => option.command === command); if (usageMetric) return `Usage: ${usageMetric.label}`; const usagePeriod = WINDOW_OPTIONS.find((option) => option.command === command); diff --git a/docs/user/keybindings.md b/docs/user/keybindings.md index 24abeb5d96c2b..3df672ac1cde9 100644 --- a/docs/user/keybindings.md +++ b/docs/user/keybindings.md @@ -123,6 +123,10 @@ a shortcut. `thread.stop` interrupts the running turn in the focused thread. It has no default shortcut; assign one in **Settings → Keybindings**. +`chat.scrollPageUp` and `chat.scrollPageDown` scroll the chat one page, like PageUp and +PageDown, and keep scrolling while you hold the key. `chat.scrollToEnd` jumps to the +latest message. These commands have no default shortcut; assign any key to them. + `thread.undo` (`mod+z` by default) reverses the actions shown in the notice at the bottom of the sidebar, such as unpin, settle, snooze, archive, or discarding a draft. Consecutive diff --git a/packages/contracts/src/keybindings.ts b/packages/contracts/src/keybindings.ts index e42396dbc582d..1922f473b2fc3 100644 --- a/packages/contracts/src/keybindings.ts +++ b/packages/contracts/src/keybindings.ts @@ -98,6 +98,10 @@ export const STATIC_KEYBINDING_COMMANDS = [ "chat.new", "chat.newLocal", "chat.newWithoutProject", + // T3-CUSTOM(expbkt3): assignable chat scroll commands (no default shortcut). + "chat.scrollPageUp", + "chat.scrollPageDown", + "chat.scrollToEnd", "editor.openFavorite", "usage.cost", "usage.tokens",