diff --git a/apps/mobile/src/state/use-thread-composer-state.ts b/apps/mobile/src/state/use-thread-composer-state.ts
index bf296007bb..f742f3b96f 100644
--- a/apps/mobile/src/state/use-thread-composer-state.ts
+++ b/apps/mobile/src/state/use-thread-composer-state.ts
@@ -123,11 +123,7 @@ export function useThreadComposerState() {
return null;
}
- return deriveActiveWorkStartedAt(
- selectedThread.latestRun,
- selectedThreadSessionActivity,
- null,
- );
+ return deriveActiveWorkStartedAt(selectedThread.latestRun, selectedThreadSessionActivity, null);
}, [selectedThreadDetail, selectedThreadSessionActivity, selectedThreadShell]);
const activeThreadBusy = !!selectedThread && threadRuntimeIsActive(selectedThread.runtime);
diff --git a/apps/web/src/components/BranchToolbar.logic.test.ts b/apps/web/src/components/BranchToolbar.logic.test.ts
index 251b076881..bee0a686d9 100644
--- a/apps/web/src/components/BranchToolbar.logic.test.ts
+++ b/apps/web/src/components/BranchToolbar.logic.test.ts
@@ -13,10 +13,7 @@ import {
resolveBranchToolbarPrBranch,
resolveBranchToolbarValue,
resolveLockedWorkspaceLabel,
- resolveLocalCheckoutBranchMismatch,
- resolvePreviousWorktreeLabel,
- resolvePreviousWorktreeSeed,
- sanitizeNewRefName,
+ resolveWorkspaceDisplayName,
shouldIncludeBranchPickerItem,
shouldShowComposerContextStrip,
shouldShowEnvironmentIndicator,
@@ -504,6 +501,18 @@ describe("resolveLockedWorkspaceLabel", () => {
});
});
+describe("resolveWorkspaceDisplayName", () => {
+ it("returns the final folder for POSIX and Windows paths", () => {
+ expect(resolveWorkspaceDisplayName("/repo/.t3/worktrees/feature-a")).toBe("feature-a");
+ expect(resolveWorkspaceDisplayName("C:\\code\\project\\feature-b\\")).toBe("feature-b");
+ });
+
+ it("handles missing and root paths", () => {
+ expect(resolveWorkspaceDisplayName(null)).toBeNull();
+ expect(resolveWorkspaceDisplayName("/")).toBe("/");
+ });
+});
+
describe("deriveLocalBranchNameFromRemoteRef", () => {
it("strips the remote prefix from a remote ref", () => {
expect(deriveLocalBranchNameFromRemoteRef("origin/feature/demo")).toBe("feature/demo");
@@ -730,93 +739,4 @@ describe("shouldIncludeBranchPickerItem", () => {
}),
).toBe(false);
});
-
- // Typing a spaced name must still surface the ref it would have been created
- // as, or the picker shows nothing at all for that query.
- it("surfaces an existing ref matching the sanitized query", () => {
- expect(
- shouldIncludeBranchPickerItem({
- itemValue: "new-branch",
- normalizedQuery: "new branch",
- createBranchItemValue: null,
- checkoutPullRequestItemValue: null,
- }),
- ).toBe(true);
- });
-
- // A partial query has to reach the ref it would have been created as, so
- // searching "hello w" still finds an existing hello-world.
- it("surfaces a ref from a partial query containing a space", () => {
- expect(
- shouldIncludeBranchPickerItem({
- itemValue: "hello-world",
- normalizedQuery: "hello w",
- createBranchItemValue: null,
- checkoutPullRequestItemValue: null,
- }),
- ).toBe(true);
- });
-
- it("excludes refs matching neither the raw nor the sanitized query", () => {
- expect(
- shouldIncludeBranchPickerItem({
- itemValue: "main",
- normalizedQuery: "new branch",
- createBranchItemValue: null,
- checkoutPullRequestItemValue: null,
- }),
- ).toBe(false);
- });
-});
-
-// Git rejects ASCII space and the ASCII control characters in ref names, so a
-// typed name like "new branch" can only ever fail. Replacing exactly those can
-// turn a failing name into a working one without touching a name git already
-// accepts, including one holding non-ASCII whitespace such as U+00A0.
-describe("sanitizeNewRefName", () => {
- it("replaces a space with a dash", () => {
- expect(sanitizeNewRefName("new branch")).toBe("new-branch");
- });
-
- it("collapses a run of whitespace into a single dash", () => {
- expect(sanitizeNewRefName("new branch")).toBe("new-branch");
- });
-
- it("trims surrounding whitespace instead of turning it into dashes", () => {
- expect(sanitizeNewRefName(" new branch ")).toBe("new-branch");
- });
-
- it("replaces tabs, which git rejects just like spaces", () => {
- expect(sanitizeNewRefName("new\tbranch")).toBe("new-branch");
- });
-
- // git accepts U+00A0, U+2009 and other non-ASCII whitespace in ref names, so
- // rewriting them would silently create a ref the user never typed.
- it("preserves whitespace that git accepts", () => {
- expect(sanitizeNewRefName("new\u00a0branch")).toBe("new\u00a0branch");
- expect(sanitizeNewRefName("new\u2009branch")).toBe("new\u2009branch");
- });
-
- it("keeps slashes so nested ref names survive", () => {
- expect(sanitizeNewRefName("feature/new thing")).toBe("feature/new-thing");
- });
-
- it("preserves case because git ref names are case sensitive", () => {
- expect(sanitizeNewRefName("Feature/New Thing")).toBe("Feature/New-Thing");
- });
-
- it("leaves an already valid ref name untouched", () => {
- expect(sanitizeNewRefName("feature/login")).toBe("feature/login");
- });
-
- it("returns an empty string for whitespace-only input", () => {
- expect(sanitizeNewRefName(" ")).toBe("");
- });
-
- // Scoped deliberately to whitespace: git accepts consecutive dashes, so
- // collapsing them would rewrite names the user may have typed on purpose.
- it("does not collapse dashes the user typed", () => {
- expect(sanitizeNewRefName("new - branch")).toBe("new---branch");
- expect(sanitizeNewRefName("foo--bar")).toBe("foo--bar");
- });
});
diff --git a/apps/web/src/components/BranchToolbar.logic.ts b/apps/web/src/components/BranchToolbar.logic.ts
index 0a8e07d195..a9bf3862a4 100644
--- a/apps/web/src/components/BranchToolbar.logic.ts
+++ b/apps/web/src/components/BranchToolbar.logic.ts
@@ -74,51 +74,11 @@ export function resolveLockedWorkspaceLabel(activeWorktreePath: string | null):
return activeWorktreePath ? "Worktree" : "Local checkout";
}
-export interface PreviousWorktreeSeed {
- branch: string | null;
- worktreePath: string;
-}
-
-// The most recently touched worktree in the project that the composer isn't
-// already pointing at. Backs the "Previous worktree" entry in the workspace
-// selector so a follow-up thread can hop back into the worktree you just
-// worked in without hunting for its branch. Archived threads don't compete —
-// the rest of the UI hides them, so their worktrees shouldn't resurface here.
-export function resolvePreviousWorktreeSeed(input: {
- threads: ReadonlyArray<{
- branch: string | null;
- worktreePath: string | null;
- updatedAt: string;
- archivedAt?: string | null;
- }>;
- currentWorktreePath: string | null;
-}): PreviousWorktreeSeed | null {
- let latest: { branch: string | null; worktreePath: string; updatedAt: number } | null = null;
- for (const thread of input.threads) {
- if (
- !thread.worktreePath ||
- thread.worktreePath === input.currentWorktreePath ||
- (thread.archivedAt ?? null) !== null
- ) {
- continue;
- }
- const updatedAt = toSortableTimestamp(thread.updatedAt);
- if (updatedAt === null) {
- continue;
- }
- if (latest === null || updatedAt > latest.updatedAt) {
- latest = {
- branch: thread.branch,
- worktreePath: thread.worktreePath,
- updatedAt,
- };
- }
- }
- return latest === null ? null : { branch: latest.branch, worktreePath: latest.worktreePath };
-}
-
-export function resolvePreviousWorktreeLabel(seed: PreviousWorktreeSeed): string {
- return seed.branch ? `Previous worktree (${seed.branch})` : "Previous worktree";
+export function resolveWorkspaceDisplayName(path: string | null): string | null {
+ if (!path) return null;
+ const normalizedPath = path.replace(/[\\/]+$/, "");
+ if (normalizedPath.length === 0) return path;
+ return normalizedPath.split(/[\\/]/).at(-1) ?? normalizedPath;
}
export function resolveEffectiveEnvMode(input: {
diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx
index 5d11cce11f..c0be2df8e3 100644
--- a/apps/web/src/components/BranchToolbar.tsx
+++ b/apps/web/src/components/BranchToolbar.tsx
@@ -42,6 +42,8 @@ import {
import { Separator } from "./ui/separator";
interface BranchToolbarProps {
+ layout?: "composer" | "panel";
+ panelSection?: "all" | "workspace" | "branch";
environmentId: EnvironmentId;
threadId: ThreadId;
showGitControls: boolean;
@@ -374,6 +376,8 @@ function useLabelsOverflow(element: HTMLDivElement | null): boolean {
}
export const BranchToolbar = memo(function BranchToolbar({
+ layout = "composer",
+ panelSection = "all",
environmentId,
threadId,
showGitControls,
@@ -465,6 +469,40 @@ export const BranchToolbar = memo(function BranchToolbar({
if (!hasActiveThread || !activeProject) return null;
+ if (layout === "panel") {
+ return (
+
+ {panelSection !== "branch" ? (
+
+ ) : null}
+ {panelSection !== "workspace" ? (
+
+ ) : null}
+
+ );
+ }
+
return (
{branchPr && branchPrStatus ? (
@@ -752,35 +761,39 @@ export function BranchToolbarBranchSelector({
{branchPrTooltip}
) : null}
- {/* Context menu lives on the wrapper: the disabled Button has
- pointer-events-none, so the trigger itself never sees right-clicks
- while refs are loading or a branch action is pending. */}
- handleBranchContextMenu(event, resolvedActiveBranch)}
+ }
+ className={cn(
+ "min-w-0 text-muted-foreground/70 hover:text-foreground/80",
+ displayMode === "panel" && THREAD_DETAILS_PANEL_ROW_CLASS,
+ )}
+ disabled={isInitialBranchesLoadPending || isBranchActionPending}
>
- }
- className="min-w-0 max-w-full text-muted-foreground/70 hover:text-foreground/80"
- disabled={isInitialBranchesLoadPending || isBranchActionPending}
+
+
-
-
-
- {triggerLabel}
-
-
-
-
-
+ {triggerLabel}
+
+
+
-
+
void;
- previousWorktreeLabel?: string | null;
- onUsePreviousWorktree?: () => void;
+ displayMode?: "toolbar" | "panel";
}
export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSelector({
envLocked,
effectiveEnvMode,
activeWorktreePath,
+ workspaceRoot = null,
onEnvModeChange,
- previousWorktreeLabel,
- onUsePreviousWorktree,
+ displayMode = "toolbar",
}: BranchToolbarEnvModeSelectorProps) {
- const showPreviousWorktree = Boolean(previousWorktreeLabel && onUsePreviousWorktree);
+ const workspacePath = displayMode === "panel" ? (activeWorktreePath ?? workspaceRoot) : null;
+ const workspaceDisplayName = resolveWorkspaceDisplayName(workspacePath);
+ const workspaceKind = activeWorktreePath ? "Worktree" : "Project folder";
const envModeItems = useMemo(
() => [
- { value: "local", label: resolveCurrentWorkspaceLabel(activeWorktreePath) },
+ {
+ value: "local",
+ label: workspaceDisplayName ?? resolveCurrentWorkspaceLabel(activeWorktreePath),
+ },
{ value: "worktree", label: resolveEnvModeLabel("worktree") },
...(showPreviousWorktree && previousWorktreeLabel
? [{ value: PREVIOUS_WORKTREE_SELECT_VALUE, label: previousWorktreeLabel }]
: []),
],
- [activeWorktreePath, previousWorktreeLabel, showPreviousWorktree],
+ [activeWorktreePath, workspaceDisplayName],
);
if (envLocked) {
+<<<<<<< HEAD
return (
-
+
{activeWorktreePath ? (
<>
@@ -64,9 +75,43 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
{resolveLockedWorkspaceLabel(activeWorktreePath)}
>
+=======
+ const lockedRow = (
+ >>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
)}
+ >
+ {activeWorktreePath ? (
+
+ ) : (
+
+ )}
+
+ {workspaceDisplayName ?? resolveLockedWorkspaceLabel(activeWorktreePath)}
+
+ {displayMode === "panel" ? (
+
+ {workspaceKind}
+
+ ) : null}
);
+
+ if (!workspacePath) return lockedRow;
+
+ return (
+
+
+ {workspacePath}
+
+ );
}
return (
@@ -82,32 +127,51 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
}}
items={envModeItems}
>
-
- {effectiveEnvMode === "worktree" ? (
-
- ) : activeWorktreePath ? (
-
- ) : (
-
- )}
-
+
+ }
>
+ {effectiveEnvMode === "worktree" ? (
+
+ ) : activeWorktreePath ? (
+
+ ) : (
+
+ )}
-
-
+ {displayMode === "panel" ? (
+
+ {effectiveEnvMode === "worktree" && !activeWorktreePath ? "Create" : workspaceKind}
+
+ ) : null}
+
+ {workspacePath ? {workspacePath} : null}
+
Workspace
diff --git a/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx b/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx
index b5d5751a28..beb0d723bc 100644
--- a/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx
+++ b/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx
@@ -3,6 +3,12 @@ import { CloudIcon, MonitorIcon } from "lucide-react";
import { memo, useMemo } from "react";
import type { EnvironmentOption } from "./BranchToolbar.logic";
+import { cn } from "../lib/utils";
+import {
+ THREAD_DETAILS_PANEL_ICON_CLASS,
+ THREAD_DETAILS_PANEL_LOCKED_ROW_CLASS,
+ THREAD_DETAILS_PANEL_ROW_CLASS,
+} from "./chat/threadDetailsPanelStyles";
import {
Select,
SelectGroup,
@@ -17,9 +23,8 @@ interface BranchToolbarEnvironmentSelectorProps {
envLocked: boolean;
environmentId: EnvironmentId;
availableEnvironments: readonly EnvironmentOption[];
- // Absent when there is only one environment to show: the indicator still
- // renders (as a static label) so remote projects are always identifiable.
- onEnvironmentChange?: (environmentId: EnvironmentId) => void;
+ onEnvironmentChange: (environmentId: EnvironmentId) => void;
+ displayMode?: "toolbar" | "panel";
}
export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvironmentSelector({
@@ -27,6 +32,7 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
environmentId,
availableEnvironments,
onEnvironmentChange,
+ displayMode = "toolbar",
}: BranchToolbarEnvironmentSelectorProps) {
const activeEnvironment = useMemo(() => {
return availableEnvironments.find((env) => env.environmentId === environmentId) ?? null;
@@ -48,25 +54,30 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
// only thing in the strip.
if (envLocked || onEnvironmentChange === undefined) {
return (
+<<<<<<< HEAD
+
+=======
+>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
{activeEnvironment?.isPrimary ? (
-
+
) : (
-
+
)}
-
- {activeEnvironment?.label ?? "Run on"}
-
+ {activeEnvironment?.label ?? "Run on"}
);
@@ -81,26 +92,24 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
>
{activeEnvironment?.isPrimary ? (
-
+
) : (
-
+
)}
-
-
-
+
diff --git a/apps/web/src/components/ChatView.logic.ts b/apps/web/src/components/ChatView.logic.ts
index 064a13dabd..4a8386f914 100644
--- a/apps/web/src/components/ChatView.logic.ts
+++ b/apps/web/src/components/ChatView.logic.ts
@@ -17,6 +17,7 @@ import { type ComposerImageAttachment, type DraftThreadState } from "../composer
import * as Schema from "effect/Schema";
import { appAtomRegistry } from "../rpc/atomRegistry";
import { environmentThreadDetails } from "../state/threads";
+import { waitForAtomValue } from "../state/waitForAtomValue";
import {
filterTerminalContextsWithText,
stripInlineTerminalContextPlaceholders,
@@ -467,43 +468,11 @@ export async function waitForStartedServerThread(
timeoutMs = 1_000,
): Promise {
const threadAtom = environmentThreadDetails.detailAtom(threadRef);
- const getThread = () => appAtomRegistry.get(threadAtom);
- const thread = getThread();
-
- if (threadHasStarted(thread)) {
- return true;
- }
-
- return await new Promise((resolve) => {
- let settled = false;
- let timeoutId: ReturnType | null = null;
- const finish = (result: boolean) => {
- if (settled) {
- return;
- }
- settled = true;
- if (timeoutId !== null) {
- globalThis.clearTimeout(timeoutId);
- }
- unsubscribe();
- resolve(result);
- };
-
- const unsubscribe = appAtomRegistry.subscribe(threadAtom, (thread) => {
- if (!threadHasStarted(thread)) {
- return;
- }
- finish(true);
- });
-
- if (threadHasStarted(getThread())) {
- finish(true);
- return;
- }
-
- timeoutId = globalThis.setTimeout(() => {
- finish(false);
- }, timeoutMs);
+ return waitForAtomValue({
+ registry: appAtomRegistry,
+ atom: threadAtom,
+ predicate: threadHasStarted,
+ timeoutMs,
});
}
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 9ab71ee105..6940b35080 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -22,15 +22,7 @@ import {
TerminalOpenInput,
} from "@t3tools/contracts";
import type { ThreadWorkEntry } from "@t3tools/client-runtime/state/shell";
-import {
- connectionStatusTitle,
- type EnvironmentConnectionPresentation,
-} from "@t3tools/client-runtime/connection";
-import {
- effectiveSettled,
- effectiveSnoozed,
- threadWokeAt,
-} from "@t3tools/client-runtime/state/thread-settled";
+import { type EnvironmentConnectionPresentation } from "@t3tools/client-runtime/connection";
import {
parseScopedThreadKey,
scopedThreadKey,
@@ -123,10 +115,16 @@ import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries";
import { isCommandPaletteOpen } from "../commandPaletteBus";
import { buildTemporaryWorktreeBranchName } from "@t3tools/shared/git";
import { useMediaQuery } from "../hooks/useMediaQuery";
-import { RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY } from "../rightPanelLayout";
+import { useElementWidth } from "../hooks/useElementWidth";
+import { usePreviewPanelInlineSize } from "../hooks/usePreviewPanelInlineSize";
+import {
+ RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY,
+ resolveThreadPanelPresentation,
+} from "../rightPanelLayout";
import {
selectActiveRightPanel,
selectActiveRightPanelSurface,
+ selectThreadPanelOpen,
selectThreadRightPanelState,
type RightPanelSurface,
updatePullRequestTabStatus,
@@ -157,16 +155,9 @@ import {
foldSubagentActivities,
} from "@t3tools/client-runtime/state/subagentRuntime";
import { DiffWorkerPoolProvider } from "./DiffWorkerPoolProvider";
-import { BranchToolbar } from "./BranchToolbar";
import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings";
import ThreadTerminalDrawer from "./ThreadTerminalDrawer";
-import {
- AlarmClockIcon,
- CheckCircle2Icon,
- ChevronDownIcon,
- GitBranchIcon,
- WifiOffIcon,
-} from "lucide-react";
+import { ChevronDownIcon } from "lucide-react";
import { cn, randomHex } from "~/lib/utils";
import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar";
import { stackedThreadToast, toastManager } from "./ui/toast";
@@ -245,6 +236,7 @@ import {
useThreadProposedPlans,
useThreadRefs,
useThreadVisibleTurnItems,
+ waitForThreadShell,
} from "../state/entities";
import { environmentShell } from "../state/shell";
import { ChatComposer, type ChatComposerHandle } from "./chat/ChatComposer";
@@ -254,8 +246,13 @@ import { PullRequestThreadDialog } from "./PullRequestThreadDialog";
import { MessagesTimeline } from "./chat/MessagesTimeline";
import { resolveTimelineIsAtEnd } from "./chat/MessagesTimeline.logic";
import { ChatHeader } from "./chat/ChatHeader";
-import { PanelLayoutControls, RightPanelMaximizeControl } from "./chat/PanelLayoutControls";
+import {
+ PanelLayoutControls,
+ type PanelLayoutControlsProps,
+ RightPanelMaximizeControl,
+} from "./chat/PanelLayoutControls";
import { type ExpandedImagePreview } from "./chat/ExpandedImagePreview";
+import { ThreadDetailsPanel, type ThreadDetailsPanelProps } from "./chat/ThreadDetailsPanel";
import { NoActiveThreadState } from "./NoActiveThreadState";
import {
resolveEffectiveEnvMode,
@@ -319,7 +316,6 @@ import { sanitizeThreadErrorMessage } from "~/rpc/transportError";
import { RightPanelSheet } from "./RightPanelSheet";
import { previewEnvironment } from "../state/preview";
import { useAtomCommand } from "../state/use-atom-command";
-import { Button } from "./ui/button";
import {
AlertDialog,
AlertDialogClose,
@@ -1342,7 +1338,15 @@ function ChatViewContent(props: ChatViewProps) {
>({});
const [pendingUserInputQuestionIndexByRequestId, setPendingUserInputQuestionIndexByRequestId] =
useState>({});
- const shouldUseRightPanelSheet = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY);
+ const shouldUsePlanSidebarSheet = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY);
+ const [workspaceLayoutRef, workspaceLayoutWidth] = useElementWidth();
+ const previewPanelInlineSize = usePreviewPanelInlineSize();
+ const threadPanelPopoverAnchorRef = useRef(null);
+ // Tracks whether the user explicitly dismissed the sidebar for the active turn.
+ const planSidebarDismissedForTurnRef = useRef(null);
+ // When set, the thread-change reset effect will open the sidebar instead of closing it.
+ // Used by "Implement in a new thread" to carry the sidebar-open intent across navigation.
+ const planSidebarOpenOnNextThreadRef = useRef(false);
const [terminalFocusRequestId, setTerminalFocusRequestId] = useState(0);
const [pullRequestDialogState, setPullRequestDialogState] =
useState(null);
@@ -1639,7 +1643,19 @@ function ChatViewContent(props: ChatViewProps) {
const canMaximizeRightPanel = rightPanelOpen && !shouldUseRightPanelSheet;
const rightPanelMaximized =
canMaximizeRightPanel && maximizedRightPanelThreadKey === routeThreadKey;
- const inlineRightPanelOwnsTitleBar = rightPanelOpen && !shouldUseRightPanelSheet;
+ const inlineRightPanelOwnsTitleBar = rightPanelOpen && !shouldUsePlanSidebarSheet;
+ const threadPanelPresentation = resolveThreadPanelPresentation(
+ workspaceLayoutWidth,
+ inlineRightPanelOwnsTitleBar ? previewPanelInlineSize.width : 0,
+ rightPanelMaximized,
+ );
+ const threadPanelOpen = useRightPanelStore((state) =>
+ selectThreadPanelOpen(
+ state.threadPanelVisibilityByThreadKey,
+ activeThreadRef,
+ threadPanelPresentation,
+ ),
+ );
useEffect(() => {
if (!activeThreadRef) return;
@@ -1872,16 +1888,6 @@ function ChatViewContent(props: ChatViewProps) {
});
return envs;
}, [activeProject, allProjects, projectGroupingSettings, primaryEnvironmentId, environmentById]);
- const hasMultipleEnvironments = logicalProjectEnvironments.length > 1;
- const activeEnvironmentOption =
- logicalProjectEnvironments.find(
- (environment) => environment.environmentId === activeThread?.environmentId,
- ) ?? null;
- const showComposerEnvironmentIndicator = shouldShowEnvironmentIndicator({
- activeEnvironment: activeEnvironmentOption,
- canPickEnvironment: hasMultipleEnvironments,
- });
-
const openPullRequestDialog = useCallback(
(reference?: string) => {
if (!canCheckoutPullRequestIntoThread) {
@@ -2188,6 +2194,18 @@ function ChatViewContent(props: ChatViewProps) {
versionMismatchSelfUpdate,
versionMismatchServerLabel,
]);
+ const reconnectActiveEnvironment = useCallback(() => {
+ if (!activeEnvironmentUnavailableState) return;
+ void handleReconnectActiveEnvironment(activeEnvironmentUnavailableState.environmentId);
+ }, [activeEnvironmentUnavailableState, handleReconnectActiveEnvironment]);
+ const openConnectionSettings = useCallback(() => {
+ void navigate({ to: "/settings/connections" });
+ }, [navigate]);
+ const handleDismissVersionMismatch = useCallback(() => {
+ if (!versionMismatchDismissKey) return;
+ dismissVersionMismatch(versionMismatchDismissKey);
+ setDismissedVersionMismatchKey(versionMismatchDismissKey);
+ }, [setDismissedVersionMismatchKey, versionMismatchDismissKey]);
const providerStatuses = serverConfig?.providers ?? EMPTY_PROVIDERS;
const unlockedSelectedProvider = resolveSelectableProvider(
providerStatuses,
@@ -3288,6 +3306,9 @@ function ChatViewContent(props: ChatViewProps) {
useRightPanelStore.getState().open(activeThreadRef, "diff");
onDiffPanelOpen?.();
}, [activeThreadRef, isGitRepo, isServerThread, onDiffPanelOpen]);
+ const openChangesFromThreadPanel = useCallback(() => {
+ addDiffSurface();
+ }, [addDiffSurface]);
const addFilesSurface = useCallback(() => {
if (!activeThreadRef || !activeProject) return;
useRightPanelStore.getState().open(activeThreadRef, "files");
@@ -3464,7 +3485,15 @@ function ChatViewContent(props: ChatViewProps) {
return;
}
useRightPanelStore.getState().toggleVisibility(activeThreadRef);
- }, [activeThreadRef, closePreviewPanel, rightPanelOpen]);
+ }, [activeThreadRef, closePlanSidebar, closePreviewPanel, planSidebarOpen, rightPanelOpen]);
+ const toggleThreadPanel = useCallback(() => {
+ if (!activeThreadRef) return;
+ useRightPanelStore.getState().toggleThreadPanel(activeThreadRef, threadPanelPresentation);
+ }, [activeThreadRef, threadPanelPresentation]);
+ const closeThreadPanelPopover = useCallback(() => {
+ if (!activeThreadRef) return;
+ useRightPanelStore.getState().setThreadPanelOpen(activeThreadRef, "popover", false);
+ }, [activeThreadRef]);
const toggleRightPanelMaximized = useCallback(() => {
if (!canMaximizeRightPanel) return;
setMaximizedRightPanelThreadKey((threadKey) =>
@@ -4752,6 +4781,13 @@ function ChatViewContent(props: ChatViewProps) {
return;
}
+ if (command === "threadPanel.toggle") {
+ event.preventDefault();
+ event.stopPropagation();
+ toggleThreadPanel();
+ return;
+ }
+
if (command === "terminal.split") {
event.preventDefault();
event.stopPropagation();
@@ -4847,6 +4883,7 @@ function ChatViewContent(props: ChatViewProps) {
keybindings,
onToggleDiff,
toggleRightPanel,
+ toggleThreadPanel,
toggleTerminalVisibility,
composerRef,
]);
@@ -4981,6 +5018,7 @@ function ChatViewContent(props: ChatViewProps) {
async (input: { readonly sourceThreadId: ThreadId; readonly runId: RunId }) => {
if (!activeThread || activeEnvironmentUnavailable) return;
const targetThreadId = newThreadId();
+ const targetThreadRef = scopeThreadRef(environmentId, targetThreadId);
const result = await forkThreadFromRun({
environmentId,
input: {
@@ -5000,9 +5038,17 @@ function ChatViewContent(props: ChatViewProps) {
}
return;
}
+ const targetThreadReady = await waitForThreadShell(targetThreadRef);
+ if (!targetThreadReady) {
+ setThreadError(
+ activeThread.id,
+ "The fork was created, but its thread data did not reach this client. Reconnect and try opening it from the sidebar.",
+ );
+ return;
+ }
await navigate({
to: "/$environmentId/$threadId",
- params: buildThreadRouteParams(scopeThreadRef(environmentId, targetThreadId)),
+ params: buildThreadRouteParams(targetThreadRef),
});
},
[
@@ -5826,6 +5872,8 @@ function ChatViewContent(props: ChatViewProps) {
setComposerDraftInteractionMode,
setThreadError,
startThreadTurn,
+ activeThreadRef,
+ autoOpenPlanSidebar,
environmentId,
composerRef,
],
@@ -6159,41 +6207,6 @@ function ChatViewContent(props: ChatViewProps) {
return ;
}
- const panelToggleControls = (
-
- );
- const panelLayoutControls = (
-
- {rightPanelOpen && !shouldUseRightPanelSheet ? (
-
- ) : null}
- {panelToggleControls}
-
- );
const rightPanelContent = activeThreadRef ? (
activeRightPanelSurface?.kind === "preview" ? (
@@ -6306,10 +6319,117 @@ function ChatViewContent(props: ChatViewProps) {
) : null
) : null;
+ const threadDetailsPanelProps: Omit = {
+ environmentId: activeThread.environmentId,
+ environmentConnection: activeEnvironment?.connection ?? null,
+ threadId: activeThread.id,
+ ...(draftId ? { draftId } : {}),
+ activeProjectName: activeProject?.title,
+ activeProjectScripts: activeProject?.scripts,
+ preferredScriptId: activeProject
+ ? (lastInvokedScriptByProjectId[activeProject.id] ?? null)
+ : null,
+ keybindings,
+ gitCwd,
+ isGitRepo,
+ envLocked,
+ availableEnvironments: logicalProjectEnvironments,
+ onEnvironmentChange,
+ onEnvModeChange,
+ ...(canOverrideServerThreadEnvMode ? { effectiveEnvModeOverride: envMode } : {}),
+ ...(canOverrideServerThreadEnvMode
+ ? {
+ activeThreadBranchOverride: activeThreadBranch,
+ onActiveThreadBranchOverrideChange: setPendingServerThreadBranch,
+ }
+ : {}),
+ startFromOrigin,
+ onStartFromOriginChange,
+ ...(canCheckoutPullRequestIntoThread
+ ? { onCheckoutPullRequestRequest: openPullRequestDialog }
+ : {}),
+ onComposerFocusRequest: scheduleComposerFocus,
+ ...(isServerThread && isGitRepo ? { onOpenChanges: openChangesFromThreadPanel } : {}),
+ onReconnectEnvironment: reconnectActiveEnvironment,
+ onOpenConnectionSettings: openConnectionSettings,
+ versionMismatch:
+ showVersionMismatchBanner && versionMismatch
+ ? {
+ clientVersion: versionMismatch.clientVersion,
+ serverVersion: versionMismatch.serverVersion,
+ serverLabel: versionMismatchServerLabel,
+ }
+ : null,
+ onDismissVersionMismatch: handleDismissVersionMismatch,
+ onRunProjectScript: runProjectScript,
+ onAddProjectScript: saveProjectScript,
+ onUpdateProjectScript: updateProjectScript,
+ onDeleteProjectScript: deleteProjectScript,
+ };
+ const panelToggleControlProps = {
+ terminalAvailable: activeProject !== null,
+ terminalOpen: terminalUiState.terminalOpen,
+ terminalShortcutLabel: shortcutLabelForCommand(keybindings, "terminal.toggle"),
+ threadPanelOpen,
+ threadPanelPresentation,
+ threadPanelPopoverAnchor: threadPanelPopoverAnchorRef,
+ ...(threadPanelPresentation === "popover"
+ ? {
+ threadPanelPopoverContent: (
+
+ ),
+ }
+ : {}),
+ threadPanelShortcutLabel: shortcutLabelForCommand(keybindings, "threadPanel.toggle"),
+ threadPanelHasAttention:
+ activeEnvironmentUnavailableState !== null || showVersionMismatchBanner,
+ rightPanelAvailable: activeProject !== null,
+ rightPanelOpen,
+ rightPanelShortcutLabel: shortcutLabelForCommand(keybindings, "rightPanel.toggle"),
+ onToggleTerminal: toggleTerminalVisibility,
+ onToggleThreadPanel: toggleThreadPanel,
+ onToggleRightPanel: toggleRightPanel,
+ } satisfies PanelLayoutControlsProps;
+ const panelToggleControls = (
+
+ );
+ const threadPanelHeaderControl = (
+
+ );
+ const panelLayoutControls = (
+
+ {rightPanelOpen && !shouldUsePlanSidebarSheet ? (
+
+ ) : null}
+ {panelToggleControls}
+
+ );
return (
-
- {rightPanelOpen && !shouldUseRightPanelSheet ? panelLayoutControls : null}
+
+ {isElectron && activeThreadRef ? (
+
+ ) : null}
+ {rightPanelOpen && !shouldUsePlanSidebarSheet ? panelLayoutControls : null}
{/* Top bar */}
- {!rightPanelOpen ? panelLayoutControls : null}
+ {inlineRightPanelOwnsTitleBar
+ ? threadPanelHeaderControl
+ : !rightPanelOpen
+ ? panelLayoutControls
+ : null}
@@ -6470,7 +6583,6 @@ function ChatViewContent(props: ChatViewProps) {
threadId={activeThread.id}
/>
) : null}
-
+
{activeThreadRef && activePreviewMiniPlayer ? (
@@ -6607,6 +6720,9 @@ function ChatViewContent(props: ChatViewProps) {
) : null}
{/* end chat column */}
+ {threadPanelOpen && threadPanelPresentation === "inline" ? (
+
+ ) : null}
{/* end horizontal flex container */}
@@ -6634,6 +6750,7 @@ function ChatViewContent(props: ChatViewProps) {
{panelToggleControls} }
+ inlineSize={previewPanelInlineSize}
+ layoutControls={panelToggleControls}
surfaces={rightPanelState.surfaces}
activeSurfaceId={activeRightPanelSurface?.id ?? null}
pendingSurfaceIds={pendingFileSurfaceIds}
@@ -6702,7 +6816,6 @@ function ChatViewContent(props: ChatViewProps) {
) : null}
-
{expandedImage && (
void) | undefined;
+=======
+ displayMode?: "toolbar" | "panel";
+ onOpenChanges?: () => void;
+>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
}
interface PendingDefaultBranchAction {
@@ -351,11 +365,13 @@ function GitActionItemIcon({
function GitQuickActionIcon({
quickAction,
SourceControlIcon,
+ className = "size-3.5",
}: {
quickAction: GitQuickAction;
SourceControlIcon: ReturnType["Icon"];
+ className?: string;
}) {
- const iconClassName = "size-3.5";
+ const iconClassName = className;
if (quickAction.kind === "open_pr") return ;
if (quickAction.kind === "open_publish") return ;
if (quickAction.kind === "run_pull") return ;
@@ -978,8 +994,15 @@ export default function GitActionsControl({
gitCwd,
activeThreadRef,
draftId,
+<<<<<<< HEAD
onOpenPullRequest,
+=======
+ displayMode = "toolbar",
+ onOpenChanges,
+>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
}: GitActionsControlProps) {
+ const isPanel = displayMode === "panel";
+ const ActionGroup = isPanel ? "div" : Group;
const updateThreadMetadata = useAtomCommand(
threadEnvironment.updateMetadata,
"thread branch metadata update",
@@ -1675,6 +1698,7 @@ export default function GitActionsControl({
) : (
-
+
{quickActionDisabledReason ? (
@@ -1717,8 +1748,14 @@ export default function GitActionsControl({
-
+
{quickAction.label}
@@ -1730,17 +1767,30 @@ export default function GitActionsControl({
)}
-
+ {isPanel ? (
+
+ ) : (
+
+ )}
-
+
)}
+ {isPanel && isRepo ? (
+
+ ) : null}
+