Skip to content

Commit 5efa3cd

Browse files
feat: split chats from files in the @ menu (#262)
* feat: split chats from files in the @ menu The @ menu's Files tab mixed chat tabs and threads in with file results. Chats now get their own tab on web and mobile: open chat tabs first, then other threads by recency. A query with chat matches but no file matches opens on Chats. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat: show project, branch, model, and status in the @ menu's Chats tab Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(web): keep chat model names aligned when the provider icon is missing Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 25265c3 commit 5efa3cd

12 files changed

Lines changed: 307 additions & 120 deletions

File tree

‎apps/mobile/src/features/threads/ComposerCommandPopover.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import { cn } from "../../lib/cn";
3131
import { SUBAGENT_TONE_TEXT_CLASS, SubagentStatusDot } from "./SubagentStatusDot";
3232
import { subagentStatusLabel, subagentStatusTone } from "./threadAgentsPresentation";
3333

34-
/** The `@` menu's tabs, shown when the thread has agents to reference. */
35-
export type ComposerPathTab = "files" | "agents";
34+
/** The `@` menu's tabs. Agents shows only when the thread has agents to reference. */
35+
export type ComposerPathTab = "files" | "chats" | "agents";
3636

3737
export type ComposerCommandItem =
3838
| {
@@ -92,18 +92,23 @@ interface ComposerCommandPopoverProps {
9292
readonly triggerKind: ComposerTriggerKind | null;
9393
readonly isLoading: boolean;
9494
readonly error?: string | null;
95-
/** Files/Agents tabs for the `@` menu; null when the thread has no agents. */
95+
/** Files/Chats/Agents tabs for the `@` menu. */
9696
readonly pathTab?: {
9797
readonly active: ComposerPathTab;
98+
readonly showAgents: boolean;
9899
readonly onChange: (tab: ComposerPathTab) => void;
99100
} | null;
100101
readonly onSelect: (item: ComposerCommandItem) => void;
101102
}
102103

103104
const PATH_TAB_OPTIONS = [
104105
{ value: "files", label: "Files" },
106+
{ value: "chats", label: "Chats" },
105107
{ value: "agents", label: "Agents" },
106108
] as const satisfies ReadonlyArray<{ value: ComposerPathTab; label: string }>;
109+
const PATH_TAB_OPTIONS_WITHOUT_AGENTS = PATH_TAB_OPTIONS.filter(
110+
(option) => option.value !== "agents",
111+
);
107112

108113
function PopoverSurface(props: { readonly children: React.ReactNode; readonly style?: ViewStyle }) {
109114
const baseStyle: ViewStyle = {
@@ -171,6 +176,7 @@ function emptyText(
171176
pathTab: ComposerPathTab | null,
172177
): string {
173178
if (pathTab === "agents") return "No matching agents.";
179+
if (pathTab === "chats") return "No matching chats.";
174180
if (isLoading) {
175181
return triggerKind === "path" ? "Searching files…" : "Loading…";
176182
}
@@ -314,7 +320,7 @@ export const ComposerCommandPopover = memo(function ComposerCommandPopover(
314320
<SegmentedControl
315321
size="compact"
316322
role="tab"
317-
options={PATH_TAB_OPTIONS}
323+
options={pathTab.showAgents ? PATH_TAB_OPTIONS : PATH_TAB_OPTIONS_WITHOUT_AGENTS}
318324
selected={pathTab.active}
319325
onSelect={pathTab.onChange}
320326
/>

‎apps/mobile/src/features/threads/NewTaskDraftScreen.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ export function NewTaskDraftScreen(props: {
506506
ownerKey: flow.draftKey,
507507
environmentId: selectedProject?.environmentId ?? null,
508508
threadShells: useThreadShells(),
509+
projects: useProjects(),
509510
pullRequestProjectId: selectedEnvironmentServerConfig?.environment.capabilities.pullRequests
510511
? (selectedProject?.id ?? null)
511512
: null,

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import {
6565
} from "../../state/use-composer-drafts";
6666
import { appAtomRegistry } from "../../state/atom-registry";
6767
import type { ComposerDocumentAttachment } from "../../lib/composerContext";
68-
import { useProject, useThreadShells } from "../../state/entities";
68+
import { useProject, useProjects, useThreadShells } from "../../state/entities";
6969
import { environmentThreadDetails } from "../../state/threads";
7070
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
7171

@@ -532,6 +532,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
532532
ownerKey: composerOwnerKey,
533533
environmentId: props.environmentId,
534534
threadShells: useThreadShells(),
535+
projects: useProjects(),
535536
currentThreadId: props.selectedThread.id,
536537
...(threadSubagents ? { threadSubagents } : {}),
537538
...(props.serverConfig ? { providers: props.serverConfig.providers } : {}),

‎apps/mobile/src/features/threads/use-composer-command-menu.ts‎

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ import type {
88
ThreadId,
99
} from "@t3tools/contracts";
1010
import { matchComposerThreadItems } from "@t3tools/client-runtime/composerThreadItems";
11-
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/models";
11+
import type {
12+
EnvironmentProject,
13+
EnvironmentThreadShell,
14+
} from "@t3tools/client-runtime/state/models";
1215
import { deriveThreadAgentFleet } from "@t3tools/client-runtime/state/agent-fleet";
1316
import {
1417
matchesSubagentQuery,
1518
subagentContextRecord,
1619
} from "@t3tools/client-runtime/state/subagent-handles";
1720

1821
const EMPTY_THREAD_SHELLS: ReadonlyArray<EnvironmentThreadShell> = [];
22+
const EMPTY_PROJECTS: ReadonlyArray<EnvironmentProject> = [];
1923
const EMPTY_SUBAGENTS: ReadonlyArray<OrchestrationV2Subagent> = [];
2024
const EMPTY_PROVIDERS: ReadonlyArray<ServerProvider> = [];
2125
import {
@@ -184,6 +188,7 @@ export function useComposerCommandMenu({
184188
ownerKey,
185189
environmentId,
186190
threadShells = EMPTY_THREAD_SHELLS,
191+
projects = EMPTY_PROJECTS,
187192
currentThreadId = null,
188193
threadSubagents = EMPTY_SUBAGENTS,
189194
providers = EMPTY_PROVIDERS,
@@ -204,6 +209,8 @@ export function useComposerCommandMenu({
204209
readonly environmentId: EnvironmentId | null;
205210
/** Candidates for `@` thread suggestions; the caller reads them from the entity store. */
206211
readonly threadShells?: ReadonlyArray<EnvironmentThreadShell>;
212+
/** Names the project beside each `@` thread suggestion. */
213+
readonly projects?: ReadonlyArray<EnvironmentProject>;
207214
/** Left out of `@` thread suggestions: a thread is never context for itself. */
208215
readonly currentThreadId?: ThreadId | null;
209216
/** The current thread's subagent records, for the `@` menu's Agents tab. */
@@ -381,27 +388,54 @@ export function useComposerCommandMenu({
381388
.map((shell) => shell.source),
382389
}).filter((entry) => entry.subagent !== null);
383390
}, [currentThreadId, environmentId, pathTriggerOpen, threadShells, threadSubagents]);
384-
// The tab the user picked for this `@`; otherwise Agents when the query starts a handle.
391+
const chatItems = useMemo(
392+
() =>
393+
trigger?.kind === "path" && environmentId
394+
? matchComposerThreadItems({
395+
shells: threadShells,
396+
environmentId,
397+
excludeThreadId: currentThreadId,
398+
query: trigger.query,
399+
projectTitles: new Map(
400+
projects
401+
.filter((project) => project.environmentId === environmentId)
402+
.map((project) => [project.id, project.title]),
403+
),
404+
})
405+
: [],
406+
[currentThreadId, environmentId, projects, threadShells, trigger],
407+
);
408+
// The tab the user picked for this `@`; otherwise Agents when the query starts a handle,
409+
// Chats when only chats match, else Files.
385410
const [pathTabChoice, setPathTabChoice] = useState<{
386411
readonly rangeStart: number;
387412
readonly tab: ComposerPathTab;
388413
} | null>(null);
389414
const pathTab = useMemo(() => {
390-
if (trigger?.kind !== "path" || agentFleet.length === 0) return null;
415+
if (trigger?.kind !== "path") return null;
391416
const needle = trigger.query.trim().toLowerCase();
417+
const showAgents = agentFleet.length > 0;
392418
const prefersAgents =
393419
needle.length > 0 && agentFleet.some((entry) => entry.handle.startsWith(needle));
420+
const prefersChats =
421+
needle.length > 0 &&
422+
chatItems.length > 0 &&
423+
!pathSearch.isPending &&
424+
pathSearch.entries.length === 0;
394425
const rangeStart = trigger.rangeStart;
395426
return {
396427
active:
397-
pathTabChoice?.rangeStart === rangeStart
428+
pathTabChoice?.rangeStart === rangeStart && (pathTabChoice.tab !== "agents" || showAgents)
398429
? pathTabChoice.tab
399430
: prefersAgents
400431
? ("agents" as const)
401-
: ("files" as const),
432+
: prefersChats
433+
? ("chats" as const)
434+
: ("files" as const),
435+
showAgents,
402436
onChange: (tab: ComposerPathTab) => setPathTabChoice({ rangeStart, tab }),
403437
};
404-
}, [agentFleet, pathTabChoice, trigger]);
438+
}, [agentFleet, chatItems, pathSearch.entries, pathSearch.isPending, pathTabChoice, trigger]);
405439
const pullRequestSearch = useComposerPullRequestSearch({
406440
environmentId,
407441
projectId: pullRequestProjectId,
@@ -560,39 +594,28 @@ export function useComposerCommandMenu({
560594
}));
561595
}
562596

597+
if (trigger.kind === "path" && pathTab?.active === "chats") return chatItems;
598+
563599
if (trigger.kind === "path") {
564-
const threadItems = environmentId
565-
? matchComposerThreadItems({
566-
shells: threadShells,
567-
environmentId,
568-
excludeThreadId: currentThreadId,
569-
query: trigger.query,
570-
})
571-
: [];
572-
return [
573-
...threadItems,
574-
...pathSearch.entries.map((entry) => {
575-
const parts = entry.path.split("/");
576-
return {
577-
id: `path:${entry.path}`,
578-
type: "path" as const,
579-
path: entry.path,
580-
kind: entry.kind,
581-
label: parts[parts.length - 1] ?? entry.path,
582-
description: parts.length > 1 ? parts.slice(0, -1).join("/") : "",
583-
};
584-
}),
585-
];
600+
return pathSearch.entries.map((entry) => {
601+
const parts = entry.path.split("/");
602+
return {
603+
id: `path:${entry.path}`,
604+
type: "path" as const,
605+
path: entry.path,
606+
kind: entry.kind,
607+
label: parts[parts.length - 1] ?? entry.path,
608+
description: parts.length > 1 ? parts.slice(0, -1).join("/") : "",
609+
};
610+
});
586611
}
587612

588613
return [];
589614
}, [
590615
agentFleet,
591-
currentThreadId,
592-
environmentId,
616+
chatItems,
593617
pathTab?.active,
594618
providers,
595-
threadShells,
596619
hasThread,
597620
hasCompactableConversation,
598621
onUpdateInteractionMode,
@@ -746,7 +769,7 @@ export function useComposerCommandMenu({
746769
isLoading:
747770
trigger?.kind === "pull-request"
748771
? pullRequestSearch.isPending
749-
: pathTab?.active !== "agents" && pathSearch.isPending,
772+
: (pathTab === null || pathTab.active === "files") && pathSearch.isPending,
750773
error:
751774
trigger?.kind === "pull-request"
752775
? pullRequestProjectId === null || pullRequestRepository === null

0 commit comments

Comments
 (0)