Skip to content

Commit 21583f9

Browse files
BarretoDiegoclaude
andcommitted
feat(web): make a thread's path in the header navigable
The header above a thread showed a project name and a title. The project was not a link — clicking it started a new thread, an action a breadcrumb has no business performing — and the environment was missing entirely, so with two servers connected the header never said which machine the work was running on. There was also nowhere to go: no view of one environment's projects, and no view of one project's threads outside the sidebar's narrow column. The header now reads environment / project / thread, widest scope first, and every crumb above the thread is a link to that scope's own page. The environment leads whenever the server actually names itself; a blank name renders no crumb rather than an icon with nothing beside it. Two pages back those links. The environment page lists every project on that server, busiest first, with each one's live thread count and last activity — including projects with no threads yet, the same promise the sidebar's seeded sections make. The project page lists that project's threads under Active, Snoozed and Settled. Those shelves are the sidebar's rule, reused rather than re-derived, so the two surfaces cannot disagree about what is finished. One deliberate omission: the sidebar's pull-request snapshot stays behind. It is a sidebar-local cache of open PRs, and a page that needed one would be fetching PR state to decide where a row goes. With Auto-settle merged threads on, a thread whose PR just merged reads as active here until the server stamps it. The project page is scoped to the project on *this* environment rather than to the sidebar's logical grouping. The crumb comes from a thread, a thread has exactly one environment, and a page reached by following a path should not quietly widen it. Clicking the project name no longer starts a thread. Both pages carry a New thread / New project button, the sidebar's project headers still have theirs, and the keybinding is untouched — so the action loses a hiding place, not a home. Docs: the new section in the thread sidebar guide. Desktop inherits this from web; mobile has its own navigation and no header of this shape, so it is unaffected. Written by Claude Opus 5 in Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 067399c commit 21583f9

13 files changed

Lines changed: 1070 additions & 37 deletions

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ import {
346346
revokeBlobPreviewUrl,
347347
revokeUserMessagePreviewUrls,
348348
shouldWriteThreadErrorToCurrentServerThread,
349-
startNewThreadForProject,
350349
waitForStartedServerThread,
351350
} from "./ChatView.logic";
352351
import type { ThreadSyncPhase } from "../threadSync";
@@ -1800,9 +1799,6 @@ function ChatViewContent(props: ChatViewProps) {
18001799
[activeThread?.environmentId, activeThread?.projectId],
18011800
);
18021801
const activeProject = useProject(activeProjectRef);
1803-
const handleNewThreadInActiveProject = useCallback(() => {
1804-
startNewThreadForProject(activeProjectRef, handleNewThread);
1805-
}, [activeProjectRef, handleNewThread]);
18061802
const activeEnvironmentShell = useEnvironmentQuery(
18071803
activeThread ? environmentShell.stateAtom(activeThread.environmentId) : null,
18081804
);
@@ -6595,6 +6591,7 @@ function ChatViewContent(props: ChatViewProps) {
65956591
activeThreadTitle={activeThread.title}
65966592
isServerThread={isServerThread}
65976593
changeRequest={activeThreadChangeRequest}
6594+
activeProjectId={activeProject?.id ?? null}
65986595
activeProjectName={activeProject?.title}
65996596
activeProjectCwd={activeProject?.workspaceRoot ?? null}
66006597
activeProjectFaviconPath={activeProject?.faviconPath ?? null}
@@ -6607,7 +6604,6 @@ function ChatViewContent(props: ChatViewProps) {
66076604
availableEditors={availableEditors}
66086605
rightPanelOpen={rightPanelOpen}
66096606
gitCwd={gitCwd}
6610-
onNewThreadInProject={handleNewThreadInActiveProject}
66116607
onRunProjectScript={runProjectScript}
66126608
onAddProjectScript={saveProjectScript}
66136609
onUpdateProjectScript={updateProjectScript}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export function WorkspaceBreadcrumb({ ariaLabel, children, className }: Workspac
2222

2323
interface WorkspaceBreadcrumbItemProps {
2424
readonly children: ReactNode;
25-
readonly className?: string;
25+
// Explicitly `| undefined` so a caller can forward an optional className
26+
// straight through under exactOptionalPropertyTypes.
27+
readonly className?: string | undefined;
2628
readonly current?: boolean;
2729
}
2830

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { Link } from "@tanstack/react-router";
2+
import type { EnvironmentId, ProjectId } from "@t3tools/contracts";
3+
import { HardDriveIcon, ServerIcon } from "lucide-react";
4+
5+
import { cn } from "../lib/utils";
6+
import { usePrimaryEnvironmentId } from "../state/environments";
7+
import { ProjectFavicon } from "./ProjectFavicon";
8+
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
9+
import { WorkspaceBreadcrumbItem } from "./WorkspaceBreadcrumb";
10+
11+
/**
12+
* The clickable halves of a thread's path: its environment and its project.
13+
*
14+
* Both crumbs render the same way wherever the path is shown — the chat
15+
* header, the environment page, the project page — so a scope always looks
16+
* like the same thing and always leads to the same place. Shared as
17+
* components rather than as a `crumbs` array because each one carries its own
18+
* icon rule and its own tooltip copy.
19+
*/
20+
21+
const CRUMB_LINK_CLASS =
22+
"inline-flex min-w-0 cursor-pointer items-center gap-1.5 rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring";
23+
24+
/** A crumb that is the page you are on: no link, no hover affordance. */
25+
const CRUMB_CURRENT_CLASS = "inline-flex min-w-0 items-center gap-1.5 text-foreground";
26+
27+
export function EnvironmentCrumb(props: {
28+
readonly environmentId: EnvironmentId;
29+
readonly label: string;
30+
/** True when this crumb *is* the current page, so it stops being a link. */
31+
readonly current?: boolean;
32+
}) {
33+
const primaryEnvironmentId = usePrimaryEnvironmentId();
34+
// The machine you are sitting at gets a drive; anything reached over the
35+
// network gets a server. One glance answers "is this work happening here".
36+
const Icon = props.environmentId === primaryEnvironmentId ? HardDriveIcon : ServerIcon;
37+
const body = (
38+
<>
39+
<Icon aria-hidden className="size-3.5 shrink-0" />
40+
<span className="max-w-32 truncate">{props.label}</span>
41+
</>
42+
);
43+
if (props.current === true) {
44+
return (
45+
<WorkspaceBreadcrumbItem current>
46+
<span className={CRUMB_CURRENT_CLASS}>{body}</span>
47+
</WorkspaceBreadcrumbItem>
48+
);
49+
}
50+
return (
51+
<WorkspaceBreadcrumbItem>
52+
<Tooltip>
53+
<TooltipTrigger
54+
render={
55+
<Link
56+
to="/environments/$environmentId"
57+
params={{ environmentId: props.environmentId }}
58+
aria-label={`Open ${props.label}`}
59+
className={CRUMB_LINK_CLASS}
60+
/>
61+
}
62+
>
63+
{body}
64+
</TooltipTrigger>
65+
<TooltipPopup side="bottom">Every project in {props.label}</TooltipPopup>
66+
</Tooltip>
67+
</WorkspaceBreadcrumbItem>
68+
);
69+
}
70+
71+
export function ProjectCrumb(props: {
72+
readonly environmentId: EnvironmentId;
73+
readonly projectId: ProjectId;
74+
readonly label: string;
75+
readonly cwd: string | null;
76+
readonly faviconPath: string | null;
77+
readonly current?: boolean;
78+
readonly className?: string | undefined;
79+
}) {
80+
const body = (
81+
<>
82+
<ProjectFavicon
83+
environmentId={props.environmentId}
84+
cwd={props.cwd ?? ""}
85+
faviconPath={props.faviconPath}
86+
className="size-3.5"
87+
/>
88+
<span className={cn("truncate", props.current === true ? "min-w-0" : "max-w-40")}>
89+
{props.label}
90+
</span>
91+
</>
92+
);
93+
if (props.current === true) {
94+
return (
95+
<WorkspaceBreadcrumbItem current className={props.className}>
96+
<span className={CRUMB_CURRENT_CLASS}>{body}</span>
97+
</WorkspaceBreadcrumbItem>
98+
);
99+
}
100+
return (
101+
<WorkspaceBreadcrumbItem className={props.className}>
102+
<Tooltip>
103+
<TooltipTrigger
104+
render={
105+
<Link
106+
to="/environments/$environmentId/projects/$projectId"
107+
params={{ environmentId: props.environmentId, projectId: props.projectId }}
108+
aria-label={`Open ${props.label}`}
109+
className={CRUMB_LINK_CLASS}
110+
/>
111+
}
112+
>
113+
{body}
114+
</TooltipTrigger>
115+
<TooltipPopup side="bottom">Every thread in {props.label}</TooltipPopup>
116+
</Tooltip>
117+
</WorkspaceBreadcrumbItem>
118+
);
119+
}

‎apps/web/src/components/chat/ChatHeader.tsx‎

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
type EnvironmentId,
33
type EditorId,
4+
type ProjectId,
45
type ProjectScript,
56
type ResolvedKeybindingsConfig,
67
type ThreadId,
@@ -33,17 +34,18 @@ import ProjectScriptsControl, {
3334
} from "../ProjectScriptsControl";
3435
import { OpenInPicker } from "./OpenInPicker";
3536
import { useRemoteOpenState, type RemoteOpenMode } from "../../remoteOpen";
36-
import { usePrimaryEnvironmentId } from "../../state/environments";
37+
import { useEnvironments, usePrimaryEnvironmentId } from "../../state/environments";
3738
import { useT3ProjectFileScripts } from "~/hooks/useT3ProjectFileScripts";
3839
import { useThreadActionMenu } from "~/hooks/useThreadActionMenu";
3940
import { threadEnvironment } from "../../state/threads";
4041
import { useAtomCommand } from "../../state/use-atom-command";
41-
import { ProjectFavicon } from "../ProjectFavicon";
4242
import {
4343
WorkspaceBreadcrumb,
4444
WorkspaceBreadcrumbItem,
4545
WorkspaceBreadcrumbSeparator,
4646
} from "../WorkspaceBreadcrumb";
47+
import { EnvironmentCrumb, ProjectCrumb } from "../WorkspaceScopeCrumbs";
48+
import { resolveScopeEnvironmentLabel } from "../../workspaceScope";
4749
import { cn } from "~/lib/utils";
4850

4951
interface ChatHeaderProps {
@@ -55,6 +57,8 @@ interface ChatHeaderProps {
5557
isServerThread: boolean;
5658
/** PR feeding the settled classification, resolved by ChatView. */
5759
changeRequest: ChangeRequestSettleSource | null;
60+
/** Null on a draft whose project has not resolved yet — the crumb hides. */
61+
activeProjectId: ProjectId | null;
5862
activeProjectName: string | undefined;
5963
activeProjectCwd: string | null;
6064
activeProjectFaviconPath: string | null;
@@ -66,7 +70,6 @@ interface ChatHeaderProps {
6670
rightPanelOpen: boolean;
6771
gitCwd: string | null;
6872
readonly onOpenPullRequest?: ((number: number) => void) | undefined;
69-
onNewThreadInProject: () => void;
7073
onRunProjectScript: (script: ProjectScript) => void;
7174
onAddProjectScript: (input: NewProjectScriptInput) => Promise<ProjectScriptActionResult>;
7275
onUpdateProjectScript: (
@@ -124,6 +127,7 @@ export const ChatHeader = memo(function ChatHeader({
124127
activeThreadTitle,
125128
isServerThread,
126129
changeRequest,
130+
activeProjectId,
127131
activeProjectName,
128132
activeProjectCwd,
129133
activeProjectFaviconPath,
@@ -135,13 +139,16 @@ export const ChatHeader = memo(function ChatHeader({
135139
rightPanelOpen,
136140
gitCwd,
137141
onOpenPullRequest,
138-
onNewThreadInProject,
139142
onRunProjectScript,
140143
onAddProjectScript,
141144
onUpdateProjectScript,
142145
onDeleteProjectScript,
143146
}: ChatHeaderProps) {
144147
const primaryEnvironmentId = usePrimaryEnvironmentId();
148+
const { environments } = useEnvironments();
149+
const activeEnvironmentLabel = resolveScopeEnvironmentLabel(
150+
environments.find((entry) => entry.environmentId === activeThreadEnvironmentId)?.label,
151+
);
145152
const fileScripts = useT3ProjectFileScripts(
146153
activeThreadEnvironmentId,
147154
activeProjectScripts ? activeProjectCwd : null,
@@ -289,34 +296,30 @@ export const ChatHeader = memo(function ChatHeader({
289296
onContextMenu={handleHeaderContextMenu}
290297
>
291298
<WorkspaceBreadcrumb ariaLabel="Thread breadcrumb" className="flex-1">
292-
{/* The project always leads the header: knowing which project a
293-
thread lives in is priority zero, and the thread title alone
294-
doesn't answer it. */}
295-
{activeProjectName ? (
299+
{/* The path to the thread, widest scope first. Every crumb but the
300+
thread itself is a link to that scope's own page, so the header
301+
answers "where am I" and "show me the rest of it" with the same
302+
row. The environment leads it whenever one resolves: with more
303+
than one server connected, the project name alone does not say
304+
which machine the work is on. */}
305+
{activeEnvironmentLabel === null ? null : (
296306
<>
297-
<WorkspaceBreadcrumbItem>
298-
<Tooltip>
299-
<TooltipTrigger
300-
render={
301-
<button
302-
type="button"
303-
aria-label={`New thread in ${activeProjectName}`}
304-
onClick={onNewThreadInProject}
305-
className="inline-flex min-w-0 cursor-pointer items-center gap-1.5 rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
306-
/>
307-
}
308-
>
309-
<ProjectFavicon
310-
environmentId={activeThreadEnvironmentId}
311-
cwd={activeProjectCwd ?? ""}
312-
faviconPath={activeProjectFaviconPath}
313-
className="size-3.5"
314-
/>
315-
<span className="max-w-40 truncate">{activeProjectName}</span>
316-
</TooltipTrigger>
317-
<TooltipPopup side="top">New thread in {activeProjectName}</TooltipPopup>
318-
</Tooltip>
319-
</WorkspaceBreadcrumbItem>
307+
<EnvironmentCrumb
308+
environmentId={activeThreadEnvironmentId}
309+
label={activeEnvironmentLabel}
310+
/>
311+
<WorkspaceBreadcrumbSeparator />
312+
</>
313+
)}
314+
{activeProjectName && activeProjectId !== null ? (
315+
<>
316+
<ProjectCrumb
317+
environmentId={activeThreadEnvironmentId}
318+
projectId={activeProjectId}
319+
label={activeProjectName}
320+
cwd={activeProjectCwd}
321+
faviconPath={activeProjectFaviconPath}
322+
/>
320323
<WorkspaceBreadcrumbSeparator />
321324
</>
322325
) : null}

0 commit comments

Comments
 (0)