@devries-cameron20 / t3code-1 / commits / d7935f135f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(web): choose what the thread details card shows (#26904)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 29, 2026 at 03:28 UTC d7935f135f50f3798c1e247ebe8b88587dd62adf
21 files changed +514 -153
apps/desktop/src/settings/DesktopClientSettings.test.ts
+1
@@ -65,6 +65,7 @@ const clientSettings: ClientSettings = {
65 boringSidebarEnabled: false,
66 boringSidebarMultilineRows: false,
67 threadDetailsUsageEnabled: false,
68 + threadDetailsItems: {},
69 legacySidebarEnabled: false,
70 sidebarWorkingShelfEnabled: false,
71 loadBalancingEnabled: false,
apps/web/src/components/ChatView.tsx
+6 -13
@@ -1228,9 +1228,6 @@ export default function ChatView(props: ChatViewProps) {
1228 const canChangeEnvironment =
1229 hasMultipleEnvironments && !envLocked && draftId !== null && !draftThread?.promotedTo;
1230
1231 - const threadDetailsUsageEnabled = useClientSettings(
1232 - (settings) => settings.threadDetailsUsageEnabled,
1233 - );
1231 const loadBalancingSettings = useClientSettings((settings) => ({
1232 loadBalancingEnabled: settings.loadBalancingEnabled,
1233 loadBalancingWeights: settings.loadBalancingWeights,
@@ -3773,16 +3770,12 @@ export default function ChatView(props: ChatViewProps) {
3770 onAddProjectScript={saveProjectScriptStable}
3771 onUpdateProjectScript={updateProjectScriptStable}
3772 onDeleteProjectScript={deleteProjectScriptStable}
3776 - usage={
3777 - threadDetailsUsageEnabled
3778 - ? {
3779 - providerInstanceId: activeProviderInstanceId,
3780 - providers: providerStatuses,
3781 - sources: serverConfig?.usageLimitSources ?? EMPTY_USAGE_LIMIT_SOURCES,
3782 - contextWindow: activeContextWindow,
3783 - }
3784 - : undefined
3785 - }
3773 + usage={{
3774 + providerInstanceId: activeProviderInstanceId,
3775 + providers: providerStatuses,
3776 + sources: serverConfig?.usageLimitSources ?? EMPTY_USAGE_LIMIT_SOURCES,
3777 + contextWindow: activeContextWindow,
3778 + }}
3779 />
3780
3781 <PullRequestThreadDialogHost
apps/web/src/components/GitActionsControl.tsx
+16 -9
@@ -117,6 +117,8 @@ interface GitActionsControlProps {
117 activeThreadRef: ScopedThreadRef | null;
118 draftId?: DraftId;
119 compact?: boolean;
120 + showActions?: boolean;
121 + showChanges?: boolean;
122 onOpenChanges?: () => void;
123 }
124
@@ -926,6 +928,8 @@ export default function GitActionsControl({
928 activeThreadRef,
929 draftId,
930 compact = false,
931 + showActions = true,
932 + showChanges = true,
933 onOpenChanges,
934 }: GitActionsControlProps) {
935 const panelAnchorRef = useRef<HTMLDivElement | null>(null);
@@ -1476,7 +1480,7 @@ export default function GitActionsControl({
1480
1481 return (
1482 <>
1479 - {!isRepo ? (
1483 + {!showActions ? null : !isRepo ? (
1484 <ThreadDetailsControl
1485 size="xs"
1486 variant="ghost"
@@ -1618,7 +1622,7 @@ export default function GitActionsControl({
1622 </div>
1623 )}
1624
1621 - {isRepo && !quietEmptyDraft ? (
1625 + {showChanges && isRepo && !quietEmptyDraft ? (
1626 <ThreadDetailsControl
1627 type="button"
1628 variant="ghost"
@@ -1826,13 +1830,16 @@ export default function GitActionsControl({
1830 </DialogPopup>
1831 </Dialog>
1832
1829 - <PublishRepositoryDialog
1830 - open={isPublishDialogOpen}
1831 - onOpenChange={setIsPublishDialogOpen}
1832 - environmentId={activeEnvironmentId}
1833 - threadRef={activeThreadRef}
1834 - gitCwd={gitCwd}
1835 - />
1833 + {/* Its discovery query should stop when the Git actions row that opens it is hidden. */}
1834 + {showActions ? (
1835 + <PublishRepositoryDialog
1836 + open={isPublishDialogOpen}
1837 + onOpenChange={setIsPublishDialogOpen}
1838 + environmentId={activeEnvironmentId}
1839 + threadRef={activeThreadRef}
1840 + gitCwd={gitCwd}
1841 + />
1842 + ) : null}
1843
1844 <Dialog
1845 open={pendingDefaultBranchAction !== null}
apps/web/src/components/chat/OpenInPicker.browser.test.tsx
+13
@@ -189,6 +189,19 @@ describe("host editor access", () => {
189 });
190 });
191
192 +describe("remote editor links", () => {
193 + it("opens the link from the fallback when the picker is not mounted", async () => {
194 + await using fixture = await setup();
195 + const { screen, pressOpenFavorite, FavoriteEditorFallback } = fixture;
196 + state.remote = { mode: "remote-links", host: { kind: "ssh-alias", host: "sol" } };
197 + await act(async () => screen.rerender(<FavoriteEditorFallback />));
198 +
199 + expect((await pressOpenFavorite()).defaultPrevented).toBe(true);
200 + expect(state.openUrl).toHaveBeenCalledWith(expect.stringContaining("ssh-remote+sol"));
201 + expect(state.run).not.toHaveBeenCalled();
202 + });
203 +});
204 +
205 describe("open in editor announcement", () => {
206 it("speaks only after the shortcut opened the editor, from the picker or the fallback", async () => {
207 await using fixture = await setup();
apps/web/src/components/chat/OpenInPickerShortcut.ts
+33 -7
@@ -1,11 +1,16 @@
1 -import type { EditorId, EnvironmentId, ResolvedKeybindingsConfig } from "@t3tools/contracts";
1 +import {
2 + buildRemoteOpenUrl,
3 + type EditorId,
4 + type EnvironmentId,
5 + type ResolvedKeybindingsConfig,
6 +} from "@t3tools/contracts";
7 import { useEffect } from "react";
8
9 import { usePreferredEditor } from "../../editorPreferences";
10 import { editorLabelForPlatform } from "../../editorLabels";
11 import { isOpenFavoriteEditorShortcut } from "../../keybindings";
12 import { announce } from "../../lib/announce";
8 -import { useRemoteOpenState } from "../../remoteOpen";
13 +import { openRemoteEditorUrl, useRemoteCapableEditors, useRemoteOpenState } from "../../remoteOpen";
14 import { registerCommands } from "../../shortcuts/dispatcher";
15 import { shellEnvironment } from "../../state/shell";
16 import { useAtomCommand } from "../../state/use-atom-command";
@@ -49,18 +54,39 @@ export function useOpenFavoriteEditorShortcut({
54 openInCwd: string | null;
55 }) {
56 const openInEditorMutation = useAtomCommand(shellEnvironment.openInEditor, "open in editor");
52 - const [preferredEditor] = usePreferredEditor(availableEditors);
57 const remote = useRemoteOpenState(environmentId);
58 + const remoteCapableEditors = useRemoteCapableEditors();
59 + // Matches the picker: remote editors run on the viewing machine.
60 + const [preferredEditor] = usePreferredEditor(
61 + remote.mode === "local-exec" ? availableEditors : remoteCapableEditors,
62 + );
63
55 - // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes a window keydown listener for the open-in-editor shortcut while enabled locally
64 + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes a window keydown listener for the open-in-editor shortcut while enabled
65 useEffect(() => {
57 - if (!enabled || remote.mode !== "local-exec") return;
66 + if (!enabled || remote.mode === "remote-unavailable") return;
67 const handler = (event: globalThis.KeyboardEvent) => {
59 - if (event.defaultPrevented || !isOpenFavoriteEditorShortcut(event, keybindings)) return;
68 + if (
69 + event.repeat ||
70 + event.defaultPrevented ||
71 + !isOpenFavoriteEditorShortcut(event, keybindings)
72 + )
73 + return;
74 if (!openInCwd || !preferredEditor) return;
75
76 event.preventDefault();
77 const label = editorLabelForPlatform(preferredEditor, navigator.platform);
78 + if (remote.mode === "remote-links") {
79 + const url = buildRemoteOpenUrl({
80 + editor: preferredEditor,
81 + ...remote.host,
82 + absolutePath: openInCwd,
83 + });
84 + if (url === undefined) return;
85 + void openRemoteEditorUrl(url).then((opened) => {
86 + if (opened) announce(`Opened in ${label}`);
87 + });
88 + return;
89 + }
90 void openInEditorMutation({
91 environmentId,
92 input: {
@@ -80,6 +106,6 @@ export function useOpenFavoriteEditorShortcut({
106 openInCwd,
107 openInEditorMutation,
108 preferredEditor,
83 - remote.mode,
109 + remote,
110 ]);
111 }
apps/web/src/components/chat/ThreadAutomationsPanel.tsx
+6 -6
@@ -153,12 +153,6 @@ export function ThreadAutomationsPanel(props: {
153 </Tooltip>
154 }
155 >
156 - {tasksQuery.error !== null ? (
157 - <p className="px-2.5 py-1.5 text-2xs text-destructive">
158 - Could not load automations: {tasksQuery.error}
159 - </p>
160 - ) : null}
161 -
156 <ul className="m-0 list-none p-0">
157 {boundTasks.map((task) => (
158 <li
@@ -242,6 +236,12 @@ export function ThreadAutomationsPanel(props: {
236 </li>
237 ))}
238 </ul>
239 + {/* Kept last: the details card treats a section whose last child is empty as empty. */}
240 + {tasksQuery.error !== null ? (
241 + <p className="px-2.5 py-1.5 text-2xs text-destructive">
242 + Could not load automations: {tasksQuery.error}
243 + </p>
244 + ) : null}
245 </ThreadDetailsSection>
246 );
247 }
apps/web/src/components/chat/ThreadDetailsCard.browser.test.tsx
+24 -2
@@ -42,10 +42,13 @@ function Card({
42 threadRef,
43 inline,
44 fixture,
45 + rows = 1,
46 }: {
47 threadRef: ScopedThreadRef;
48 inline: boolean;
49 fixture: ReturnType<typeof setup>;
50 + /** Rows of 100px shown at full density. Compact always takes 50px. */
51 + rows?: number;
52 }) {
53 return (
54 // The web root renders in StrictMode, which re-runs ref callbacks on every mount.
@@ -63,8 +66,17 @@ function Card({
66 detailsCardPlacement: inline ? placement : null,
67 }}
68 >
66 - <ThreadDetailsCard threadRef={threadRef} anchor={fixture.anchor} handle={fixture.handle}>
67 - {() => <p>Details for {threadRef.threadId}</p>}
69 + <ThreadDetailsCard
70 + threadRef={threadRef}
71 + anchor={fixture.anchor}
72 + handle={fixture.handle}
73 + contentKey={String(rows)}
74 + >
75 + {(density) => (
76 + <p style={{ height: density === "full" ? rows * 100 : 50 }}>
77 + Details for {threadRef.threadId}
78 + </p>
79 + )}
80 </ThreadDetailsCard>
81 </ChatCanvasContext>
82 </StrictMode>
@@ -136,3 +148,13 @@ it("reopens after a normal close", async () => {
148 await setOpen(true);
149 await expect.element(page.getByText("Details for thread-b")).toBeVisible();
150 });
151 +
152 +it("returns to full density when hidden items make the content fit", async () => {
153 + using fixture = setup();
154 + await using screen = await render(<Card threadRef={threadB} inline fixture={fixture} rows={6} />);
155 + const card = page.getByRole("region", { name: "Thread details" });
156 + await expect.element(card).toHaveAttribute("data-density", "compact");
157 +
158 + await screen.rerender(<Card threadRef={threadB} inline fixture={fixture} rows={2} />);
159 + await expect.element(card).toHaveAttribute("data-density", "full");
160 +});
apps/web/src/components/chat/ThreadDetailsCard.tsx
+14 -2
@@ -1,5 +1,11 @@
1 import { workspaceAreaProps } from "../../lib/workspaceFocus";
2 -import { useLayoutEffect, useState, type ReactNode, type RefObject } from "react";
2 +import {
3 + useLayoutEffect,
4 + useState,
5 + type MouseEventHandler,
6 + type ReactNode,
7 + type RefObject,
8 +} from "react";
9 import type { ScopedThreadRef } from "@t3tools/contracts";
10 import { ScrollArea } from "../ui/scroll-area";
11 import { cn } from "../../lib/utils";
@@ -17,11 +23,16 @@ export function ThreadDetailsCard({
23 threadRef,
24 anchor,
25 handle,
26 + contentKey,
27 + onContextMenu,
28 children,
29 }: {
30 threadRef: ScopedThreadRef;
31 anchor: RefObject<Element | null>;
32 handle: ReturnType<typeof PopoverCreateHandle>;
33 + /** Changes when the set of rendered items changes, so cached heights are measured again. */
34 + contentKey: string;
35 + onContextMenu?: MouseEventHandler<HTMLDivElement>;
36 children: (density: "full" | "compact" | "essential") => ReactNode;
37 }) {
38 const detailsArea = workspaceAreaProps("details", 3, "Thread details");
@@ -36,7 +47,7 @@ export function ThreadDetailsCard({
47 const popoverOpen = useRightPanelStore((state) =>
48 selectThreadPanelOpen(state.threadPanelVisibilityByThreadKey, threadRef, "popover"),
49 );
39 - const measurementKey = `${threadRef.environmentId}:${threadRef.threadId}:${preferredPlacement?.width ?? "popup"}`;
50 + const measurementKey = `${threadRef.environmentId}:${threadRef.threadId}:${preferredPlacement?.width ?? "popup"}:${contentKey}`;
51 const [measurements, setMeasurements] = useState({
52 key: measurementKey,
53 heights: { full: 0, compact: 0 },
@@ -109,6 +120,7 @@ export function ThreadDetailsCard({
120 "max-h-[min(calc(100dvh-6.5rem),calc(var(--available-height,100dvh)-1rem))]",
121 )}
122 style={placement ? { maxHeight: height } : undefined}
123 + onContextMenu={onContextMenu}
124 data-thread-details-card
125 >
126 <ScrollArea scrollFade className="min-h-0">
apps/web/src/components/chat/ThreadDetailsItemsMenu.tsx new
+45
@@ -0,0 +1,45 @@
1 +import {
2 + getClientSettings,
3 + updateClientSettings,
4 + useClientSettings,
5 +} from "../../hooks/useSettings";
6 +import { MenuCheckboxItem, MenuGroup, MenuGroupLabel, MenuItem, MenuSeparator } from "../ui/menu";
7 +import {
8 + isDefaultThreadDetailsVisibility,
9 + resolveThreadDetailsVisibility,
10 + RESET_THREAD_DETAILS_ITEMS,
11 + setThreadDetailsItem,
12 + THREAD_DETAILS_ITEMS,
13 +} from "./threadDetailsItems";
14 +
15 +/** Menu body that shows and hides thread details items. The card's context menu and Settings share it. */
16 +export function ThreadDetailsItemsMenuItems() {
17 + const visibility = useClientSettings(resolveThreadDetailsVisibility);
18 + return (
19 + <>
20 + <MenuGroup>
21 + <MenuGroupLabel>Show in thread details</MenuGroupLabel>
22 + {THREAD_DETAILS_ITEMS.map((item) => (
23 + <MenuCheckboxItem
24 + key={item.id}
25 + checked={visibility[item.id]}
26 + onCheckedChange={(checked) =>
27 + updateClientSettings({
28 + threadDetailsItems: setThreadDetailsItem(getClientSettings(), item, checked),
29 + })
30 + }
31 + >
32 + {item.label}
33 + </MenuCheckboxItem>
34 + ))}
35 + </MenuGroup>
36 + <MenuSeparator />
37 + <MenuItem
38 + disabled={isDefaultThreadDetailsVisibility(visibility)}
39 + onClick={() => updateClientSettings(RESET_THREAD_DETAILS_ITEMS)}
40 + >
41 + Reset to default
42 + </MenuItem>
43 + </>
44 + );
45 +}
apps/web/src/components/chat/ThreadDetailsPanel.tsx
+178 -84
@@ -16,7 +16,7 @@ import ProjectScriptsControl, {
16 type NewProjectScriptInput,
17 type ProjectScriptActionResult,
18 } from "../ProjectScriptsControl";
19 -import { memo, type ComponentProps } from "react";
19 +import { memo, useState, type ComponentProps } from "react";
20 import { ThreadDetailsCard } from "./ThreadDetailsCard";
21 import { OpenInPicker } from "./OpenInPicker";
22 import { ThreadDetailsSection } from "./ThreadDetailsSection";
@@ -24,6 +24,17 @@ import { ThreadAutomationsPanel } from "./ThreadAutomationsPanel";
24 import { ThreadRelationshipsPanel } from "./ThreadRelationshipsControl";
25 import { ThreadServersPanel } from "./ThreadServersPanel";
26 import { ThreadDetailsUsage, type ThreadDetailsUsageInput } from "./ThreadDetailsUsage";
27 +import { ThreadDetailsItemsMenuItems } from "./ThreadDetailsItemsMenu";
28 +import { resolveThreadDetailsVisibility, THREAD_DETAILS_ITEMS } from "./threadDetailsItems";
29 +import { useClientSettings } from "../../hooks/useSettings";
30 +import { cn } from "../../lib/utils";
31 +import { SlidersHorizontalIcon } from "lucide-react";
32 +import { ThreadDetailsControl } from "./ThreadDetailsControl";
33 +import {
34 + THREAD_DETAILS_PANEL_ICON_CLASS,
35 + THREAD_DETAILS_PANEL_LABEL_CLASS,
36 +} from "./threadDetailsPanelStyles";
37 +import { Menu, MenuPopup } from "../ui/menu";
38
39 const GitActionsControl = memo(BaseGitActionsControl);
40
@@ -68,14 +79,15 @@ interface ThreadDetailsPanelProps extends Pick<
79 input: NewProjectScriptInput,
80 ) => Promise<ProjectScriptActionResult>;
81 onDeleteProjectScript: (scriptId: string) => Promise<ProjectScriptActionResult>;
71 - /** Set only while the Labs usage readout is on. */
72 - usage?: ThreadDetailsUsageInput | undefined;
82 + usage: ThreadDetailsUsageInput;
83 }
84
85 export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
86 + const visible = useClientSettings(resolveThreadDetailsVisibility);
87 + const [menuPosition, setMenuPosition] = useState<{ x: number; y: number } | null>(null);
88 const fileScripts = useT3ProjectFileScripts(
89 props.environmentId,
78 - props.activeProjectScripts ? props.gitCwd : null,
90 + props.activeProjectScripts && visible.scripts ? props.gitCwd : null,
91 );
92 const activeThreadRef = { environmentId: props.environmentId, threadId: props.threadId };
93 const branchToolbarProps = {
@@ -109,99 +121,181 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
121 threadRef={{ environmentId: props.environmentId, threadId: props.threadId }}
122 anchor={props.anchor}
123 handle={props.handle}
124 + contentKey={THREAD_DETAILS_ITEMS.filter((item) => visible[item.id])
125 + .map((item) => item.id)
126 + .join(",")}
127 + onContextMenu={(event) => {
128 + // Popups the card opens bubble here through React; they, fields, links, and selected text
129 + // keep their own menus.
130 + const target = event.target;
131 + const selection = window.getSelection();
132 + if (
133 + !(target instanceof Element) ||
134 + !event.currentTarget.contains(target) ||
135 + target.closest("input, textarea, [contenteditable], a[href]") ||
136 + (selection &&
137 + !selection.isCollapsed &&
138 + (event.currentTarget.contains(selection.anchorNode) ||
139 + event.currentTarget.contains(selection.focusNode)))
140 + )
141 + return;
142 + event.preventDefault();
143 + setMenuPosition({ x: event.clientX, y: event.clientY });
144 + }}
145 >
113 - {(density) => (
114 - <>
115 - <ThreadDetailsSection
116 - headingId="thread-details-workspace-heading"
117 - title="Workspace"
118 - separated={false}
119 - showHeading={false}
120 - >
121 - <div className="flex flex-col">
122 - {density === "full" ? (
123 - <BranchToolbar
124 - layout="panel"
125 - panelSection="workspace"
126 - availableEnvironments={props.availableEnvironments}
127 - {...(props.onEnvironmentChange
128 - ? { onEnvironmentChange: props.onEnvironmentChange }
129 - : {})}
130 - autoEnvironmentLabel={props.autoEnvironmentLabel}
131 - onAutoEnvironment={props.onAutoEnvironment}
132 - {...branchToolbarProps}
133 - />
146 + {(density) => {
147 + // Section flags follow the rows that will render, so no empty section steals the divider rule.
148 + const show = {
149 + environment: density === "full" && visible.environment,
150 + openIn: density !== "essential" && visible.openIn && props.showOpenInPicker,
151 + scripts: visible.scripts && props.activeProjectScripts !== undefined,
152 + branch: props.gitCwd !== null && props.isGitRepo && visible.branch,
153 + git:
154 + props.gitCwd !== null &&
155 + props.activeProjectName !== undefined &&
156 + (visible.gitActions || (visible.changes && props.isGitRepo)),
157 + };
158 + return (
159 + <>
160 + <div className="group/details-items">
161 + {show.environment || show.openIn || show.scripts ? (
162 + <ThreadDetailsSection
163 + headingId="thread-details-workspace-heading"
164 + title="Workspace"
165 + separated={false}
166 + showHeading={false}
167 + >
168 + <div className="flex flex-col">
169 + {show.environment ? (
170 + <BranchToolbar
171 + layout="panel"
172 + panelSection="workspace"
173 + availableEnvironments={props.availableEnvironments}
174 + {...(props.onEnvironmentChange
175 + ? { onEnvironmentChange: props.onEnvironmentChange }
176 + : {})}
177 + autoEnvironmentLabel={props.autoEnvironmentLabel}
178 + onAutoEnvironment={props.onAutoEnvironment}
179 + {...branchToolbarProps}
180 + />
181 + ) : null}
182 +
183 + {show.openIn ? (
184 + <OpenInPicker
185 + keybindings={props.keybindings}
186 + environmentId={props.environmentId}
187 + availableEditors={props.availableEditors}
188 + openInCwd={props.gitCwd}
189 + enableShortcut={props.openInShortcutEnabled}
190 + displayMode="panel"
191 + />
192 + ) : null}
193 +
194 + {show.scripts && props.activeProjectScripts ? (
195 + <ProjectScriptsControl
196 + environmentId={props.environmentId}
197 + displayMode="panel"
198 + scripts={props.activeProjectScripts}
199 + fileScripts={fileScripts}
200 + preferredScriptId={props.preferredScriptId}
201 + onRunScript={props.onRunProjectScript}
202 + onAddScript={props.onAddProjectScript}
203 + onUpdateScript={props.onUpdateProjectScript}
204 + onDeleteScript={props.onDeleteProjectScript}
205 + />
206 + ) : null}
207 + </div>
208 + </ThreadDetailsSection>
209 + ) : null}
210 +
211 + {props.gitCwd && (show.branch || show.git) ? (
212 + <ThreadDetailsSection
213 + headingId="thread-details-version-control-heading"
214 + title="Version Control"
215 + showHeading={false}
216 + separated={density === "full"}
217 + >
218 + <div className="flex flex-col">
219 + {show.branch ? (
220 + <BranchToolbar layout="panel" panelSection="branch" {...branchToolbarProps} />
221 + ) : null}
222 + {show.git ? (
223 + <GitActionsControl
224 + compact={density !== "full"}
225 + showActions={visible.gitActions}
226 + showChanges={visible.changes}
227 + gitCwd={props.gitCwd}
228 + activeThreadRef={activeThreadRef}
229 + {...(props.draftId ? { draftId: props.draftId } : {})}
230 + {...(props.onOpenChanges ? { onOpenChanges: props.onOpenChanges } : {})}
231 + />
232 + ) : null}
233 + </div>
234 + </ThreadDetailsSection>
235 + ) : null}
236 +
237 + {density === "full" && !props.draftId && visible.servers ? (
238 + <ThreadServersPanel environmentId={props.environmentId} threadId={props.threadId} />
239 ) : null}
240
136 - {density !== "essential" && props.showOpenInPicker ? (
137 - <OpenInPicker
138 - keybindings={props.keybindings}
241 + {density === "full" && !props.draftId && visible.automations ? (
242 + <ThreadAutomationsPanel
243 environmentId={props.environmentId}
140 - availableEditors={props.availableEditors}
141 - openInCwd={props.gitCwd}
142 - enableShortcut={props.openInShortcutEnabled}
143 - displayMode="panel"
244 + threadId={props.threadId}
245 />
246 ) : null}
247
147 - {props.activeProjectScripts ? (
148 - <ProjectScriptsControl
248 + {density === "full" && !props.draftId && visible.lineage ? (
249 + <ThreadRelationshipsPanel
250 environmentId={props.environmentId}
150 - displayMode="panel"
151 - scripts={props.activeProjectScripts}
152 - fileScripts={fileScripts}
153 - preferredScriptId={props.preferredScriptId}
154 - onRunScript={props.onRunProjectScript}
155 - onAddScript={props.onAddProjectScript}
156 - onUpdateScript={props.onUpdateProjectScript}
157 - onDeleteScript={props.onDeleteProjectScript}
251 + threadId={props.threadId}
252 />
253 ) : null}
160 - </div>
161 - </ThreadDetailsSection>
254
163 - {props.gitCwd ? (
164 - <ThreadDetailsSection
165 - headingId="thread-details-version-control-heading"
166 - title="Version Control"
167 - showHeading={false}
168 - separated={density === "full"}
169 - >
170 - <div className="flex flex-col">
171 - {props.isGitRepo ? (
172 - <BranchToolbar layout="panel" panelSection="branch" {...branchToolbarProps} />
173 - ) : null}
174 - {props.activeProjectName ? (
175 - <GitActionsControl
176 - compact={density !== "full"}
177 - gitCwd={props.gitCwd}
178 - activeThreadRef={activeThreadRef}
179 - {...(props.draftId ? { draftId: props.draftId } : {})}
180 - {...(props.onOpenChanges ? { onOpenChanges: props.onOpenChanges } : {})}
181 - />
182 - ) : null}
183 - </div>
184 - </ThreadDetailsSection>
185 - ) : null}
186 -
187 - {density === "full" && !props.draftId ? (
188 - <ThreadServersPanel environmentId={props.environmentId} threadId={props.threadId} />
189 - ) : null}
190 -
191 - {density === "full" && !props.draftId ? (
192 - <ThreadAutomationsPanel environmentId={props.environmentId} threadId={props.threadId} />
193 - ) : null}
255 + {visible.usage ? <ThreadDetailsUsage {...props.usage} /> : null}
256
195 - {density === "full" && !props.draftId ? (
196 - <ThreadRelationshipsPanel
197 - environmentId={props.environmentId}
198 - threadId={props.threadId}
199 - />
200 - ) : null}
257 + {/* Shown only when no section above has content, so an emptied card can be refilled. */}
258 + <div className="p-2 group-has-[>section>:last-child:not(:empty)]/details-items:hidden">
259 + <ThreadDetailsControl
260 + size="xs"
261 + variant="ghost"
262 + part="row"
263 + panel
264 + onClick={(event) => {
265 + const rect = event.currentTarget.getBoundingClientRect();
266 + setMenuPosition({ x: rect.left, y: rect.bottom });
267 + }}
268 + >
269 + <SlidersHorizontalIcon className={THREAD_DETAILS_PANEL_ICON_CLASS} aria-hidden />
270 + <span className={cn("ml-0.5", THREAD_DETAILS_PANEL_LABEL_CLASS)}>
271 + Choose what to show
272 + </span>
273 + </ThreadDetailsControl>
274 + </div>
275 + </div>
276
202 - {props.usage ? <ThreadDetailsUsage {...props.usage} /> : null}
203 - </>
204 - )}
277 + <Menu
278 + open={menuPosition !== null}
279 + onOpenChange={(open) => !open && setMenuPosition(null)}
280 + >
281 + <MenuPopup
282 + anchor={
283 + menuPosition
284 + ? {
285 + getBoundingClientRect: () =>
286 + new DOMRect(menuPosition.x, menuPosition.y, 0, 0),
287 + }
288 + : undefined
289 + }
290 + align="start"
291 + side="bottom"
292 + >
293 + <ThreadDetailsItemsMenuItems />
294 + </MenuPopup>
295 + </Menu>
296 + </>
297 + );
298 + }}
299 </ThreadDetailsCard>
300 );
301 }
apps/web/src/components/chat/ThreadDetailsSection.tsx
+6 -1
@@ -22,7 +22,12 @@ export function ThreadDetailsSection({
22 {...props}
23 aria-labelledby={showHeading ? headingId : undefined}
24 aria-label={showHeading ? undefined : title}
25 - className={cn("px-2 pt-2 pb-2.5", separated && "border-t border-border/65")}
25 + // A row can still render nothing (a fresh draft quiets Git actions), so an empty section
26 + // collapses, and a divider only follows a section that has content.
27 + className={cn(
28 + "px-2 pt-2 pb-2.5 has-[>div:last-child:empty]:hidden",
29 + separated && "border-border/65 [section:not(:has(>div:last-child:empty))~&]:border-t",
30 + )}
31 >
32 <div
33 className={cn(
apps/web/src/components/chat/ThreadDetailsUsage.tsx
+1 -1
@@ -36,7 +36,7 @@ export interface ThreadDetailsUsageInput {
36 }
37
38 /**
39 - * Labs readout of the selected provider's limit windows and the thread's context window.
39 + * The selected provider's limit windows and the thread's context window.
40 * Every row reads as room left, so a longer bar always means more headroom.
41 */
42 export function ThreadDetailsUsage({
apps/web/src/components/chat/threadDetailsItems.test.ts new
+35
@@ -0,0 +1,35 @@
1 +import { describe, expect, it } from "vite-plus/test";
2 +
3 +import {
4 + resolveThreadDetailsVisibility,
5 + setThreadDetailsItem,
6 + THREAD_DETAILS_ITEMS,
7 +} from "./threadDetailsItems";
8 +
9 +const usage = THREAD_DETAILS_ITEMS.find((item) => item.id === "usage")!;
10 +const servers = THREAD_DETAILS_ITEMS.find((item) => item.id === "servers")!;
11 +
12 +describe("thread details items", () => {
13 + it.each([
14 + { legacy: false, items: {}, usage: false },
15 + { legacy: true, items: {}, usage: true },
16 + { legacy: true, items: { usage: false }, usage: false },
17 + { legacy: false, items: { usage: true, retired: false }, usage: true },
18 + ])("resolves Usage from overrides and the retired Labs flag: %o", (row) => {
19 + const visibility = resolveThreadDetailsVisibility({
20 + threadDetailsItems: row.items,
21 + threadDetailsUsageEnabled: row.legacy,
22 + });
23 + expect(visibility.usage).toBe(row.usage);
24 + expect(visibility.servers).toBe(true);
25 + });
26 +
27 + it("stores only choices that differ from the default", () => {
28 + const legacyOn = { threadDetailsItems: {}, threadDetailsUsageEnabled: true };
29 + expect(setThreadDetailsItem(legacyOn, usage, false)).toEqual({ usage: false });
30 + expect(setThreadDetailsItem(legacyOn, usage, true)).toEqual({});
31 +
32 + const hidden = { threadDetailsItems: { servers: false }, threadDetailsUsageEnabled: false };
33 + expect(setThreadDetailsItem(hidden, servers, true)).toEqual({});
34 + });
35 +});
apps/web/src/components/chat/threadDetailsItems.ts new
+60
@@ -0,0 +1,60 @@
1 +import type { ClientSettings } from "@t3tools/contracts";
2 +
3 +// Ids are stored in client settings, so never rename one.
4 +export const THREAD_DETAILS_ITEMS = [
5 + { id: "environment", label: "Environment and worktree", defaultVisible: true },
6 + { id: "openIn", label: "Open in editor", defaultVisible: true },
7 + { id: "scripts", label: "Project scripts", defaultVisible: true },
8 + { id: "branch", label: "Branch and pull request", defaultVisible: true },
9 + { id: "gitActions", label: "Git actions", defaultVisible: true },
10 + { id: "changes", label: "Changes", defaultVisible: true },
11 + { id: "servers", label: "Servers", defaultVisible: true },
12 + { id: "automations", label: "Automations", defaultVisible: true },
13 + { id: "lineage", label: "Lineage", defaultVisible: true },
14 + { id: "usage", label: "Usage", defaultVisible: false },
15 +] as const;
16 +
17 +export type ThreadDetailsItemId = (typeof THREAD_DETAILS_ITEMS)[number]["id"];
18 +export type ThreadDetailsVisibility = Readonly<Record<ThreadDetailsItemId, boolean>>;
19 +
20 +type ThreadDetailsItem = (typeof THREAD_DETAILS_ITEMS)[number];
21 +type ThreadDetailsItemSettings = Pick<
22 + ClientSettings,
23 + "threadDetailsItems" | "threadDetailsUsageEnabled"
24 +>;
25 +
26 +// People who turned on the retired Labs toggle keep Usage until they change it here.
27 +function defaultVisible(item: ThreadDetailsItem, settings: ThreadDetailsItemSettings) {
28 + return item.id === "usage" ? settings.threadDetailsUsageEnabled : item.defaultVisible;
29 +}
30 +
31 +export function resolveThreadDetailsVisibility(
32 + settings: ThreadDetailsItemSettings,
33 +): ThreadDetailsVisibility {
34 + return Object.fromEntries(
35 + THREAD_DETAILS_ITEMS.map((item) => [
36 + item.id,
37 + settings.threadDetailsItems[item.id] ?? defaultVisible(item, settings),
38 + ]),
39 + ) as Record<ThreadDetailsItemId, boolean>;
40 +}
41 +
42 +/** Stores only choices that differ from the default, so a later default change reaches everyone else. */
43 +export function setThreadDetailsItem(
44 + settings: ThreadDetailsItemSettings,
45 + item: ThreadDetailsItem,
46 + visible: boolean,
47 +): ClientSettings["threadDetailsItems"] {
48 + const { [item.id]: _previous, ...rest } = settings.threadDetailsItems;
49 + return visible === defaultVisible(item, settings) ? rest : { ...rest, [item.id]: visible };
50 +}
51 +
52 +export function isDefaultThreadDetailsVisibility(visibility: ThreadDetailsVisibility) {
53 + return THREAD_DETAILS_ITEMS.every((item) => visibility[item.id] === item.defaultVisible);
54 +}
55 +
56 +/** Also clears the retired Labs flag, so Usage returns to off. */
57 +export const RESET_THREAD_DETAILS_ITEMS = {
58 + threadDetailsItems: {},
59 + threadDetailsUsageEnabled: false,
60 +} satisfies Partial<ClientSettings>;
apps/web/src/components/settings/AppearanceSettingsPanel.tsx
+2
@@ -34,6 +34,7 @@ import { searchableSetting } from "./settingsSearch";
34 import { AdvancedSettings } from "./AdvancedSettings";
35 import { PanelAnimationsPreview } from "./PanelAnimationsPreview";
36 import { TypographySection } from "./TypographySettings";
37 +import { ThreadDetailsItemsRow } from "./ThreadDetailsItemsRow";
38
39 const ENVIRONMENT_IDENTIFICATION_LABELS: Record<EnvironmentIdentificationMode, string> = {
40 artwork: "Artwork",
@@ -273,6 +274,7 @@ export function AppearanceSettingsPanel() {
274 </div>
275 }
276 />
277 + <ThreadDetailsItemsRow />
278 <SettingsRow
279 {...searchableSetting("effort-display")}
280 description="Show reasoning effort in the composer as its name, such as High, or as bars."
apps/web/src/components/settings/LabsSettingsPanel.tsx
-21
@@ -18,7 +18,6 @@ export function LabsSettingsPanel() {
18 <SettingsSection id="beta" title="Beta">
19 <BoringSidebarRow />
20 <BoringSidebarMultilineRow />
21 - <ThreadDetailsUsageRow />
21 {/* Clerk is only mounted when this build has T3 Connect. */}
22 {hasCloudPublicConfig() ? <GuestLinksRowWithSignIn /> : <GuestLinksRow />}
23 <LinkedEnvironmentsRow />
@@ -70,26 +69,6 @@ function BoringSidebarMultilineRow() {
69 );
70 }
71
73 -function ThreadDetailsUsageRow() {
74 - const settings = useScopedSettings();
75 - const updateSettings = useUpdateScopedSettings();
76 - return (
77 - <SettingsRow
78 - {...searchableSetting("thread-details-usage")}
79 - description="Show the current provider's usage limits and the thread's context window at the bottom of the thread details card."
80 - control={
81 - <Switch
82 - checked={settings.threadDetailsUsageEnabled}
83 - onCheckedChange={(checked) =>
84 - updateSettings({ threadDetailsUsageEnabled: Boolean(checked) })
85 - }
86 - aria-label="Usage in thread details"
87 - />
88 - }
89 - />
90 - );
91 -}
92 -
72 /** Signed out of T3 Connect, the row offers to sign in instead of its switch. */
73 function GuestLinksRowWithSignIn() {
74 const { isSignedIn } = useAuth();
apps/web/src/components/settings/ThreadDetailsItemsRow.tsx new
+53
@@ -0,0 +1,53 @@
1 +import { ChevronDownIcon } from "lucide-react";
2 +
3 +import { updateClientSettings, useClientSettings } from "../../hooks/useSettings";
4 +import { ThreadDetailsItemsMenuItems } from "../chat/ThreadDetailsItemsMenu";
5 +import {
6 + isDefaultThreadDetailsVisibility,
7 + resolveThreadDetailsVisibility,
8 + RESET_THREAD_DETAILS_ITEMS,
9 + THREAD_DETAILS_ITEMS,
10 +} from "../chat/threadDetailsItems";
11 +import { Button } from "../ui/button";
12 +import { Menu, MenuPopup, MenuTrigger } from "../ui/menu";
13 +import { SettingResetButton, SettingsRow } from "./settingsLayout";
14 +import { searchableSetting } from "./settingsSearch";
15 +
16 +export function ThreadDetailsItemsRow() {
17 + const visibility = useClientSettings(resolveThreadDetailsVisibility);
18 + const enabled = THREAD_DETAILS_ITEMS.filter((item) => visibility[item.id]).length;
19 + return (
20 + <SettingsRow
21 + {...searchableSetting("thread-details-items")}
22 + description="Choose what the thread details card shows. You can also right-click the card."
23 + resetAction={
24 + isDefaultThreadDetailsVisibility(visibility) ? null : (
25 + <SettingResetButton
26 + label="thread details"
27 + onClick={() => updateClientSettings(RESET_THREAD_DETAILS_ITEMS)}
28 + />
29 + )
30 + }
31 + control={
32 + <Menu>
33 + <MenuTrigger
34 + render={
35 + <Button
36 + variant="outline"
37 + size="sm"
38 + className="w-full justify-between sm:w-40"
39 + aria-label={`Thread details: ${enabled} of ${THREAD_DETAILS_ITEMS.length} on`}
40 + />
41 + }
42 + >
43 + {enabled} of {THREAD_DETAILS_ITEMS.length} on
44 + <ChevronDownIcon aria-hidden />
45 + </MenuTrigger>
46 + <MenuPopup align="end">
47 + <ThreadDetailsItemsMenuItems />
48 + </MenuPopup>
49 + </Menu>
50 + }
51 + />
52 + );
53 +}
apps/web/src/components/settings/settingsSearch.ts
+8 -6
@@ -315,6 +315,14 @@ export const SETTINGS_SEARCH_ITEMS = [
315 to: "/settings/appearance",
316 searchTerms: ["wide full width column layout messages composer monitor"],
317 },
318 + {
319 + id: "thread-details-items",
320 + title: "Thread details",
321 + to: "/settings/appearance",
322 + searchTerms: [
323 + "customize show hide panel card environment editor scripts branch pull request git changes servers automations lineage usage limits 5 hour weekly quota tokens context window",
324 + ],
325 + },
326 {
327 id: "effort-display",
328 title: "Effort display",
@@ -437,12 +445,6 @@ export const SETTINGS_SEARCH_ITEMS = [
445 to: "/settings/labs",
446 searchTerms: ["beta boring sidebar folder rows multiline branch pull request details"],
447 },
440 - {
441 - id: "thread-details-usage",
442 - title: "Usage in thread details",
443 - to: "/settings/labs",
444 - searchTerms: ["beta limits 5 hour weekly context window tokens quota rate limit"],
445 - },
448 {
449 id: "guest-links",
450 title: "Guest links",
docs/user/thread-sidebar.md
+5
@@ -277,6 +277,11 @@ Select a server to open it in the browser panel. **Stop** ends the server's job
277 and keeps the agent, the terminal, and T3 Code running. Stop needs terminal
278 access to the environment and is not available on Windows.
279
280 +To choose what the thread details card shows, right-click the card or open
281 +**Settings → Appearance → Thread details**. Hidden rows keep their keyboard
282 +shortcuts, such as Open in editor and project scripts. **Reset to default** brings
283 +back the standard rows.
284 +
285 ## Snooze until later
286
287 To change the choices in the snooze menu, open **Settings → Threads → Snooze options**.
docs/user/usage.md
+1 -1
@@ -116,7 +116,7 @@ current model's limits without leaving the conversation. The result opens above
116 closes when you dismiss it or send your next message. It uses the same snapshot as **Usage → Limits**, so it does not run the agent or refresh
117 anything. The command is offered only for providers that appear under **Usage → Limits**.
118
119 -To keep them in view, turn on **Settings → Labs → Usage in thread details** on web and desktop.
119 +To keep them in view on web and desktop, turn on **Usage** in **Settings → Appearance → Thread details**, or right-click the thread details card.
120 The bottom of the thread details card then shows how much is left in each limit window of the
121 current provider account and in the thread's context window. Some windows, such as a weekly Opus
122 limit, count only one model. Hover a row to see when it resets, your pace, or
packages/contracts/src/settings.ts
+7
@@ -477,7 +477,13 @@ export const ClientSettingsSchema = Schema.Struct({
477 boringSidebarMultilineRows: Schema.Boolean.pipe(
478 Schema.withDecodingDefault(Effect.succeed(false)),
479 ),
480 + // Retired Labs toggle. Still read as the default for the Usage item in threadDetailsItems.
481 threadDetailsUsageEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
482 + // Sparse show/hide overrides for thread details card items. Missing ids use the client's
483 + // default, so new items appear for everyone and unknown ids survive a downgrade.
484 + threadDetailsItems: Schema.Record(Schema.String, Schema.Boolean).pipe(
485 + Schema.withDecodingDefault(Effect.succeed({})),
486 + ),
487 // Opt-in for the removed legacy sidebar. Still read so those users land in
488 // the boring sidebar; the boring sidebar toggle clears it.
489 legacySidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
@@ -1722,6 +1728,7 @@ export const ClientSettingsPatch = Schema.Struct({
1728 boringSidebarEnabled: Schema.optionalKey(Schema.Boolean),
1729 boringSidebarMultilineRows: Schema.optionalKey(Schema.Boolean),
1730 threadDetailsUsageEnabled: Schema.optionalKey(Schema.Boolean),
1731 + threadDetailsItems: Schema.optionalKey(Schema.Record(Schema.String, Schema.Boolean)),
1732 legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
1733 sidebarWorkingShelfEnabled: Schema.optionalKey(Schema.Boolean),
1734 sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),