Skip to content

Commit ac062ed

Browse files
jbmcguireclaude
andcommitted
feat(web): add thread.settle keyboard shortcut (mod+shift+s)
Adds a thread.settle keybinding command so the active thread can be settled from the keyboard. Defaults to mod+shift+s outside terminal focus, reuses useThreadActions' settleThread (so the existing can-settle guardrails and version-skew checks apply), and surfaces failures via the standard toast. Documented in docs/user/keybindings.md. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent a8e05cb commit ac062ed

6 files changed

Lines changed: 64 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
195195

196196
assert.equal(defaultsByCommand.get("thread.previous"), "mod+shift+[");
197197
assert.equal(defaultsByCommand.get("thread.next"), "mod+shift+]");
198+
assert.equal(defaultsByCommand.get("thread.settle"), "mod+shift+s");
198199
assert.equal(defaultsByCommand.get("thread.jump.1"), "mod+1");
199200
assert.equal(defaultsByCommand.get("thread.jump.9"), "mod+9");
200201
assert.equal(defaultsByCommand.get("modelPicker.toggle"), "mod+shift+m");

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ const DEFAULT_BINDINGS = compile([
128128
{ shortcut: modShortcut("o"), command: "editor.openFavorite" },
129129
{ shortcut: modShortcut("[", { shiftKey: true }), command: "thread.previous" },
130130
{ shortcut: modShortcut("]", { shiftKey: true }), command: "thread.next" },
131+
{
132+
shortcut: modShortcut("s", { shiftKey: true }),
133+
command: "thread.settle",
134+
whenAst: whenNot(whenIdentifier("terminalFocus")),
135+
},
131136
{ shortcut: modShortcut("1"), command: "thread.jump.1" },
132137
{ shortcut: modShortcut("2"), command: "thread.jump.2" },
133138
{ shortcut: modShortcut("3"), command: "thread.jump.3" },
@@ -497,6 +502,30 @@ describe("chat/editor shortcuts", () => {
497502
);
498503
});
499504

505+
it("matches thread.settle shortcut outside terminal focus", () => {
506+
assert.strictEqual(
507+
resolveShortcutCommand(event({ key: "s", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
508+
platform: "MacIntel",
509+
context: { terminalFocus: false },
510+
}),
511+
"thread.settle",
512+
);
513+
assert.notStrictEqual(
514+
resolveShortcutCommand(event({ key: "s", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
515+
platform: "MacIntel",
516+
context: { terminalFocus: true },
517+
}),
518+
"thread.settle",
519+
);
520+
assert.strictEqual(
521+
resolveShortcutCommand(event({ key: "s", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
522+
platform: "Linux",
523+
context: { terminalFocus: false },
524+
}),
525+
"thread.settle",
526+
);
527+
});
528+
500529
it("matches commandPalette.toggle shortcut outside terminal focus", () => {
501530
assert.strictEqual(
502531
resolveShortcutCommand(event({ key: "k", metaKey: true }), DEFAULT_BINDINGS, {

‎apps/web/src/routes/_chat.tsx‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
22
import { useAtomValue } from "@effect/atom-react";
3+
import {
4+
isAtomCommandInterrupted,
5+
squashAtomCommandFailure,
6+
} from "@t3tools/client-runtime/state/runtime";
37
import { useEffect, useMemo } from "react";
48

59
import { isCommandPaletteOpen } from "../commandPaletteBus";
@@ -11,6 +15,7 @@ import { selectProjectGroupingSettings } from "../logicalProject";
1115
import { buildSidebarProjectSnapshots } from "../sidebarProjectGrouping";
1216
import { dispatchPreviewAction } from "../components/preview/previewActionBus";
1317
import { useHandleNewThread } from "../hooks/useHandleNewThread";
18+
import { useThreadActions } from "../hooks/useThreadActions";
1419
import { startNewThreadFromContext } from "../lib/chatThreadActions";
1520
import { isPreviewFocused } from "../lib/previewFocus";
1621
import { isTerminalFocused } from "../lib/terminalFocus";
@@ -27,6 +32,7 @@ function ChatRouteGlobalShortcuts() {
2732
const selectedThreadKeysSize = useThreadSelectionStore((state) => state.selectedThreadKeys.size);
2833
const { activeDraftThread, activeThread, defaultProjectRef, handleNewThread, routeThreadRef } =
2934
useHandleNewThread();
35+
const { settleThread } = useThreadActions();
3036
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
3137
const sidebarV2Enabled = useSidebarV2Enabled();
3238
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
@@ -108,6 +114,28 @@ function ChatRouteGlobalShortcuts() {
108114
return;
109115
}
110116

117+
if (command === "thread.settle") {
118+
event.preventDefault();
119+
event.stopPropagation();
120+
if (!routeThreadRef) return;
121+
// Settle intentionally stays on the thread so the user can keep
122+
// reading; only failures surface, matching the sidebar's behavior.
123+
void (async () => {
124+
const result = await settleThread(routeThreadRef);
125+
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
126+
const error = squashAtomCommandFailure(result);
127+
toastManager.add(
128+
stackedThreadToast({
129+
type: "error",
130+
title: "Failed to settle thread",
131+
description: error instanceof Error ? error.message : "An error occurred.",
132+
}),
133+
);
134+
}
135+
})();
136+
return;
137+
}
138+
111139
if (command === "preview.toggle") {
112140
event.preventDefault();
113141
event.stopPropagation();
@@ -167,6 +195,7 @@ function ChatRouteGlobalShortcuts() {
167195
projectGroupCount,
168196
routeThreadRef,
169197
selectedThreadKeysSize,
198+
settleThread,
170199
sidebarV2Enabled,
171200
terminalOpen,
172201
]);

‎docs/user/keybindings.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ See the full schema for more details: [`packages/contracts/src/keybindings.ts`](
3333
{ "key": "mod+n", "command": "chat.new", "when": "!terminalFocus" },
3434
{ "key": "mod+shift+o", "command": "chat.new", "when": "!terminalFocus" },
3535
{ "key": "mod+shift+n", "command": "chat.newLocal", "when": "!terminalFocus" },
36-
{ "key": "mod+o", "command": "editor.openFavorite" }
36+
{ "key": "mod+o", "command": "editor.openFavorite" },
37+
{ "key": "mod+shift+s", "command": "thread.settle", "when": "!terminalFocus" }
3738
]
3839
```
3940

@@ -67,6 +68,7 @@ Invalid rules are ignored. Invalid config files are ignored. Warnings are logged
6768
- `chat.new`: create a new chat thread preserving the active thread's branch/worktree state
6869
- `chat.newLocal`: create a new chat thread for the active project in a new environment (local/worktree determined by app settings (default `local`))
6970
- `editor.openFavorite`: open current project/worktree in the last-used editor
71+
- `thread.settle`: settle the active thread (blocked while the thread still needs attention)
7072
- `script.{id}.run`: run a project script by id (for example `script.test.run`)
7173

7274
### Key Syntax

‎packages/contracts/src/keybindings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type ModelPickerJumpKeybindingCommand =
3737
export const THREAD_KEYBINDING_COMMANDS = [
3838
"thread.previous",
3939
"thread.next",
40+
"thread.settle",
4041
...THREAD_JUMP_KEYBINDING_COMMANDS,
4142
] as const;
4243
export type ThreadKeybindingCommand = (typeof THREAD_KEYBINDING_COMMANDS)[number];

‎packages/shared/src/keybindings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
4343
{ key: "mod+o", command: "editor.openFavorite" },
4444
{ key: "mod+shift+[", command: "thread.previous" },
4545
{ key: "mod+shift+]", command: "thread.next" },
46+
{ key: "mod+shift+s", command: "thread.settle", when: "!terminalFocus" },
4647
...THREAD_JUMP_KEYBINDING_COMMANDS.map((command, index) => ({
4748
key: `mod+${index + 1}`,
4849
command,

0 commit comments

Comments
 (0)