@devries-cameron20 / t3code Mirror · read-only / commits / 77ed46a8aa
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 22:00 UTC

fix(web): keep composer toolbar visible after worktree failure (#14753)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Theo Browne committed Oct 19, 2026 at 22:08 UTC 77ed46a8aac24ea0cd125658cfcb49e0006eb354
5 files changed +36 -28
apps/web/src/components/BranchToolbar.panel.browser.test.tsx
+3 -5
@@ -30,11 +30,6 @@ vi.mock(import("./BranchToolbarBranchSelector"), async (original) => ({
30 }));
31 vi.mock(import("../state/entities"), async (original) => ({
32 ...(await original()),
33 - useQuietThreadShell: (() => ({
34 - environmentId: "local",
35 - projectId: "project",
36 - worktreePath: state.worktreePath,
37 - })) as never,
33 useProject: (() => ({ workspaceRoot: "/tmp/project" })) as never,
34 useThreadShellsForProjectRefs: () => [],
35 }));
@@ -71,6 +66,9 @@ function render(props: Partial<ComponentProps<typeof BranchToolbar>>) {
66 panelSection="workspace"
67 environmentId={EnvironmentId.make("local")}
68 threadId={ThreadId.make("thread")}
69 + projectId={ProjectId.make("project")}
70 + worktreePath={state.worktreePath}
71 + isServerThread
72 showGitControls
73 envMode="local"
74 envLocked={false}
apps/web/src/components/BranchToolbar.tsx
+16 -22
@@ -3,7 +3,7 @@ import { readLocalApi } from "../localApi";
3 import { stackedThreadToast, toastManager } from "./ui/toast";
4 import { ComposerContextLabel } from "./ComposerContextLabel";
5 import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
6 -import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
6 +import type { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
7 import {
8 ChevronDownIcon,
9 FolderGit2Icon,
@@ -25,7 +25,7 @@ import {
25
26 import { useComposerDraftStore, type DraftId } from "../composerDraftStore";
27 import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
28 -import { useProject, useQuietThreadShell, useThreadShellsForProjectRefs } from "../state/entities";
28 +import { useProject, useThreadShellsForProjectRefs } from "../state/entities";
29 import {
30 type EnvMode,
31 type EnvironmentOption,
@@ -83,6 +83,9 @@ interface BranchToolbarProps {
83 ref?: Ref<BranchToolbarHandle>;
84 environmentId: EnvironmentId;
85 threadId: ThreadId;
86 + projectId: ProjectId;
87 + worktreePath: string | null;
88 + isServerThread: boolean;
89 showGitControls: boolean;
90 draftId?: DraftId;
91 onEnvModeChange: (mode: EnvMode) => void;
@@ -571,6 +574,9 @@ export const BranchToolbar = memo(function BranchToolbar({
574 ref,
575 environmentId,
576 threadId,
577 + projectId,
578 + worktreePath,
579 + isServerThread,
580 showGitControls,
581 draftId,
582 onEnvModeChange,
@@ -592,28 +598,16 @@ export const BranchToolbar = memo(function BranchToolbar({
598 }: BranchToolbarProps) {
599 const branchSelectorRef = useRef<BranchToolbarBranchSelectorHandle>(null);
600 const threadRef = scopeThreadRef(environmentId, threadId);
595 - const draftThread = useComposerDraftStore((store) =>
596 - draftId ? store.getDraftSession(draftId) : store.getDraftThreadByRef(threadRef),
597 - );
598 - const serverThread = useQuietThreadShell(threadRef);
601 const setDraftThreadContext = useComposerDraftStore((store) => store.setDraftThreadContext);
600 - const activeProjectRef = serverThread
601 - ? scopeProjectRef(serverThread.environmentId, serverThread.projectId)
602 - : draftThread
603 - ? scopeProjectRef(draftThread.environmentId, draftThread.projectId)
604 - : null;
602 + // The composer retains resolved thread details while bootstrap cleanup can remove its shell.
603 + const activeProjectRef = scopeProjectRef(environmentId, projectId);
604 const activeProject = useProject(activeProjectRef);
606 - const hasActiveThread = serverThread !== null || draftThread !== null;
607 - const activeWorktreePath = forceNewWorktree
608 - ? null
609 - : (serverThread?.worktreePath ?? draftThread?.worktreePath ?? null);
605 + const activeWorktreePath = forceNewWorktree ? null : worktreePath;
606 const effectiveEnvMode = forceNewWorktree ? "worktree" : envMode;
611 - const envModeLocked = envLocked || (serverThread !== null && activeWorktreePath !== null);
607 + const envModeLocked = envLocked || (isServerThread && activeWorktreePath !== null);
608
613 - const canUsePreviousWorktree =
614 - draftThread !== null && serverThread === null && !envModeLocked && !forceNewWorktree;
615 - const projectRefsForWorktreeLookup =
616 - canUsePreviousWorktree && activeProjectRef ? [activeProjectRef] : [];
609 + const canUsePreviousWorktree = !isServerThread && !envModeLocked && !forceNewWorktree;
610 + const projectRefsForWorktreeLookup = canUsePreviousWorktree ? [activeProjectRef] : [];
611 const projectThreads = useThreadShellsForProjectRefs(projectRefsForWorktreeLookup);
612 const previousWorktreeSeed = canUsePreviousWorktree
613 ? resolvePreviousWorktreeSeed({
@@ -625,7 +619,7 @@ export const BranchToolbar = memo(function BranchToolbar({
619 ? resolvePreviousWorktreeLabel(previousWorktreeSeed)
620 : null;
621 const onUsePreviousWorktree = () => {
628 - if (!previousWorktreeSeed || !activeProjectRef) return;
622 + if (!previousWorktreeSeed) return;
623 setDraftThreadContext(draftId ?? threadRef, {
624 branch: previousWorktreeSeed.branch,
625 worktreePath: previousWorktreeSeed.worktreePath,
@@ -667,7 +661,7 @@ export const BranchToolbar = memo(function BranchToolbar({
661 const [stripElement, setStripElement] = useState<HTMLDivElement | null>(null);
662 const labelsOverflow = useLabelsOverflow(stripElement);
663
670 - if (!hasActiveThread || !activeProject) return null;
664 + if (!activeProject) return null;
665
666 if (layout === "panel") {
667 return (
apps/web/src/components/ChatView.tsx
+6
@@ -8434,6 +8434,9 @@ export default function ChatView(props: ChatViewProps) {
8434 ref={branchToolbarRef}
8435 environmentId={activeThread.environmentId}
8436 threadId={activeThread.id}
8437 + projectId={activeThread.projectId}
8438 + worktreePath={activeThread.worktreePath}
8439 + isServerThread={isServerThread}
8440 showGitControls={isGitRepo}
8441 {...(routeKind === "draft" && draftId ? { draftId } : {})}
8442 onEnvModeChange={onEnvModeChangeStable}
@@ -8511,6 +8514,9 @@ export default function ChatView(props: ChatViewProps) {
8514 forceNewWorktree={multipleModelSelections !== null}
8515 environmentId={activeThread.environmentId}
8516 threadId={activeThread.id}
8517 + projectId={activeThread.projectId}
8518 + worktreePath={activeThread.worktreePath}
8519 + isServerThread={isServerThread}
8520 {...(draftId ? { draftId } : {})}
8521 activeProjectName={activeProject?.title}
8522 activeProjectScripts={activeProject ? activeProjectScripts : undefined}
apps/web/src/components/chat/ThreadDetailsPanel.tsx
+7
@@ -1,6 +1,7 @@
1 import type {
2 EditorId,
3 EnvironmentId,
4 + ProjectId,
5 ProjectScript,
6 ResolvedKeybindingsConfig,
7 ThreadId,
@@ -31,6 +32,9 @@ export interface ThreadDetailsPanelProps extends Pick<
32 forceNewWorktree?: boolean;
33 environmentId: EnvironmentId;
34 threadId: ThreadId;
35 + projectId: ProjectId;
36 + worktreePath: string | null;
37 + isServerThread: boolean;
38 draftId?: DraftId;
39 activeProjectName: string | undefined;
40 activeProjectScripts: ReadonlyArray<ProjectScript> | undefined;
@@ -74,6 +78,9 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
78 showGitControls: props.isGitRepo,
79 environmentId: props.environmentId,
80 threadId: props.threadId,
81 + projectId: props.projectId,
82 + worktreePath: props.worktreePath,
83 + isServerThread: props.isServerThread,
84 ...(props.draftId ? { draftId: props.draftId } : {}),
85 onEnvModeChange: props.onEnvModeChange,
86 startFromOrigin: props.startFromOrigin,
apps/web/src/components/chat/ThreadDetailsPrRows.browser.test.tsx
+4 -1
@@ -1,4 +1,4 @@
1 -import { EnvironmentId, ThreadId, type ThreadPullRequestLink } from "@t3tools/contracts";
1 +import { EnvironmentId, ProjectId, ThreadId, type ThreadPullRequestLink } from "@t3tools/contracts";
2 import { act, type ComponentProps } from "react";
3 import { createRoot, type Root } from "react-dom/client";
4 import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
@@ -235,6 +235,9 @@ it("keeps workspace controls after expanding and collapsing 70 linked pull reque
235 root.render(
236 <ThreadDetailsPanel
237 {...threadRef}
238 + projectId={ProjectId.make("project")}
239 + worktreePath={null}
240 + isServerThread
241 anchor={{ current: null }}
242 handle={PopoverCreateHandle()}
243 onPresentationChange={vi.fn()}