Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix: plan mode ui overhaul (#596)

Theo Browne42234b8f7cbe
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index a96b17bdb..259f055ef 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -92,6 +92,8 @@ import {
buildPlanImplementationThreadTitle,
buildPlanImplementationPrompt,
buildProposedPlanMarkdownFilename,
+ downloadPlanAsTextFile,
+ normalizePlanMarkdownForExport,
proposedPlanTitle,
resolvePlanFollowUpSubmission,
} from "../proposedPlan";
@@ -122,6 +124,7 @@ import {
shortcutLabelForCommand,
} from "../keybindings";
import ChatMarkdown from "./ChatMarkdown";
+import PlanSidebar from "./PlanSidebar";
import ThreadTerminalDrawer from "./ThreadTerminalDrawer";
import { Alert, AlertAction, AlertDescription, AlertTitle } from "./ui/alert";
import {
@@ -135,6 +138,7 @@ import {
DiffIcon,
EllipsisIcon,
FolderClosedIcon,
+ ListTodoIcon,
LockIcon,
LockOpenIcon,
Undo2Icon,
@@ -291,21 +295,7 @@ function workToneClass(tone: "thinking" | "tool" | "info" | "error"): string {
return "text-muted-foreground/40";
}
-function normalizePlanMarkdownForExport(planMarkdown: string): string {
- return `${planMarkdown.trimEnd()}\n`;
-}
-function downloadTextFile(filename: string, contents: string): void {
- const blob = new Blob([contents], { type: "text/markdown;charset=utf-8" });
- const url = URL.createObjectURL(blob);
- const anchor = document.createElement("a");
- anchor.href = url;
- anchor.download = filename;
- anchor.click();
- window.setTimeout(() => {
- URL.revokeObjectURL(url);
- }, 0);
-}
interface ExpandedImageItem {
src: string;
@@ -656,6 +646,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
const [pendingUserInputQuestionIndexByRequestId, setPendingUserInputQuestionIndexByRequestId] =
useState<Record<string, number>>({});
const [expandedWorkGroups, setExpandedWorkGroups] = useState<Record<string, boolean>>({});
+ const [planSidebarOpen, setPlanSidebarOpen] = useState(false);
+ // Tracks whether the user explicitly dismissed the sidebar for the active turn.
+ const planSidebarDismissedForTurnRef = useRef<string | null>(null);
+ // When set, the thread-change reset effect will open the sidebar instead of closing it.
+ // Used by "Implement in new thread" to carry the sidebar-open intent across navigation.
+ const planSidebarOpenOnNextThreadRef = useRef(false);
const [nowTick, setNowTick] = useState(() => Date.now());
const [terminalFocusRequestId, setTerminalFocusRequestId] = useState(0);
const [composerHighlightedItemId, setComposerHighlightedItemId] = useState<string | null>(null);
@@ -1941,8 +1937,17 @@ export default function ChatView({ threadId }: ChatViewProps) {
useEffect(() => {
setExpandedWorkGroups({});
+ if (planSidebarOpenOnNextThreadRef.current) {
+ planSidebarOpenOnNextThreadRef.current = false;
+ setPlanSidebarOpen(true);
+ } else {
+ setPlanSidebarOpen(false);
+ }
+ planSidebarDismissedForTurnRef.current = null;
}, [activeThread?.id]);
+
+
useEffect(() => {
if (!composerMenuOpen) {
setComposerHighlightedItemId(null);
@@ -2955,6 +2960,13 @@ export default function ChatView({ threadId }: ChatViewProps) {
interactionMode: nextInteractionMode,
createdAt: messageCreatedAt,
});
+ // Optimistically open the plan sidebar when implementing (not refining).
+ // "default" mode here means the agent is executing the plan, which produces
+ // step-tracking activities that the sidebar will display.
+ if (nextInteractionMode === "default") {
+ planSidebarDismissedForTurnRef.current = null;
+ setPlanSidebarOpen(true);
+ }
sendInFlightRef.current = false;
} catch (err) {
setOptimisticUserMessages((existing) =>
@@ -3063,6 +3075,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
.then(() => api.orchestration.getSnapshot())
.then((snapshot) => {
syncServerReadModel(snapshot);
+ // Signal that the plan sidebar should open on the new thread.
+ planSidebarOpenOnNextThreadRef.current = true;
return navigate({
to: "/$threadId",
params: { threadId: nextThreadId },
@@ -3469,7 +3483,10 @@ export default function ChatView({ threadId }: ChatViewProps) {
error={activeThread.error}
onDismiss={() => setThreadError(activeThread.id, null)}
/>
- <PlanModePanel activePlan={activePlan} />
+ {/* Main content area with optional plan sidebar */}
+ <div className="flex min-h-0 flex-1">
+ {/* Chat column */}
+ <div className="flex min-h-0 min-w-0 flex-1 flex-col">
{/* Messages */}
<div
@@ -3543,6 +3560,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
answers={activePendingDraftAnswers}
questionIndex={activePendingQuestionIndex}
onSelectOption={onSelectActivePendingUserInputOption}
+ onAdvance={onAdvanceActivePendingUserInput}
/>
</div>
) : showPlanFollowUpPrompt && activeProposedPlan ? (
@@ -3749,6 +3767,43 @@ export default function ChatView({ threadId }: ChatViewProps) {
{runtimeMode === "full-access" ? "Full access" : "Supervised"}
</span>
</Button>
+
+ {/* Plan sidebar toggle */}
+ {(activePlan || activeProposedPlan || planSidebarOpen) ? (
+ <>
+ <Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" />
+ <Button
+ variant="ghost"
+ className={cn(
+ "shrink-0 whitespace-nowrap px-2 sm:px-3",
+ planSidebarOpen
+ ? "text-blue-400 hover:text-blue-300"
+ : "text-muted-foreground/70 hover:text-foreground/80",
+ )}
+ size="sm"
+ type="button"
+ onClick={() => {
+ setPlanSidebarOpen((open) => {
+ if (open) {
+ // Closing: track dismissal for current turn
+ const turnKey = activePlan?.turnId ?? activeProposedPlan?.turnId ?? null;
+ if (turnKey) {
+ planSidebarDismissedForTurnRef.current = turnKey;
+ }
+ } else {
+ // Re-opening: clear dismissal tracking
+ planSidebarDismissedForTurnRef.current = null;
+ }
+ return !open;
+ });
+ }}
+ title={planSidebarOpen ? "Hide plan sidebar" : "Show plan sidebar"}
+ >
+ <ListTodoIcon />
+ <span className="sr-only sm:not-sr-only">Plan</span>
+ </Button>
+ </>
+ ) : null}
</div>
{/* Right side: send / stop button */}
@@ -3915,6 +3970,27 @@ export default function ChatView({ threadId }: ChatViewProps) {
</form>
</div>
+ </div>{/* end chat column */}
+
+ {/* Plan sidebar */}
+ {planSidebarOpen ? (
+ <PlanSidebar
+ activePlan={activePlan}
+ activeProposedPlan={activeProposedPlan}
+ markdownCwd={gitCwd ?? undefined}
+ workspaceRoot={activeProject?.cwd ?? undefined}
+ onClose={() => {
+ setPlanSidebarOpen(false);
+ // Track that the user explicitly dismissed for this turn so auto-open won't fight them.
+ const turnKey = activePlan?.turnId ?? activeProposedPlan?.turnId ?? null;
+ if (turnKey) {
+ planSidebarDismissedForTurnRef.current = turnKey;
+ }
+ }}
+ />
+ ) : null}
+ </div>{/* end horizontal flex container */}
+
{isGitRepo && (
<BranchToolbar
threadId={activeThread.id}
@@ -4274,61 +4350,13 @@ const ComposerPendingApprovalActions = memo(function ComposerPendingApprovalActi
);
});
-interface PlanModePanelProps {
- activePlan: ReturnType<typeof deriveActivePlanState>;
-}
-
-const PlanModePanel = memo(function PlanModePanel({ activePlan }: PlanModePanelProps) {
- if (!activePlan) return null;
-
- return (
- <div className="pt-3 mx-auto max-w-3xl">
- <div className="rounded-xl border border-border/70 bg-muted/30 p-4">
- <div className="flex items-center gap-2">
- <Badge variant="secondary">Plan</Badge>
- <span className="text-xs text-muted-foreground">
- Updated {formatTimestamp(activePlan.createdAt)}
- </span>
- </div>
- {activePlan.explanation ? (
- <p className="mt-2 text-sm text-muted-foreground">{activePlan.explanation}</p>
- ) : null}
- <div className="mt-3 space-y-2">
- {activePlan.steps.map((step) => (
- <div
- key={`${step.status}:${step.step}`}
- className="flex items-start gap-3 rounded-lg border border-border/60 bg-background/80 px-3 py-2"
- >
- <Badge
- variant={
- step.status === "completed"
- ? "default"
- : step.status === "inProgress"
- ? "secondary"
- : "outline"
- }
- >
- {step.status === "inProgress"
- ? "In progress"
- : step.status === "completed"
- ? "Done"
- : "Pending"}
- </Badge>
- <div className="min-w-0 flex-1 text-sm">{step.step}</div>
- </div>
- ))}
- </div>
- </div>
- </div>
- );
-});
-
interface PendingUserInputPanelProps {
pendingUserInputs: PendingUserInput[];
respondingRequestIds: ApprovalRequestId[];
answers: Record<string, PendingUserInputDraftAnswer>;
questionIndex: number;
onSelectOption: (questionId: string, optionLabel: string) => void;
+ onAdvance: () => void;
}
const ComposerPendingUserInputPanel = memo(function ComposerPendingUserInputPanel({
@@ -4337,6 +4365,7 @@ const ComposerPendingUserInputPanel = memo(function ComposerPendingUserInputPane
answers,
questionIndex,
onSelectOption,
+ onAdvance,
}: PendingUserInputPanelProps) {
if (pendingUserInputs.length === 0) return null;
const activePrompt = pendingUserInputs[0];
@@ -4350,6 +4379,7 @@ const ComposerPendingUserInputPanel = memo(function ComposerPendingUserInputPane
answers={answers}
questionIndex={questionIndex}
onSelectOption={onSelectOption}
+ onAdvance={onAdvance}
/>
);
});
@@ -4360,42 +4390,135 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
answers,
questionIndex,
onSelectOption,
+ onAdvance,
}: {
prompt: PendingUserInput;
isResponding: boolean;
answers: Record<string, PendingUserInputDraftAnswer>;
questionIndex: number;
onSelectOption: (questionId: string, optionLabel: string) => void;
+ onAdvance: () => void;
}) {
const progress = derivePendingUserInputProgress(prompt.questions, answers, questionIndex);
const activeQuestion = progress.activeQuestion;
+ const autoAdvanceTimerRef = useRef<number | null>(null);
+
+ // Clear auto-advance timer on unmount
+ useEffect(() => {
+ return () => {
+ if (autoAdvanceTimerRef.current !== null) {
+ window.clearTimeout(autoAdvanceTimerRef.current);
+ }
+ };
+ }, []);
+
+ const selectOptionAndAutoAdvance = useCallback(
+ (questionId: string, optionLabel: string) => {
+ onSelectOption(questionId, optionLabel);
+ if (autoAdvanceTimerRef.current !== null) {
+ window.clearTimeout(autoAdvanceTimerRef.current);
+ }
+ autoAdvanceTimerRef.current = window.setTimeout(() => {
+ autoAdvanceTimerRef.current = null;
+ onAdvance();
+ }, 200);
+ },
+ [onSelectOption, onAdvance],
+ );
+
+ // Keyboard shortcut: number keys 1-9 select corresponding option and auto-advance.
+ // Works even when the Lexical composer (contenteditable) has focus — the composer
+ // doubles as a custom-answer field during user input, and when it's empty the digit
+ // keys should pick options instead of typing into the editor.
+ useEffect(() => {
+ if (!activeQuestion || isResponding) return;
+ const handler = (event: globalThis.KeyboardEvent) => {
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
+ const target = event.target;
+ if (
+ target instanceof HTMLInputElement ||
+ target instanceof HTMLTextAreaElement
+ ) {
+ return;
+ }
+ // If the user has started typing a custom answer in the contenteditable
+ // composer, let digit keys pass through so they can type numbers.
+ if (target instanceof HTMLElement && target.isContentEditable) {
+ const hasCustomText = progress.customAnswer.length > 0;
+ if (hasCustomText) return;
+ }
+ const digit = Number.parseInt(event.key, 10);
+ if (Number.isNaN(digit) || digit < 1 || digit > 9) return;
+ const optionIndex = digit - 1;
+ if (optionIndex >= activeQuestion.options.length) return;
+ const option = activeQuestion.options[optionIndex];
+ if (!option) return;
+ event.preventDefault();
+ selectOptionAndAutoAdvance(activeQuestion.id, option.label);
+ };
+ document.addEventListener("keydown", handler);
+ return () => document.removeEventListener("keydown", handler);
+ }, [activeQuestion, isResponding, selectOptionAndAutoAdvance, progress.customAnswer.length]);
if (!activeQuestion) {
return null;
}
return (
- <div className="px-4 py-4 sm:px-5">
- <div className="flex gap-2">
- <span className="uppercase text-sm tracking-[0.2em]">
- {questionIndex + 1}/{prompt.questions.length} {activeQuestion.header}
- </span>
- <div className="text-sm font-medium">{activeQuestion.question}</div>
+ <div className="px-4 py-3 sm:px-5">
+ <div className="flex items-center gap-3">
+ <div className="flex items-center gap-2">
+ {prompt.questions.length > 1 ? (
+ <span className="flex h-5 items-center rounded-md bg-muted/60 px-1.5 text-[10px] font-medium tabular-nums text-muted-foreground/60">
+ {questionIndex + 1}/{prompt.questions.length}
+ </span>
+ ) : null}
+ <span className="text-[11px] font-semibold tracking-widest text-muted-foreground/50 uppercase">
+ {activeQuestion.header}
+ </span>
+ </div>
</div>
- <div className="mt-3 flex flex-wrap gap-2">
- {activeQuestion.options.map((option) => {
+ <p className="mt-1.5 text-sm text-foreground/90">{activeQuestion.question}</p>
+ <div className="mt-3 space-y-1">
+ {activeQuestion.options.map((option, index) => {
const isSelected = progress.selectedOptionLabel === option.label;
+ const shortcutKey = index < 9 ? index + 1 : null;
return (
- <Button
+ <button
key={`${activeQuestion.id}:${option.label}`}
- size="sm"
- variant={isSelected ? "default" : "outline"}
+ type="button"
disabled={isResponding}
- onClick={() => onSelectOption(activeQuestion.id, option.label)}
- title={option.description}
+ onClick={() => selectOptionAndAutoAdvance(activeQuestion.id, option.label)}
+ className={cn(
+ "group flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-all duration-150",
+ isSelected
+ ? "border-blue-500/40 bg-blue-500/8 text-foreground"
+ : "border-transparent bg-muted/20 text-foreground/80 hover:bg-muted/40 hover:border-border/40",
+ isResponding && "opacity-50 cursor-not-allowed",
+ )}
>
- {option.label}
- </Button>
+ {shortcutKey !== null ? (
+ <kbd
+ className={cn(
+ "flex size-5 shrink-0 items-center justify-center rounded text-[11px] font-medium tabular-nums transition-colors duration-150",
+ isSelected
+ ? "bg-blue-500/20 text-blue-400"
+ : "bg-muted/40 text-muted-foreground/50 group-hover:bg-muted/60 group-hover:text-muted-foreground/70",
+ )}
+ >
+ {shortcutKey}
+ </kbd>
+ ) : null}
+ <div className="min-w-0 flex-1">
+ <span className="text-sm font-medium">{option.label}</span>
+ {option.description && option.description !== option.label ? (
+ <span className="ml-2 text-xs text-muted-foreground/50">{option.description}</span>
+ ) : null}
+ </div>
+ {isSelected ? (
+ <CheckIcon className="size-3.5 shrink-0 text-blue-400" />
+ ) : null}
+ </button>
);
})}
</div>
@@ -4609,7 +4732,7 @@ const ProposedPlanCard = memo(function ProposedPlanCard({
const saveContents = normalizePlanMarkdownForExport(planMarkdown);
const handleDownload = () => {
- downloadTextFile(downloadFilename, saveContents);
+ downloadPlanAsTextFile(downloadFilename, saveContents);
};
const openSaveDialog = () => {
diff --git a/apps/web/src/components/PlanSidebar.tsx b/apps/web/src/components/PlanSidebar.tsx
new file mode 100644
index 000000000..5ab2f5e32
--- /dev/null
+++ b/apps/web/src/components/PlanSidebar.tsx
@@ -0,0 +1,267 @@
+import { memo, useState, useCallback } from "react";
+import { Badge } from "./ui/badge";
+import { Button } from "./ui/button";
+import { ScrollArea } from "./ui/scroll-area";
+import ChatMarkdown from "./ChatMarkdown";
+import {
+ CheckIcon,
+ ChevronDownIcon,
+ ChevronRightIcon,
+ EllipsisIcon,
+ LoaderIcon,
+ PanelRightCloseIcon,
+} from "lucide-react";
+import { cn } from "~/lib/utils";
+import { formatTimestamp } from "../session-logic";
+import type { ActivePlanState } from "../session-logic";
+import type { LatestProposedPlanState } from "../session-logic";
+import {
+ proposedPlanTitle,
+ buildProposedPlanMarkdownFilename,
+ normalizePlanMarkdownForExport,
+ downloadPlanAsTextFile,
+} from "../proposedPlan";
+import { Menu, MenuItem, MenuPopup, MenuTrigger } from "./ui/menu";
+import { readNativeApi } from "~/nativeApi";
+import { toastManager } from "./ui/toast";
+
+function stepStatusIcon(status: string): React.ReactNode {
+ if (status === "completed") {
+ return (
+ <span className="flex size-5 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-500">
+ <CheckIcon className="size-3" />
+ </span>
+ );
+ }
+ if (status === "inProgress") {
+ return (
+ <span className="flex size-5 shrink-0 items-center justify-center rounded-full bg-blue-500/15 text-blue-400">
+ <LoaderIcon className="size-3 animate-spin" />
+ </span>
+ );
+ }
+ return (
+ <span className="flex size-5 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted/30">
+ <span className="size-1.5 rounded-full bg-muted-foreground/30" />
+ </span>
+ );
+}
+
+interface PlanSidebarProps {
+ activePlan: ActivePlanState | null;
+ activeProposedPlan: LatestProposedPlanState | null;
+ markdownCwd: string | undefined;
+ workspaceRoot: string | undefined;
+ onClose: () => void;
+}
+
+const PlanSidebar = memo(function PlanSidebar({
+ activePlan,
+ activeProposedPlan,
+ markdownCwd,
+ workspaceRoot,
+ onClose,
+}: PlanSidebarProps) {
+ const [proposedPlanExpanded, setProposedPlanExpanded] = useState(false);
+ const [isSavingToWorkspace, setIsSavingToWorkspace] = useState(false);
+ const [copied, setCopied] = useState(false);
+
+ const planMarkdown = activeProposedPlan?.planMarkdown ?? null;
+ const planTitle = planMarkdown ? proposedPlanTitle(planMarkdown) : null;
+
+ const handleCopyPlan = useCallback(() => {
+ if (!planMarkdown) return;
+ void navigator.clipboard.writeText(planMarkdown);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 2000);
+ }, [planMarkdown]);
+
+ const handleDownload = useCallback(() => {
+ if (!planMarkdown) return;
+ const filename = buildProposedPlanMarkdownFilename(planMarkdown);
+ downloadPlanAsTextFile(filename, normalizePlanMarkdownForExport(planMarkdown));
+ }, [planMarkdown]);
+
+ const handleSaveToWorkspace = useCallback(() => {
+ const api = readNativeApi();
+ if (!api || !workspaceRoot || !planMarkdown) return;
+ const filename = buildProposedPlanMarkdownFilename(planMarkdown);
+ setIsSavingToWorkspace(true);
+ void api.projects
+ .writeFile({
+ cwd: workspaceRoot,
+ relativePath: filename,
+ contents: normalizePlanMarkdownForExport(planMarkdown),
+ })
+ .then((result) => {
+ toastManager.add({
+ type: "success",
+ title: "Plan saved",
+ description: result.relativePath,
+ });
+ })
+ .catch((error) => {
+ toastManager.add({
+ type: "error",
+ title: "Could not save plan",
+ description:
+ error instanceof Error ? error.message : "An error occurred.",
+ });
+ })
+ .then(
+ () => setIsSavingToWorkspace(false),
+ () => setIsSavingToWorkspace(false),
+ );
+ }, [planMarkdown, workspaceRoot]);
+
+ return (
+ <div className="flex h-full w-[340px] shrink-0 flex-col border-l border-border/70 bg-card/50">
+ {/* Header */}
+ <div className="flex h-12 shrink-0 items-center justify-between border-b border-border/60 px-3">
+ <div className="flex items-center gap-2">
+ <Badge
+ variant="secondary"
+ className="rounded-md bg-blue-500/10 px-1.5 py-0 text-[10px] font-semibold tracking-wide text-blue-400 uppercase"
+ >
+ Plan
+ </Badge>
+ {activePlan ? (
+ <span className="text-[11px] text-muted-foreground/60">
+ {formatTimestamp(activePlan.createdAt)}
+ </span>
+ ) : null}
+ </div>
+ <div className="flex items-center gap-1">
+ {planMarkdown ? (
+ <Menu>
+ <MenuTrigger
+ render={
+ <Button
+ size="icon-xs"
+ variant="ghost"
+ className="text-muted-foreground/50 hover:text-foreground/70"
+ aria-label="Plan actions"
+ />
+ }
+ >
+ <EllipsisIcon className="size-3.5" />
+ </MenuTrigger>
+ <MenuPopup align="end">
+ <MenuItem onClick={handleCopyPlan}>
+ {copied ? "Copied!" : "Copy to clipboard"}
+ </MenuItem>
+ <MenuItem onClick={handleDownload}>Download as markdown</MenuItem>
+ <MenuItem
+ onClick={handleSaveToWorkspace}
+ disabled={!workspaceRoot || isSavingToWorkspace}
+ >
+ Save to workspace
+ </MenuItem>
+ </MenuPopup>
+ </Menu>
+ ) : null}
+ <Button
+ size="icon-xs"
+ variant="ghost"
+ onClick={onClose}
+ aria-label="Close plan sidebar"
+ className="text-muted-foreground/50 hover:text-foreground/70"
+ >
+ <PanelRightCloseIcon className="size-3.5" />
+ </Button>
+ </div>
+ </div>
+
+ {/* Content */}
+ <ScrollArea className="min-h-0 flex-1">
+ <div className="p-3 space-y-4">
+ {/* Explanation */}
+ {activePlan?.explanation ? (
+ <p className="text-[13px] leading-relaxed text-muted-foreground/80">
+ {activePlan.explanation}
+ </p>
+ ) : null}
+
+ {/* Plan Steps */}
+ {activePlan && activePlan.steps.length > 0 ? (
+ <div className="space-y-1">
+ <p className="mb-2 text-[10px] font-semibold tracking-widest text-muted-foreground/40 uppercase">
+ Steps
+ </p>
+ {activePlan.steps.map((step) => (
+ <div
+ key={`${step.status}:${step.step}`}
+ className={cn(
+ "flex items-start gap-2.5 rounded-lg px-2.5 py-2 transition-colors duration-200",
+ step.status === "inProgress" && "bg-blue-500/5",
+ step.status === "completed" && "bg-emerald-500/5",
+ )}
+ >
+ <div className="mt-0.5">
+ {stepStatusIcon(step.status)}
+ </div>
+ <p
+ className={cn(
+ "text-[13px] leading-snug",
+ step.status === "completed"
+ ? "text-muted-foreground/50 line-through decoration-muted-foreground/20"
+ : step.status === "inProgress"
+ ? "text-foreground/90"
+ : "text-muted-foreground/70",
+ )}
+ >
+ {step.step}
+ </p>
+ </div>
+ ))}
+ </div>
+ ) : null}
+
+ {/* Proposed Plan Markdown */}
+ {planMarkdown ? (
+ <div className="space-y-2">
+ <button
+ type="button"
+ className="group flex w-full items-center gap-1.5 text-left"
+ onClick={() => setProposedPlanExpanded((v) => !v)}
+ >
+ {proposedPlanExpanded ? (
+ <ChevronDownIcon className="size-3 shrink-0 text-muted-foreground/40 transition-transform" />
+ ) : (
+ <ChevronRightIcon className="size-3 shrink-0 text-muted-foreground/40 transition-transform" />
+ )}
+ <span className="text-[10px] font-semibold tracking-widest text-muted-foreground/40 uppercase group-hover:text-muted-foreground/60">
+ {planTitle ?? "Full Plan"}
+ </span>
+ </button>
+ {proposedPlanExpanded ? (
+ <div className="rounded-lg border border-border/50 bg-background/50 p-3">
+ <ChatMarkdown
+ text={planMarkdown}
+ cwd={markdownCwd}
+ isStreaming={false}
+ />
+ </div>
+ ) : null}
+ </div>
+ ) : null}
+
+ {/* Empty state */}
+ {!activePlan && !planMarkdown ? (
+ <div className="flex flex-col items-center justify-center py-12 text-center">
+ <p className="text-[13px] text-muted-foreground/40">
+ No active plan yet.
+ </p>
+ <p className="mt-1 text-[11px] text-muted-foreground/30">
+ Plans will appear here when generated.
+ </p>
+ </div>
+ ) : null}
+ </div>
+ </ScrollArea>
+ </div>
+ );
+});
+
+export default PlanSidebar;
+export type { PlanSidebarProps };
diff --git a/apps/web/src/proposedPlan.ts b/apps/web/src/proposedPlan.ts
index 1550eb7de..3bd4f62e6 100644
--- a/apps/web/src/proposedPlan.ts
+++ b/apps/web/src/proposedPlan.ts
@@ -49,3 +49,19 @@ export function buildProposedPlanMarkdownFilename(planMarkdown: string): string
const title = proposedPlanTitle(planMarkdown);
return `${sanitizePlanFileSegment(title ?? "plan")}.md`;
}
+
+export function normalizePlanMarkdownForExport(planMarkdown: string): string {
+ return `${planMarkdown.trimEnd()}\n`;
+}
+
+export function downloadPlanAsTextFile(filename: string, contents: string): void {
+ const blob = new Blob([contents], { type: "text/markdown;charset=utf-8" });
+ const url = URL.createObjectURL(blob);
+ const anchor = document.createElement("a");
+ anchor.href = url;
+ anchor.download = filename;
+ anchor.click();
+ window.setTimeout(() => {
+ URL.revokeObjectURL(url);
+ }, 0);
+}