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): add bindable thread.regenerateTitle keybinding command · pingdotgg/t3code@4b04a2e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src
    • components
      • ChatView.tsx
      • CommandPalette.tsx
      • Sidebar.tsx
      • settings
        • KeybindingsSettings.logic.test.ts
    • hooks
      • useThreadActionMenu.test.ts
      • useThreadActionMenu.ts
      • useThreadActions.ts
    • keybindings.test.ts
  • docs/user
    • keybindings.md
    • thread-sidebar.md
  • packages
    • client-runtime/src/state
      • threadCommands.test.ts
      • threadCommands.ts
    • contracts/src
      • keybindings.test.ts
      • keybindings.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: apps/web/src/components/ChatView.tsx
+33-1Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,8 @@ export default function ChatView(props: ChatViewProps) {
15901590
const canReadTerminal = useEnvironmentScope(environmentId, AuthTerminalReadScope);
15911591
const draftId = routeKind === "draft" ? props.draftId : null;
15921592
const handleNewThread = useNewThreadHandler();
1593-
const { settleThread, pinThread, confirmAndUnpinThread } = useThreadActions();
1593+
const { settleThread, pinThread, confirmAndUnpinThread, regenerateThreadTitle } =
1594+
useThreadActions();
15941595
const routeThreadRef = useMemo(
15951596
() => scopeThreadRef(environmentId, threadId),
15961597
[environmentId, threadId],
@@ -7147,6 +7148,8 @@ export default function ChatView(props: ChatViewProps) {
71477148
const supportsSnooze = serverConfig?.environment.capabilities.threadSnooze === true;
71487149
const supportsPinning = serverConfig?.environment.capabilities.threadPinning === true;
71497150
const activeThreadPinned = supportsPinning && activeThreadShell?.pinnedAt != null;
7151+
const supportsTitleRegeneration =
7152+
serverConfig?.environment.capabilities.threadTitleRegeneration === true;
71507153
const activeThreadSnoozed =
71517154
activeThreadShell !== null &&
71527155
supportsSnooze &&
@@ -8111,6 +8114,33 @@ export default function ChatView(props: ChatViewProps) {
81118114
return;
81128115
}
81138116

8117+
if (command === "thread.regenerateTitle") {
8118+
// Unavailable: leave the key to anything else that wants it. Once available
8119+
// the key is always consumed; the command skips a regeneration already running.
8120+
if (
8121+
!isServerThread ||
8122+
!activeThreadRef ||
8123+
!supportsTitleRegeneration ||
8124+
!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)
8125+
)
8126+
return;
8127+
event.preventDefault();
8128+
event.stopPropagation();
8129+
if (event.repeat) return;
8130+
void regenerateThreadTitle(activeThreadRef).then((result) => {
8131+
if (result._tag !== "Failure" || isAtomCommandInterrupted(result)) return;
8132+
const error = squashAtomCommandFailure(result);
8133+
toastManager.add(
8134+
stackedThreadToast({
8135+
type: "error",
8136+
title: "Failed to regenerate thread title",
8137+
description: error instanceof Error ? error.message : "An error occurred.",
8138+
}),
8139+
);
8140+
});
8141+
return;
8142+
}
8143+
81148144
if (command === "terminal.toggle") {
81158145
if (!terminalUiState.terminalOpen && !canReadTerminal && !canOperateTerminal) return;
81168146
event.preventDefault();
@@ -8371,6 +8401,8 @@ export default function ChatView(props: ChatViewProps) {
83718401
settleThread,
83728402
supportsPinning,
83738403
supportsSettlement,
8404+
supportsTitleRegeneration,
8405+
regenerateThreadTitle,
83748406
confirmAndUnpinThread,
83758407
copyActiveThreadReference,
83768408
getShortcutContext,
Collapse file

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

Copy file name to clipboardExpand all lines: apps/web/src/components/CommandPalette.tsx
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
MonitorIcon,
7373
MoonIcon,
7474
PaletteIcon,
75+
RefreshCwIcon,
7576
RotateCcwIcon,
7677
SettingsIcon,
7778
SquarePenIcon,
@@ -127,6 +128,7 @@ import { sourceControlEnvironment } from "../state/sourceControl";
127128
import { useAtomCommand } from "../state/use-atom-command";
128129
import { useAtomQueryRunner } from "../state/use-atom-query-runner";
129130
import { useScratchProject } from "../hooks/useScratchProject";
131+
import { useThreadActions } from "../hooks/useThreadActions";
130132
import { useNewProject } from "../hooks/useNewProject";
131133
import { isScratchProject } from "@t3tools/client-runtime/state/projects";
132134
import { useEnvironments, usePrimaryEnvironmentId } from "../state/environments";
@@ -637,6 +639,7 @@ function OpenCommandPaletteDialog(props: {
637639
const stopThreadSession = useAtomCommand(threadEnvironment.stopSession, {
638640
reportFailure: false,
639641
});
642+
const { regenerateThreadTitle } = useThreadActions();
640643
const refreshProviders = useAtomCommand(serverEnvironment.refreshProviders, {
641644
reportFailure: false,
642645
});
@@ -665,6 +668,10 @@ function OpenCommandPaletteDialog(props: {
665668
const activeThreadServerConfig = useServerConfigs().get(
666669
activeThread?.environmentId ?? ("" as EnvironmentId),
667670
);
671+
const canOperateActiveThread = useEnvironmentScope(
672+
activeThread?.environmentId ?? null,
673+
AuthOrchestrationOperateScope,
674+
);
668675
const activeThreadReferenceCopyTarget =
669676
referenceThreadRef === null || (pathname === "/pull-requests" && !openPanelPullRequestUrl)
670677
? null
@@ -1964,6 +1971,31 @@ function OpenCommandPaletteDialog(props: {
19641971
}
19651972
}
19661973

1974+
if (
1975+
activeThread !== null &&
1976+
canOperateActiveThread &&
1977+
activeThreadServerConfig?.environment.capabilities.threadTitleRegeneration === true
1978+
) {
1979+
const threadRef = scopeThreadRef(activeThread.environmentId, activeThread.id);
1980+
const isRegeneratingTitle = activeThread.titleRegeneration != null;
1981+
actionItems.push({
1982+
kind: "action",
1983+
value: "action:regenerate-thread-title",
1984+
searchTerms: ["regenerate", "title", "rename", "thread name", "refresh"],
1985+
title: isRegeneratingTitle ? "Regenerating thread title…" : "Regenerate thread title",
1986+
icon: <RefreshCwIcon className={ITEM_ICON_CLASS} />,
1987+
disabled: isRegeneratingTitle,
1988+
shortcutCommand: "thread.regenerateTitle",
1989+
// Failures throw into executeItem's error toast.
1990+
run: async () => {
1991+
const result = await regenerateThreadTitle(threadRef);
1992+
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
1993+
throw squashAtomCommandFailure(result);
1994+
}
1995+
},
1996+
});
1997+
}
1998+
19671999
if (activeThread !== null) {
19682000
const thread = activeThread;
19692001
actionItems.push({
Collapse file

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

Copy file name to clipboardExpand all lines: apps/web/src/components/Sidebar.tsx
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,7 @@ export default function Sidebar() {
24482448
markThreadUnread,
24492449
archiveThread,
24502450
deleteThread,
2451+
regenerateThreadTitle,
24512452
} = useThreadActions();
24522453
const updateThreadMetadata = useOrchestrationCommand(threadEnvironment.updateMetadata, {
24532454
reportFailure: false,
@@ -4806,11 +4807,7 @@ export default function Sidebar() {
48064807
startThreadRename(threadRef, thread.title);
48074808
return;
48084809
case "regenerate-title": {
4809-
if (isRegeneratingTitle) return;
4810-
const result = await updateThreadMetadata({
4811-
environmentId: threadRef.environmentId,
4812-
input: { threadId: threadRef.threadId, regenerateTitle: true },
4813-
});
4810+
const result = await regenerateThreadTitle(threadRef);
48144811
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
48154812
const error = squashAtomCommandFailure(result);
48164813
toastManager.add(
@@ -4929,8 +4926,8 @@ export default function Sidebar() {
49294926
serverConfigs,
49304927
setProjectScopeKey,
49314928
setThreadAutoSettle,
4929+
regenerateThreadTitle,
49324930
startThreadRename,
4933-
updateThreadMetadata,
49344931
timestampFormat,
49354932
],
49364933
);
Collapse file

‎apps/web/src/components/settings/KeybindingsSettings.logic.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/settings/KeybindingsSettings.logic.test.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ describe("KeybindingsSettings.logic", () => {
285285
expect(commandLabel("themeEditor.toggle")).toBe("Theme Editor: Toggle");
286286
expect(commandLabel("view.reopenClosed")).toBe("Reopen Closed Tab");
287287
expect(commandLabel("preview.focusUrl")).toBe("Preview: Focus URL");
288+
expect(commandLabel("thread.regenerateTitle")).toBe("Thread: Regenerate Title");
288289
expect(commandLabel("script.setup-db.run")).toBe("Run Script: Setup Db");
289290
});
290291

@@ -327,11 +328,12 @@ describe("KeybindingsSettings.logic", () => {
327328
"rightPanel.toggleMaximized",
328329
"composer.cycleHost",
329330
"thread.stop",
331+
"thread.regenerateTitle",
330332
"usage.open",
331333
"script.setup-db.run",
332334
]),
333335
);
334-
for (const command of ["thread.stop", "composer.cycleHost"]) {
336+
for (const command of ["thread.stop", "composer.cycleHost", "thread.regenerateTitle"]) {
335337
expect(DEFAULT_RESOLVED_KEYBINDINGS.some((binding) => binding.command === command)).toBe(
336338
false,
337339
);
Collapse file

‎apps/web/src/hooks/useThreadActionMenu.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/hooks/useThreadActionMenu.test.ts
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ vi.mock("../state/entities", () => ({
6565
useProjects: () => [{ id: "project", environmentId: "secondary" }],
6666
}));
6767
vi.mock("../state/environments", () => ({ usePrimaryEnvironmentId: () => "primary" }));
68-
vi.mock("../state/threads", () => ({ threadEnvironment: { updateMetadata: "metadata" } }));
69-
vi.mock("../state/use-atom-command", () => ({
70-
useAtomCommand: () => async () => {
71-
recordEffect("metadata");
72-
return AsyncResult.success(undefined);
73-
},
74-
}));
7568
vi.mock("../localApi", () => ({
7669
readLocalApi: () => ({
7770
contextMenu: { show: state.show, close: () => {} },
@@ -134,6 +127,7 @@ vi.mock("./useThreadActions", () => ({
134127
"confirmAndUnpinThread",
135128
"archiveThread",
136129
"deleteThread",
130+
"regenerateThreadTitle",
137131
].map((action) => [
138132
action,
139133
async () => {
Collapse file

‎apps/web/src/hooks/useThreadActionMenu.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/hooks/useThreadActionMenu.ts
+3-11Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import {
2222
type ThreadActionMenuId,
2323
} from "../components/threadActionMenu.logic";
2424
import { stackedThreadToast, toastManager } from "../components/ui/toast";
25-
import { threadEnvironment } from "../state/threads";
26-
import { useOrchestrationCommand } from "../state/use-orchestration-command";
2725
import { readEnvironmentScope } from "../state/session";
2826
import {
2927
readEnvironmentSupportsAutoSettleOptOut,
@@ -99,10 +97,8 @@ export function useThreadActionMenu(input: {
9997
archiveThread,
10098
deleteThread,
10199
markThreadUnread,
100+
regenerateThreadTitle,
102101
} = useThreadActions();
103-
const updateThreadMetadata = useOrchestrationCommand(threadEnvironment.updateMetadata, {
104-
reportFailure: false,
105-
});
106102
const handleNewThread = useNewThreadHandler();
107103
const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
108104
const confirmThreadArchive = useClientSettings((s) => s.confirmThreadArchive);
@@ -254,12 +250,8 @@ export function useThreadActionMenu(input: {
254250
onStartRename();
255251
return;
256252
case "regenerate-title":
257-
if (isRegeneratingTitle) return;
258253
await reportFailure("Failed to regenerate thread title", () =>
259-
updateThreadMetadata({
260-
environmentId: threadRef.environmentId,
261-
input: { threadId: threadRef.threadId, regenerateTitle: true },
262-
}),
254+
regenerateThreadTitle(threadRef),
263255
);
264256
return;
265257
case "mark-unread":
@@ -365,7 +357,7 @@ export function useThreadActionMenu(input: {
365357
timestampFormat,
366358
unsettleThread,
367359
unsnoozeThread,
368-
updateThreadMetadata,
360+
regenerateThreadTitle,
369361
],
370362
);
371363

Collapse file

‎apps/web/src/hooks/useThreadActions.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/hooks/useThreadActions.ts
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ export function useThreadActions() {
305305
const unsnoozeThreadMutation = useOrchestrationCommand(threadEnvironment.unsnooze, {
306306
reportFailure: false,
307307
});
308+
const updateThreadMetadataMutation = useOrchestrationCommand(threadEnvironment.updateMetadata, {
309+
reportFailure: false,
310+
});
308311
const markThreadUnread = useMarkThreadUnread();
309312
const stopThreadSession = useOrchestrationCommand(threadEnvironment.stopSession);
310313
const removeWorktree = useAtomCommand(vcsEnvironment.removeWorktree, {
@@ -863,6 +866,16 @@ export function useThreadActions() {
863866
[confirmThreadUnpin, resolveThreadTarget, unpinThread],
864867
);
865868

869+
/** Skipped (successfully) while the thread's title is already regenerating. */
870+
const regenerateThreadTitle = useCallback(
871+
(target: ScopedThreadRef) =>
872+
updateThreadMetadataMutation({
873+
environmentId: target.environmentId,
874+
input: { threadId: target.threadId, regenerateTitle: true },
875+
}),
876+
[updateThreadMetadataMutation],
877+
);
878+
866879
const reorderPinnedThread = useCallback(
867880
async (target: ScopedThreadRef, orderKey: string) => {
868881
// Callers (the sidebar drag handler) only enable dragging on
@@ -1024,6 +1037,7 @@ export function useThreadActions() {
10241037
reorderActiveThread,
10251038
markThreadUnread,
10261039
setThreadAutoSettle,
1040+
regenerateThreadTitle,
10271041
}),
10281042
[
10291043
archiveThread,
@@ -1032,6 +1046,7 @@ export function useThreadActions() {
10321046
deleteThread,
10331047
markThreadUnread,
10341048
pinThread,
1049+
regenerateThreadTitle,
10351050
reorderPinnedThread,
10361051
reorderActiveThread,
10371052
setThreadAutoSettle,
Collapse file

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

Copy file name to clipboardExpand all lines: apps/web/src/keybindings.test.ts
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,31 @@ describe("resolveShortcutCommand", () => {
10641064
);
10651065
});
10661066

1067+
it("resolves a custom regenerate-title shortcut outside the terminal only", () => {
1068+
const keybindings = compile([
1069+
{
1070+
shortcut: modShortcut("t", { shiftKey: true }),
1071+
command: "thread.regenerateTitle",
1072+
whenAst: whenNot(whenIdentifier("terminalFocus")),
1073+
},
1074+
]);
1075+
const input = event({ key: "t", metaKey: true, shiftKey: true });
1076+
1077+
assert.strictEqual(
1078+
resolveShortcutCommand(input, keybindings, {
1079+
platform: "MacIntel",
1080+
context: { terminalFocus: false },
1081+
}),
1082+
"thread.regenerateTitle",
1083+
);
1084+
assert.isNull(
1085+
resolveShortcutCommand(input, keybindings, {
1086+
platform: "MacIntel",
1087+
context: { terminalFocus: true },
1088+
}),
1089+
);
1090+
});
1091+
10671092
it("returns dynamic script commands", () => {
10681093
const keybindings = compile([{ shortcut: modShortcut("r"), command: "script.setup.run" }]);
10691094

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
@@ -141,6 +141,10 @@ a shortcut.
141141
`thread.stop` interrupts the running turn in the focused thread. It has no default
142142
shortcut; assign one in **Settings → Keybindings**.
143143

144+
`thread.regenerateTitle` generates a fresh title for the focused thread. It has no
145+
default shortcut. It does nothing while a title is already being generated or when
146+
the thread's environment does not support title regeneration.
147+
144148
`thread.undo` (`mod+z` by default) reverses the actions shown in the notice at the
145149
bottom of the sidebar, such as unpin, settle, snooze, archive, or discarding a
146150
draft. Consecutive
Collapse file

‎docs/user/thread-sidebar.md‎

Copy file name to clipboardExpand all lines: docs/user/thread-sidebar.md
+4-2Lines changed: 4 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ environment. Pinned and active reordering require server support. Threads from o
104104
their default order until the server is updated.
105105

106106
To generate a fresh title from the conversation, open a thread's menu and choose
107-
**Regenerate title**. The action is unavailable while title generation is in progress
108-
or when the connected environment needs a server update.
107+
**Regenerate title**. The same action is in the command palette, and you can bind
108+
**Thread: Regenerate Title** in **Settings → Keybindings**. The action is unavailable
109+
while title generation is in progress or when the connected environment needs a server
110+
update.
109111

110112
Agents connected through T3 Code can use the same server-owned metadata workflow to
111113
rename a thread, regenerate its title, or link and unlink a pull request. These changes

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.