The best way to control Claude Code, Codex and more from any computer or phone
refactor(web): the command palette's thread items come from their own hook (#22687)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 21, 2026 at 01:13 UTC
767134a4a7a64d8d5dd29e84423157f94e28064e
3 files changed
+257
-208
apps/web/src/components/CommandPalette.tsx
+14
-208
@@ -24,7 +24,6 @@ import {
24
} from "@t3tools/client-runtime/operations/projects";
25
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
26
import { connectionStatusText } from "@t3tools/client-runtime/connection";
27
-import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";
27
import { resolveThreadReferenceCopyTarget } from "@t3tools/shared/threadReference";
28
import {
29
canPreloadBrowsePath,
@@ -42,11 +41,9 @@ import {
41
AuthSourceControlWriteScope,
42
AuthFilesystemReadScope,
43
type DesktopWslState,
45
- type ClientSettings,
44
type EnvironmentId,
45
type EnvironmentMachineKind,
46
type FilesystemBrowseResult,
49
- type ProjectId,
47
type SourceControlDiscoveryResult,
48
SourceControlProviderKind,
49
type SourceControlRepositoryInfo,
@@ -121,7 +118,6 @@ import {
118
usePrimaryEnvironmentId,
119
} from "../state/environments";
120
import { useProjects, useServerConfigs, useThreadShells, waitForProject } from "../state/entities";
124
-import { useThreadSearch } from "../state/queries";
121
import { resolveThreadActionProjectRef, startNewThreadFromContext } from "../lib/chatThreadActions";
122
import {
123
appendBrowsePathSegment,
@@ -166,7 +162,6 @@ import {
162
buildCommandPaletteProjectMetadata,
163
buildProjectActionItems,
164
buildRootGroups,
169
- buildThreadActionItems,
165
buildLinkedThreadActionItems,
166
buildCommandPaletteRows,
167
enumerateCommandPaletteItems,
@@ -188,9 +183,15 @@ import {
183
reduceCommandPaletteSearchState,
184
type SearchOverlayMode,
185
} from "./CommandPalette.logic";
191
-import { orderItemsByPreferredIds, sortLogicalProjectsForSidebar } from "./Sidebar.logic";
186
import { resolveEnvironmentOptionLabel } from "./BranchToolbar.logic";
187
import { CommandPaletteContent } from "./CommandPaletteContent";
188
+import {
189
+ selectCommandPaletteClientSettings,
190
+ useEnvironmentLookups,
191
+ useProjectLookups,
192
+ useSortedProjectGroups,
193
+} from "./CommandPaletteLookups";
194
+import { useCommandPaletteThreadItems } from "./CommandPaletteThreadItems";
195
import {
196
APPEARANCE_OPTIONS,
197
notifyThemeSaveFailure,
@@ -210,22 +211,8 @@ import { openLinkPullRequestDialog } from "./pullRequest/LinkPullRequestDialog";
211
import { ProjectContentSearchDialog } from "./search/ProjectContentSearchDialog";
212
import { toggleThemeEditorForTheme } from "./settings/themeEditorStore";
213
import { searchSettings, SETTINGS_SECTION_LABELS } from "./settings/settingsSearch";
213
-import {
214
- COMMAND_PALETTE_META_ICON_CLASS,
215
- CommandPaletteMetaDot,
216
- ThreadCommandSubtitle,
217
-} from "./ThreadCommandSubtitle";
218
-import {
219
- ThreadRowLeadingStatus,
220
- ThreadRowTrailingStatus,
221
- ThreadSearchPullRequestNumber,
222
-} from "./ThreadStatusIndicators";
223
-import { primaryServerKeybindingsAtom, primaryServerProvidersAtom } from "../state/server";
224
-import {
225
- applyProviderInstanceSettings,
226
- deriveProviderInstanceEntries,
227
- type ProviderInstanceEntry,
228
-} from "../providerInstances";
214
+import { COMMAND_PALETTE_META_ICON_CLASS, CommandPaletteMetaDot } from "./ThreadCommandSubtitle";
215
+import { primaryServerKeybindingsAtom } from "../state/server";
216
import { resolveShortcutCommand, threadJumpIndexFromCommand } from "../keybindings";
217
import { CommandDialog, CommandDialogPopup, CommandFooterAction } from "./ui/command";
218
import { Button } from "./ui/button";
@@ -235,12 +222,7 @@ import { stackedThreadToast, toastManager } from "./ui/toast";
222
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
223
import { ComposerHandleContext, useComposerHandleContext } from "../composerHandleContext";
224
import type { ChatComposerHandle } from "./chat/ChatComposer";
238
-import { getProjectOrderKey } from "../logicalProject";
239
-import { legacyProjectCwdPreferenceKey, useUiStateStore } from "../uiStateStore";
240
-import {
241
- buildSidebarProjectPickerEntries,
242
- buildSidebarProjectSnapshots,
243
-} from "../sidebarProjectGrouping";
225
+import { buildSidebarProjectPickerEntries } from "../sidebarProjectGrouping";
226
import type { Project } from "../types";
227
import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
228
import { readPullRequestListPreferences } from "~/components/pullRequest/pullRequestListPreferences";
@@ -350,99 +332,6 @@ function overlayModeForCommand(command: string | null): SearchOverlayMode | null
332
: null;
333
}
334
353
-// Each helper reads its own source hook so the compiler caches the derived value on that
354
-// source. Taking the source as an argument instead leaves the helper hook-free, and the
355
-// compiler then treats it as a plain function and caches nothing.
356
-function useThreadSearchWithContentMatches(
357
- environmentIds: ReadonlyArray<EnvironmentId>,
358
- query: string,
359
-) {
360
- const threadSearch = useThreadSearch(environmentIds, query);
361
- const contentMatchByKey = new Map(
362
- threadSearch.matches.flatMap((match) =>
363
- match.source === "user" || match.source === "assistant"
364
- ? [[threadSearchMatchKey(match), match] as const]
365
- : [],
366
- ),
367
- );
368
- return { threadSearch, contentMatchByKey };
369
-}
370
-
371
-function useEnvironmentLookups() {
372
- const { environments } = useEnvironments();
373
- const environmentLabelById = new Map(
374
- environments.map((environment) => [environment.environmentId, environment.label] as const),
375
- );
376
- const projectEnvironmentLocationById = new Map(
377
- environments.map((environment) => {
378
- const isPrimary = environment.entry.target._tag === "PrimaryConnectionTarget";
379
- const isLocal = isPrimary || isDesktopLocalConnectionTarget(environment.entry.target);
380
- return [
381
- environment.environmentId,
382
- {
383
- kind: isLocal ? "local" : "remote",
384
- label: isPrimary ? "Local" : isLocal ? `${environment.label} (Local)` : environment.label,
385
- machine: resolveEnvironmentMachineKind(environment.serverConfig),
386
- },
387
- ] as const;
388
- }),
389
- );
390
- return { environmentLabelById, projectEnvironmentLocationById };
391
-}
392
-
393
-function useProjectLookups() {
394
- const projects = useProjects();
395
- const projectCwdById = new Map<ProjectId, string>(
396
- projects.map((project) => [project.id, project.workspaceRoot]),
397
- );
398
- const projectByKey = new Map(
399
- projects.map((project) => [`${project.environmentId}:${project.id}`, project]),
400
- );
401
- const projectTitleById = new Map<ProjectId, string>(
402
- projects.map((project) => [project.id, project.title]),
403
- );
404
- return { projectCwdById, projectByKey, projectTitleById };
405
-}
406
-
407
-const selectCommandPaletteClientSettings = (settings: ClientSettings) => ({
408
- sidebarProjectGroupingMode: settings.sidebarProjectGroupingMode,
409
- sidebarProjectGroupingOverrides: settings.sidebarProjectGroupingOverrides,
410
- sidebarProjectSortOrder: settings.sidebarProjectSortOrder,
411
- sidebarThreadSortOrder: settings.sidebarThreadSortOrder,
412
-});
413
-
414
-function useSortedProjectGroups(environmentLabelById: ReadonlyMap<EnvironmentId, string>) {
415
- const projects = useProjects();
416
- const threads = useThreadShells();
417
- const projectOrder = useUiStateStore((store) => store.projectOrder);
418
- const clientSettings = useClientSettings(selectCommandPaletteClientSettings);
419
- const primaryEnvironmentId = usePrimaryEnvironmentId();
420
- const projectGroupingSettings = {
421
- sidebarProjectGroupingMode: clientSettings.sidebarProjectGroupingMode,
422
- sidebarProjectGroupingOverrides: clientSettings.sidebarProjectGroupingOverrides,
423
- };
424
- const orderedProjects = orderItemsByPreferredIds({
425
- items: projects,
426
- preferredIds: projectOrder,
427
- getId: getProjectOrderKey,
428
- getPreferenceIds: (project) => [
429
- getProjectOrderKey(project),
430
- legacyProjectCwdPreferenceKey(project.workspaceRoot),
431
- ],
432
- });
433
- const unsortedProjectGroups = buildSidebarProjectSnapshots({
434
- projects: clientSettings.sidebarProjectSortOrder === "manual" ? orderedProjects : projects,
435
- settings: projectGroupingSettings,
436
- primaryEnvironmentId,
437
- resolveEnvironmentLabel: (environmentId) => environmentLabelById.get(environmentId) ?? null,
438
- });
439
- return sortLogicalProjectsForSidebar(
440
- unsortedProjectGroups,
441
- threads,
442
- clientSettings.sidebarProjectSortOrder,
443
- );
444
-}
445
-
335
export function CommandPalette({ children }: { children: ReactNode }) {
336
const navigate = useNavigate();
337
const [state, dispatch] = useReducer(reduceCommandPaletteUiState, {
@@ -778,31 +667,10 @@ function OpenCommandPaletteDialog(props: {
667
};
668
const threads = useThreadShells();
669
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
781
- const { changeThemeItem, changeAppearanceItem, themeEditorItem } = useCommandPaletteThemeItems();
782
- const providers = useAtomValue(primaryServerProvidersAtom);
670
const providersByEnvironment = useEnvironmentProviders();
784
- const providerEntryByEnvironmentAndInstanceId = new Map<string, ProviderInstanceEntry>(
785
- environments.flatMap((environment) => {
786
- const serverConfig = environment.serverConfig;
787
- const derived = deriveProviderInstanceEntries(
788
- providersByEnvironment.get(environment.environmentId) ??
789
- (environment.environmentId === primaryEnvironmentId ? providers : []),
790
- );
791
- const entries = serverConfig
792
- ? applyProviderInstanceSettings(derived, serverConfig.settings, null)
793
- : derived;
794
- return entries.map(
795
- (entry) => [`${environment.environmentId}:${entry.instanceId}`, entry] as const,
796
- );
797
- }),
798
- );
671
+ const { changeThemeItem, changeAppearanceItem, themeEditorItem } = useCommandPaletteThemeItems();
672
const currentView = viewStack.at(-1)?.view ?? null;
800
- const environmentIds = environments
801
- .filter((environment) => environment.connection.phase === "connected")
802
- .map((environment) => environment.environmentId);
673
const threadSearchQuery = currentView === null && !isActionsOnly ? deferredQuery : "";
804
- const { threadSearch, contentMatchByKey: threadContentMatchByKey } =
805
- useThreadSearchWithContentMatches(environmentIds, threadSearchQuery);
674
const [browseGeneration, setBrowseGeneration] = useState(0);
675
const [browseNavigation] = useState(createBrowseNavigationCoordinator);
676
const [addProjectEnvironmentId, setAddProjectEnvironmentId] = useState<EnvironmentId | null>(
@@ -1183,70 +1051,8 @@ function OpenCommandPaletteDialog(props: {
1051
];
1052
})();
1053
1186
- const allThreadItems = buildThreadActionItems({
1187
- threads,
1188
- ...(activeThreadId ? { activeThreadId } : {}),
1189
- projectTitleById,
1190
- sortOrder: clientSettings.sidebarThreadSortOrder,
1191
- icon: <MessageSquareIcon className={ITEM_ICON_CLASS} />,
1192
- renderLeadingContent: (thread) => <ThreadRowLeadingStatus thread={thread} />,
1193
- renderTrailingContent: (thread) => (
1194
- <>
1195
- <ThreadSearchPullRequestNumber
1196
- thread={thread}
1197
- query={threadSearchQuery}
1198
- settled={thread.settledOverride === "settled"}
1199
- />
1200
- <ThreadRowTrailingStatus thread={thread} />
1201
- </>
1202
- ),
1203
- renderDescription: (thread, { projectTitle }) => {
1204
- const modelInstanceId =
1205
- thread.runtime?.providerInstanceId ?? thread.modelSelection.instanceId;
1206
- const providerEntry =
1207
- providerEntryByEnvironmentAndInstanceId.get(`${thread.environmentId}:${modelInstanceId}`) ??
1208
- null;
1209
- return (
1210
- <ThreadCommandSubtitle
1211
- project={projectByKey.get(`${thread.environmentId}:${thread.projectId}`) ?? null}
1212
- projectTitle={projectTitle ?? null}
1213
- environmentLabel={
1214
- projectEnvironmentLocationById.get(thread.environmentId)?.label ?? "Remote"
1215
- }
1216
- branch={thread.branch}
1217
- worktreePath={thread.worktreePath}
1218
- isCurrent={thread.id === activeThreadId}
1219
- driverKind={providerEntry?.driverKind ?? null}
1220
- providerDisplayName={
1221
- thread.runtime?.providerName ?? providerEntry?.displayName ?? modelInstanceId
1222
- }
1223
- acpRegistryAgentId={providerEntry?.acpRegistryAgentId}
1224
- acpRegistryIconUrl={providerEntry?.acpRegistryIconUrl}
1225
- />
1226
- );
1227
- },
1228
- getContentMatch: (thread) => {
1229
- const match = threadContentMatchByKey.get(
1230
- threadSearchMatchKey({
1231
- environmentId: thread.environmentId,
1232
- threadId: thread.id,
1233
- }),
1234
- );
1235
- return match && (match.source === "user" || match.source === "assistant")
1236
- ? {
1237
- source: match.source,
1238
- snippet: match.snippet,
1239
- query: threadSearch.query,
1240
- }
1241
- : undefined;
1242
- },
1243
- runThread: async (thread) => {
1244
- await navigate({
1245
- to: "/$environmentId/$threadId",
1246
- params: buildThreadRouteParams(scopeThreadRef(thread.environmentId, thread.id)),
1247
- });
1248
- },
1249
- });
1054
+ const { threadItems: allThreadItems, isSearchPending: isThreadSearchPending } =
1055
+ useCommandPaletteThreadItems({ activeThreadId, threadSearchQuery });
1056
const recentThreadItems = allThreadItems.slice(0, RECENT_THREAD_LIMIT);
1057
1058
// Stable so the item builders that capture it during render never see the
@@ -3208,7 +3014,7 @@ function OpenCommandPaletteDialog(props: {
3014
? {
3015
emptyStateMessage: "Press Enter to create this folder and add it as a project.",
3016
}
3211
- : threadSearch.isPending
3017
+ : isThreadSearchPending
3018
? { emptyStateMessage: "Searching thread messages…" }
3019
: {})}
3020
/>
apps/web/src/components/CommandPaletteLookups.ts
new
+93
@@ -0,0 +1,93 @@
1
+import {
2
+ type ClientSettings,
3
+ type EnvironmentId,
4
+ type ProjectId,
5
+ resolveEnvironmentMachineKind,
6
+} from "@t3tools/contracts";
7
+
8
+import { isDesktopLocalConnectionTarget } from "../connection/desktopLocal";
9
+import { useClientSettings } from "../hooks/useSettings";
10
+import { getProjectOrderKey } from "../logicalProject";
11
+import { useProjects, useThreadShells } from "../state/entities";
12
+import { useEnvironments, usePrimaryEnvironmentId } from "../state/environments";
13
+import { buildSidebarProjectSnapshots } from "../sidebarProjectGrouping";
14
+import { legacyProjectCwdPreferenceKey, useUiStateStore } from "../uiStateStore";
15
+import { orderItemsByPreferredIds, sortLogicalProjectsForSidebar } from "./Sidebar.logic";
16
+
17
+// Each helper reads its own source hook so the compiler caches the derived value on that
18
+// source. Taking the source as an argument instead leaves the helper hook-free, and the
19
+// compiler then treats it as a plain function and caches nothing.
20
+export function useEnvironmentLookups() {
21
+ const { environments } = useEnvironments();
22
+ const environmentLabelById = new Map(
23
+ environments.map((environment) => [environment.environmentId, environment.label] as const),
24
+ );
25
+ const projectEnvironmentLocationById = new Map(
26
+ environments.map((environment) => {
27
+ const isPrimary = environment.entry.target._tag === "PrimaryConnectionTarget";
28
+ const isLocal = isPrimary || isDesktopLocalConnectionTarget(environment.entry.target);
29
+ return [
30
+ environment.environmentId,
31
+ {
32
+ kind: isLocal ? "local" : "remote",
33
+ label: isPrimary ? "Local" : isLocal ? `${environment.label} (Local)` : environment.label,
34
+ machine: resolveEnvironmentMachineKind(environment.serverConfig),
35
+ },
36
+ ] as const;
37
+ }),
38
+ );
39
+ return { environmentLabelById, projectEnvironmentLocationById };
40
+}
41
+
42
+export function useProjectLookups() {
43
+ const projects = useProjects();
44
+ const projectCwdById = new Map<ProjectId, string>(
45
+ projects.map((project) => [project.id, project.workspaceRoot]),
46
+ );
47
+ const projectByKey = new Map(
48
+ projects.map((project) => [`${project.environmentId}:${project.id}`, project]),
49
+ );
50
+ const projectTitleById = new Map<ProjectId, string>(
51
+ projects.map((project) => [project.id, project.title]),
52
+ );
53
+ return { projectCwdById, projectByKey, projectTitleById };
54
+}
55
+
56
+export const selectCommandPaletteClientSettings = (settings: ClientSettings) => ({
57
+ sidebarProjectGroupingMode: settings.sidebarProjectGroupingMode,
58
+ sidebarProjectGroupingOverrides: settings.sidebarProjectGroupingOverrides,
59
+ sidebarProjectSortOrder: settings.sidebarProjectSortOrder,
60
+ sidebarThreadSortOrder: settings.sidebarThreadSortOrder,
61
+});
62
+
63
+export function useSortedProjectGroups(environmentLabelById: ReadonlyMap<EnvironmentId, string>) {
64
+ const projects = useProjects();
65
+ const threads = useThreadShells();
66
+ const projectOrder = useUiStateStore((store) => store.projectOrder);
67
+ const clientSettings = useClientSettings(selectCommandPaletteClientSettings);
68
+ const primaryEnvironmentId = usePrimaryEnvironmentId();
69
+ const projectGroupingSettings = {
70
+ sidebarProjectGroupingMode: clientSettings.sidebarProjectGroupingMode,
71
+ sidebarProjectGroupingOverrides: clientSettings.sidebarProjectGroupingOverrides,
72
+ };
73
+ const orderedProjects = orderItemsByPreferredIds({
74
+ items: projects,
75
+ preferredIds: projectOrder,
76
+ getId: getProjectOrderKey,
77
+ getPreferenceIds: (project) => [
78
+ getProjectOrderKey(project),
79
+ legacyProjectCwdPreferenceKey(project.workspaceRoot),
80
+ ],
81
+ });
82
+ const unsortedProjectGroups = buildSidebarProjectSnapshots({
83
+ projects: clientSettings.sidebarProjectSortOrder === "manual" ? orderedProjects : projects,
84
+ settings: projectGroupingSettings,
85
+ primaryEnvironmentId,
86
+ resolveEnvironmentLabel: (environmentId) => environmentLabelById.get(environmentId) ?? null,
87
+ });
88
+ return sortLogicalProjectsForSidebar(
89
+ unsortedProjectGroups,
90
+ threads,
91
+ clientSettings.sidebarProjectSortOrder,
92
+ );
93
+}
apps/web/src/components/CommandPaletteThreadItems.tsx
new
+150
@@ -0,0 +1,150 @@
1
+import { scopeThreadRef } from "@t3tools/client-runtime/environment";
2
+import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";
3
+import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
4
+import { useAtomValue } from "@effect/atom-react";
5
+import { useNavigate } from "@tanstack/react-router";
6
+import { MessageSquareIcon } from "lucide-react";
7
+
8
+import { useClientSettings } from "../hooks/useSettings";
9
+import {
10
+ applyProviderInstanceSettings,
11
+ deriveProviderInstanceEntries,
12
+ type ProviderInstanceEntry,
13
+} from "../providerInstances";
14
+import { useThreadShells } from "../state/entities";
15
+import {
16
+ useEnvironmentProviders,
17
+ useEnvironments,
18
+ usePrimaryEnvironmentId,
19
+} from "../state/environments";
20
+import { useThreadSearch } from "../state/queries";
21
+import { primaryServerProvidersAtom } from "../state/server";
22
+import { buildThreadRouteParams } from "../threadRoutes";
23
+import { buildThreadActionItems, ITEM_ICON_CLASS } from "./CommandPalette.logic";
24
+import { useEnvironmentLookups, useProjectLookups } from "./CommandPaletteLookups";
25
+import { ThreadCommandSubtitle } from "./ThreadCommandSubtitle";
26
+import {
27
+ ThreadRowLeadingStatus,
28
+ ThreadRowTrailingStatus,
29
+ ThreadSearchPullRequestNumber,
30
+} from "./ThreadStatusIndicators";
31
+
32
+function useProviderEntryByEnvironmentAndInstanceId() {
33
+ const { environments } = useEnvironments();
34
+ const primaryEnvironmentId = usePrimaryEnvironmentId();
35
+ const providers = useAtomValue(primaryServerProvidersAtom);
36
+ const providersByEnvironment = useEnvironmentProviders();
37
+ return new Map<string, ProviderInstanceEntry>(
38
+ environments.flatMap((environment) => {
39
+ const serverConfig = environment.serverConfig;
40
+ const derived = deriveProviderInstanceEntries(
41
+ providersByEnvironment.get(environment.environmentId) ??
42
+ (environment.environmentId === primaryEnvironmentId ? providers : []),
43
+ );
44
+ const entries = serverConfig
45
+ ? applyProviderInstanceSettings(derived, serverConfig.settings, null)
46
+ : derived;
47
+ return entries.map(
48
+ (entry) => [`${environment.environmentId}:${entry.instanceId}`, entry] as const,
49
+ );
50
+ }),
51
+ );
52
+}
53
+
54
+function useThreadSearchWithContentMatches(query: string) {
55
+ const { environments } = useEnvironments();
56
+ const environmentIds: ReadonlyArray<EnvironmentId> = environments
57
+ .filter((environment) => environment.connection.phase === "connected")
58
+ .map((environment) => environment.environmentId);
59
+ const threadSearch = useThreadSearch(environmentIds, query);
60
+ const contentMatchByKey = new Map(
61
+ threadSearch.matches.flatMap((match) =>
62
+ match.source === "user" || match.source === "assistant"
63
+ ? [[threadSearchMatchKey(match), match] as const]
64
+ : [],
65
+ ),
66
+ );
67
+ return { threadSearch, contentMatchByKey };
68
+}
69
+
70
+/** Every thread as a palette item, with message matches for a non-empty `threadSearchQuery`. */
71
+export function useCommandPaletteThreadItems(input: {
72
+ readonly activeThreadId: ThreadId | undefined;
73
+ readonly threadSearchQuery: string;
74
+}) {
75
+ const { activeThreadId, threadSearchQuery } = input;
76
+ const navigate = useNavigate();
77
+ const threads = useThreadShells();
78
+ const sidebarThreadSortOrder = useClientSettings((settings) => settings.sidebarThreadSortOrder);
79
+ const { projectEnvironmentLocationById } = useEnvironmentLookups();
80
+ const providerEntryByEnvironmentAndInstanceId = useProviderEntryByEnvironmentAndInstanceId();
81
+ const { threadSearch, contentMatchByKey } = useThreadSearchWithContentMatches(threadSearchQuery);
82
+ const { projectByKey, projectTitleById } = useProjectLookups();
83
+
84
+ const threadItems = buildThreadActionItems({
85
+ threads,
86
+ ...(activeThreadId ? { activeThreadId } : {}),
87
+ projectTitleById,
88
+ sortOrder: sidebarThreadSortOrder,
89
+ icon: <MessageSquareIcon className={ITEM_ICON_CLASS} />,
90
+ renderLeadingContent: (thread) => <ThreadRowLeadingStatus thread={thread} />,
91
+ renderTrailingContent: (thread) => (
92
+ <>
93
+ <ThreadSearchPullRequestNumber
94
+ thread={thread}
95
+ query={threadSearchQuery}
96
+ settled={thread.settledOverride === "settled"}
97
+ />
98
+ <ThreadRowTrailingStatus thread={thread} />
99
+ </>
100
+ ),
101
+ renderDescription: (thread, { projectTitle }) => {
102
+ const modelInstanceId =
103
+ thread.runtime?.providerInstanceId ?? thread.modelSelection.instanceId;
104
+ const providerEntry =
105
+ providerEntryByEnvironmentAndInstanceId.get(`${thread.environmentId}:${modelInstanceId}`) ??
106
+ null;
107
+ return (
108
+ <ThreadCommandSubtitle
109
+ project={projectByKey.get(`${thread.environmentId}:${thread.projectId}`) ?? null}
110
+ projectTitle={projectTitle ?? null}
111
+ environmentLabel={
112
+ projectEnvironmentLocationById.get(thread.environmentId)?.label ?? "Remote"
113
+ }
114
+ branch={thread.branch}
115
+ worktreePath={thread.worktreePath}
116
+ isCurrent={thread.id === activeThreadId}
117
+ driverKind={providerEntry?.driverKind ?? null}
118
+ providerDisplayName={
119
+ thread.runtime?.providerName ?? providerEntry?.displayName ?? modelInstanceId
120
+ }
121
+ acpRegistryAgentId={providerEntry?.acpRegistryAgentId}
122
+ acpRegistryIconUrl={providerEntry?.acpRegistryIconUrl}
123
+ />
124
+ );
125
+ },
126
+ getContentMatch: (thread) => {
127
+ const match = contentMatchByKey.get(
128
+ threadSearchMatchKey({
129
+ environmentId: thread.environmentId,
130
+ threadId: thread.id,
131
+ }),
132
+ );
133
+ return match && (match.source === "user" || match.source === "assistant")
134
+ ? {
135
+ source: match.source,
136
+ snippet: match.snippet,
137
+ query: threadSearch.query,
138
+ }
139
+ : undefined;
140
+ },
141
+ runThread: async (thread) => {
142
+ await navigate({
143
+ to: "/$environmentId/$threadId",
144
+ params: buildThreadRouteParams(scopeThreadRef(thread.environmentId, thread.id)),
145
+ });
146
+ },
147
+ });
148
+
149
+ return { threadItems, isSearchPending: threadSearch.isPending };
150
+}