Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -8134,6 +8172,8 @@ export default function ChatView(props: ChatViewProps) {
toggleThreadPanel,
toggleTerminalVisibility,
composerRef,
// T3-CUSTOM(expbkt3): chat.scrollToEnd keybinding.
scrollToEnd,
draftId,
environmentId,
envLocked,
Expand Down
17 changes: 17 additions & 0 deletions apps/web/src/components/settings/KeybindingsSettings.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/components/settings/KeybindingsSettings.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions docs/user/keybindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts/src/keybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading