Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(ui): the prompt window is the prompt window, on every surface

David87fef747bc9c
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index 4880c251..1f3ed0e0 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -239,6 +239,15 @@ export function ChatView() {
</div>
</div>
+ {/* The plan, for plain chat and for Agent alike. It belongs with
+ the standing status controls in the header, not at the prompt
+ box: the Chat surface has no right-hand column to hand it to,
+ and this row is where everything that is TRUE OF THE SESSION
+ rather than of the next message already lives (agent toggle,
+ workspace, token counter, context window, memory). Collapsed
+ by default so it costs one line above the transcript. */}
+ <PlanBar />
+
<MessageList
isGenerating={isGenerating}
isThisChatGenerating={activeGenerating}
@@ -340,7 +349,10 @@ export function ChatView() {
slashCommands={isAgentActive}
onAttachDocs={appMode !== 'cloud' ? () => setRagPanelOpen(true) : undefined}
composerModel={<ModelSelector openUpward />}
- composerAbove={<><LoopBar onStop={stopGeneration} /><GoalBar /><GroupCostHint /><PlanBar /></>}
+ // No plan lives here. The prompt window is the prompt window
+ // (David, 2026-08-22): the plan band sits under the header row
+ // above, next to the other standing status controls.
+ composerAbove={<><LoopBar onStop={stopGeneration} /><GoalBar /><GroupCostHint /></>}
composerActions={
<>
{/* Documents (RAG) — local-embeddings only, so hide in
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsx
index b60021b7..c5c201f3 100644
--- a/src/components/chat/CodexView.tsx
+++ b/src/components/chat/CodexView.tsx
@@ -16,7 +16,6 @@ import { WorkingAnchor } from './WorkingAnchor'
import { useCodexConfirmStore } from '../../stores/codexConfirmStore'
import { PluginsDropdown } from './PluginsDropdown'
import { CodexModeDropdown } from './CodexModeDropdown'
-import { PlanApprovalBar } from './PlanApprovalBar'
import { ModelSelector } from '../models/ModelSelector'
import { GoalBar } from './GoalBar'
import { LoopBar } from './LoopBar'
@@ -510,7 +509,10 @@ export function CodexView() {
isGenerating={isRunning || codexGenerating}
slashCommands
composerModel={<ModelSelector openUpward surface="code" />}
- composerAbove={<><LoopBar onStop={stopCodex} /><GoalBar /><PlanApprovalBar onApprove={(text) => sendInstruction(text)} /></>}
+ // No plan lives here. The prompt window is the prompt window
+ // (David, 2026-08-22): the plan and its Approve-and-run card sit
+ // at the bottom of the Explorer column on the right.
+ composerAbove={<><LoopBar onStop={stopCodex} /><GoalBar /></>}
// Ask / Bypass / Plan sits here, in the CODE composer only (plan
// C1). ChatInput stays surface-neutral, so the Chat tab inherits
// nothing from it.
@@ -518,9 +520,12 @@ export function CodexView() {
/>
</div>
- {/* Right column: plan (C2) + explorer tree + file preview (C3). It
- owns its own width and collapsed state, both persisted in uiStore. */}
- <ExplorerPanel />
+ {/* Right column: explorer tree + file preview (C3), and at the bottom
+ the plan plus its Approve-and-run card (C2). It owns its own width
+ and collapsed state, both persisted in uiStore. The approve callback
+ is threaded through because the card left the composer and this view
+ is the only place that holds `sendInstruction`. */}
+ <ExplorerPanel onApprovePlan={(text) => sendInstruction(text)} />
</div>
)
}
diff --git a/src/components/chat/ExplorerPanel.tsx b/src/components/chat/ExplorerPanel.tsx
index c9217f5e..23bb0b29 100644
--- a/src/components/chat/ExplorerPanel.tsx
+++ b/src/components/chat/ExplorerPanel.tsx
@@ -1,6 +1,13 @@
/**
- * The right column of the Code tab (2.6.6 C2 + C3): the model's plan on top, a
- * real lazy file tree below it, and the preview of a clicked file underneath.
+ * The right column of the Code tab (2.6.6 C2 + C3): a real lazy file tree, the
+ * preview of a clicked file underneath it, and at the BOTTOM the model's plan
+ * plus the Approve-and-run card that goes with it.
+ *
+ * Both plan pieces are here because the prompt window is the prompt window and
+ * shows nothing about plans (David, 2026-08-22, fifth time of asking). They are
+ * at the BOTTOM of the column rather than the top for the same reading, filed
+ * the same day: opening the Code tab, the eye wants the files first, and a plan
+ * sitting above the folder picker made no sense to him.
*
* What changed against the old FileTree:
* - Folders EXPAND in place. They used to replace the workspace root, which
@@ -24,6 +31,7 @@ import {
FileText,
Folder,
FolderOpen,
+ ListTodo,
Loader2,
PanelRightClose,
PanelRightOpen,
@@ -44,11 +52,19 @@ import {
type FsList,
} from '../../lib/explorer-tree'
import { PlanBar } from './PlanBar'
+import { PlanApprovalBar } from './PlanApprovalBar'
import { FilePreview } from './FilePreview'
+import { useChatStore } from '../../stores/chatStore'
+import { useTodoStore } from '../../stores/todoStore'
const fsList: FsList = (args) => backendCall('fs_list', args as unknown as Record<string, unknown>)
-export function ExplorerPanel() {
+interface Props {
+ /** Runs the approved plan. Threaded in from CodexView, which owns the send. */
+ onApprovePlan: (instruction: string) => void
+}
+
+export function ExplorerPanel({ onApprovePlan }: Props) {
const root = useCodexStore((s) => s.workingDirectory)
const setWorkingDirectory = useCodexStore((s) => s.setWorkingDirectory)
const fileTreeVersion = useCodexStore((s) => s.fileTreeVersion)
@@ -64,6 +80,17 @@ export function ExplorerPanel() {
const [error, setError] = useState<string | null>(null)
const [selected, setSelected] = useState<ExplorerNode | null>(null)
+ // The plan moved into this column, so a collapsed column would hide it, and
+ // with it the only Approve-and-run button there is. The rail says so instead.
+ const activeConversationId = useChatStore((s) => s.activeConversationId)
+ const planWaiting = useCodexStore((s) =>
+ activeConversationId ? !!s.planApprovalByConversation[activeConversationId] : false,
+ )
+ const planSteps = useTodoStore((s) =>
+ activeConversationId ? (s.byConversation[activeConversationId]?.length ?? 0) : 0,
+ )
+ const planHasSomething = planWaiting || planSteps > 0
+
const load = async (dir: string) => {
setBusy((b) => (b.includes(dir) ? b : [...b, dir]))
try {
@@ -158,6 +185,18 @@ export function ExplorerPanel() {
>
<PanelRightOpen size={12} />
</button>
+ {planHasSomething && (
+ <button
+ onClick={() => setExplorerCollapsed(false)}
+ title={planWaiting ? 'A plan is waiting for your approval' : 'Show the plan'}
+ data-testid="explorer-plan-waiting"
+ className={`mt-1 p-1 rounded transition-colors hover:bg-gray-100 dark:hover:bg-white/5 ${
+ planWaiting ? 'text-purple-400' : 'text-blue-400'
+ }`}
+ >
+ <ListTodo size={12} />
+ </button>
+ )}
</div>
)
}
@@ -179,9 +218,6 @@ export function ExplorerPanel() {
className="absolute left-0 top-0 h-full w-1 -ml-0.5 z-10 cursor-col-resize hover:bg-blue-500/40 active:bg-blue-500/60 transition-colors"
/>
- {/* C2: the plan lives here now, not above the prompt. */}
- <PlanBar variant="panel" />
-
<div className="flex items-center gap-1 p-1.5 border-b border-gray-200 dark:border-white/[0.04]">
<button
onClick={pickFolder}
@@ -279,6 +315,14 @@ export function ExplorerPanel() {
// per-file script opt-in cannot survive the switch.
<FilePreview key={selected.path} node={selected} root={root} onClose={() => setSelected(null)} />
)}
+
+ {/* Bottom of the column, and the only place either of these renders.
+ `shrink-0` so a long file tree can never squeeze the plan, and with
+ it the Approve-and-run button, down to nothing. */}
+ <div className="shrink-0 border-t border-gray-200 dark:border-white/[0.04]">
+ <PlanApprovalBar onApprove={onApprovePlan} />
+ <PlanBar variant="panel" />
+ </div>
</aside>
)
}
diff --git a/src/components/chat/PlanApprovalBar.tsx b/src/components/chat/PlanApprovalBar.tsx
index 3c8a9faf..92ca8841 100644
--- a/src/components/chat/PlanApprovalBar.tsx
+++ b/src/components/chat/PlanApprovalBar.tsx
@@ -9,6 +9,12 @@
// 2. The execution never lands in Bypass implicitly. The target mode is
// resolved from the user's own visible choices and printed ON the button,
// so "Approve and run (Ask)" is a promise about what happens next.
+//
+// It used to sit above the prompt box. It does not any more: the prompt window
+// is the prompt window and shows nothing about plans (David, 2026-08-22, fifth
+// time of asking). The card moved to the plan's home, the bottom of the
+// Explorer column, with the plan itself. Both rules above are untouched by that
+// move; only the wrapper width changed from the composer's 70% to the column.
import { useState } from 'react'
import { ClipboardCheck, ChevronDown, X } from 'lucide-react'
@@ -49,7 +55,7 @@ export function PlanApprovalBar({ onApprove }: { onApprove: (instruction: string
}
return (
- <div className="w-full max-w-[70%] mx-auto px-3 pb-1">
+ <div className="w-full p-1.5" data-testid="plan-approval-panel">
<div className="w-full rounded-md border border-purple-500/25 bg-purple-500/[0.04]">
<div className="flex items-center gap-1.5 px-2 py-1">
<ClipboardCheck size={9} className="text-purple-400 shrink-0" />
diff --git a/src/components/chat/PlanBar.tsx b/src/components/chat/PlanBar.tsx
index c82eb2b2..f7b890ab 100644
--- a/src/components/chat/PlanBar.tsx
+++ b/src/components/chat/PlanBar.tsx
@@ -5,13 +5,18 @@
// this list through `todo_write` and keeps it current, so progress is one glance
// instead of a scroll back through twenty tool calls.
//
-// Two homes since 2.6.6 C2:
-// - 'composer' (Agent tab): above the input, inside the composer's 70% width
-// wrapper. Collapsed to the current step by default, because a ten-item
-// list would push the input off screen.
-// - 'panel' (Code tab): the top section of the Explorer column, full column
-// width and expanded by default. It has vertical room there, and the plan
-// stops stealing the prompt window it used to sit in.
+// Two homes, and neither one touches the prompt window. David has asked for
+// that five times now, last on 2026-08-22: the prompt window is the prompt
+// window, nothing about plans may be visible there, on any surface, in any
+// state. So there is no composer variant to reach for:
+// - 'header' (LU tab, plain chat and Agent alike): a status band under the
+// header row and above the transcript, next to the other standing status
+// controls. Collapsed to the current step by default, because a ten-item
+// list would push the conversation down.
+// - 'panel' (Code tab): the BOTTOM section of the Explorer column, full
+// column width and expanded by default. Bottom because David read the
+// column top down on 2026-08-22 and the files are what he wants first;
+// the plan is the footer of that column, not its headline.
// Expanded state is per session, not persisted, because a plan is short-lived.
import { useState } from 'react'
@@ -27,13 +32,13 @@ export function planDoneLabel(pendingChanges: number): string {
return `every step done, ${pendingChanges} change${pendingChanges === 1 ? '' : 's'} still waiting for your approval`
}
-export type PlanBarVariant = 'composer' | 'panel'
+export type PlanBarVariant = 'header' | 'panel'
interface Props {
variant?: PlanBarVariant
}
-export function PlanBar({ variant = 'composer' }: Props) {
+export function PlanBar({ variant = 'header' }: Props) {
const panel = variant === 'panel'
const activeConversationId = useChatStore((s) => s.activeConversationId)
const todos = useTodoStore((s) =>
@@ -60,8 +65,8 @@ export function PlanBar({ variant = 'composer' }: Props) {
return (
<div
- className={panel ? 'w-full p-1.5' : 'w-full max-w-[70%] mx-auto px-3 pb-1 flex justify-center'}
- data-testid={panel ? 'plan-panel' : 'plan-composer'}
+ className={panel ? 'w-full p-1.5' : 'w-full px-2 pt-1'}
+ data-testid={panel ? 'plan-panel' : 'plan-header'}
>
<div className="w-full rounded-md border border-blue-500/20 bg-blue-500/[0.04]">
<div className="flex items-center gap-1.5 px-2 py-1">
@@ -98,8 +103,9 @@ export function PlanBar({ variant = 'composer' }: Props) {
</div>
{expanded && (
- // Capped so a fifteen-step plan cannot push the composer off screen,
- // and in the panel so it cannot push the file tree out of view.
+ // Capped so a fifteen-step plan cannot push the transcript off
+ // screen, and in the panel so it cannot push the file tree out of
+ // view.
<ul className={`px-2 pb-1.5 space-y-0.5 overflow-y-auto ${panel ? 'max-h-48 scrollbar-thin' : 'max-h-40'}`}>
{todos.map((t, i) => (
<li key={`${i}-${t.content}`} className="flex items-start gap-1.5">
@@ -127,8 +133,8 @@ export function PlanBar({ variant = 'composer' }: Props) {
)}
{(panel || !expanded) && allDone && (
- // In the composer this is the collapsed summary line. In the panel the
- // list is open by default, so the line has to stay: "every step done"
+ // In the header band this is the collapsed summary line. In the panel
+ // the list is open by default, so the line has to stay: "every step done"
// while six writes sit refused in the queue is exactly the sentence
// Morgan believed.
<div className="px-2 pb-1 flex items-center gap-1.5" data-testid="plan-all-done">
diff --git a/src/components/chat/__tests__/plan-done-vs-applied.test.ts b/src/components/chat/__tests__/plan-done-vs-applied.test.ts
index 9fe167d5..01afc3cb 100644
--- a/src/components/chat/__tests__/plan-done-vs-applied.test.ts
+++ b/src/components/chat/__tests__/plan-done-vs-applied.test.ts
@@ -6,8 +6,12 @@
*
* Since 2.6.6 C2 the coding tab shows this in the right-hand panel instead of
* above the prompt, so the same claims are now tested on the panel variant:
- * the staged-changes coupling and the clear button moved with it, and the
- * composer above the input no longer carries a plan at all.
+ * the staged-changes coupling and the clear button moved with it. Since
+ * 2026-08-22 the panel section sits at the BOTTOM of that column, the LU tab
+ * shows its plan in the header band, and no composer anywhere carries a plan.
+ * The invariant behind that lives in
+ * the-prompt-window-is-the-prompt-window.test.ts; what is checked here is that
+ * the Morgan warning survived both moves.
*
* Run: npx vitest run src/components/chat/__tests__/plan-done-vs-applied.test.ts
*/
@@ -48,13 +52,14 @@ describe('the bar reads the staging queue', () => {
})
describe('the plan moved into the panel (C2)', () => {
- it('PlanBar has a panel variant without the composer width wrapper', () => {
+ it('PlanBar has a panel variant and a header variant, no composer one', () => {
const src = read('../PlanBar.tsx')
- expect(src).toMatch(/variant = 'composer'/)
+ expect(src).toMatch(/variant = 'header'/)
expect(src).toMatch(/panel = variant === 'panel'/)
- // The 70% wrapper belongs to the composer only; in a 280px column it would
- // squeeze the plan into a third of the panel.
- expect(src).toMatch(/panel \? 'w-full p-1\.5' : 'w-full max-w-\[70%\]/)
+ // The old 70% wrapper was the composer's; in a 280px column it squeezed the
+ // plan into a third of the panel, and at the prompt box it had no business
+ // being at all.
+ expect(src).toMatch(/panel \? 'w-full p-1\.5' : 'w-full px-2 pt-1'/)
})
it('the clear button and the staged count came along, unchanged', () => {
@@ -63,27 +68,30 @@ describe('the plan moved into the panel (C2)', () => {
expect(src).toMatch(/s\.byChat\[activeConversationId\]\?\.length \?\? 0/)
})
- it('the coding composer no longer carries a plan', () => {
+ it('the coding composer carries no plan, not even the approval card', () => {
const src = read('../CodexView.tsx')
- // C1 added the plan APPROVAL card here (a button plus the plan text the
- // user is approving); the plan itself still lives only in the panel.
- expect(src).toMatch(/composerAbove=\{<><LoopBar onStop=\{stopCodex\} \/><GoalBar \/><PlanApprovalBar /)
+ // C1 had put the plan APPROVAL card here (a button plus the plan text the
+ // user is approving). It went down into the panel too on 2026-08-22: the
+ // prompt window is the prompt window.
+ expect(src).toMatch(/composerAbove=\{<><LoopBar onStop=\{stopCodex\} \/><GoalBar \/><\/>\}/)
expect(src).not.toMatch(/PlanBar/)
+ expect(src).not.toMatch(/PlanApprovalBar/)
})
- it('the panel renders it, above the tree', () => {
+ it('the panel renders it, below the tree', () => {
const src = read('../ExplorerPanel.tsx')
expect(src).toMatch(/<PlanBar variant="panel" \/>/)
const plan = src.indexOf('<PlanBar variant="panel" />')
const tree = src.indexOf('{rows.map((row) => {')
expect(plan).toBeGreaterThan(-1)
- expect(tree).toBeGreaterThan(plan)
+ expect(plan).toBeGreaterThan(tree)
})
- it('counter-test: the chat tab keeps the plan above its composer', () => {
- // Only the Code tab moved. ChatView is not ours to change and must still
- // render the composer variant.
+ it('and the chat tab shows it in the header band, not at its composer', () => {
+ // The Chat and Agent surface has no right-hand column, so the plan sits
+ // with the standing status controls above the transcript instead.
const src = read('../ChatView.tsx')
expect(src).toMatch(/<PlanBar \/>/)
+ expect(src.indexOf('<PlanBar />')).toBeLessThan(src.indexOf('<MessageList'))
})
})
diff --git a/src/components/chat/__tests__/the-prompt-window-is-the-prompt-window.test.ts b/src/components/chat/__tests__/the-prompt-window-is-the-prompt-window.test.ts
new file mode 100644
index 00000000..49a64b51
--- /dev/null
+++ b/src/components/chat/__tests__/the-prompt-window-is-the-prompt-window.test.ts
@@ -0,0 +1,244 @@
+/**
+ * THE RULE, and it is not negotiable:
+ *
+ * "Im Promptfenster darf nichts von Plaenen zu sehen sein.
+ * Das Promptfenster ist das Promptfenster."
+ *
+ * David has asked for this five times. Every previous round fixed ONE surface
+ * and the plan reappeared on the next one: G8-1 took the plan bar and the plan
+ * progress out of the Agent transcript, 2.6.6 C2 moved the plan out of the Code
+ * composer into the right-hand panel, and the Chat and Agent composer, plus the
+ * Approve-and-run card on Code, carried a plan the whole time regardless.
+ *
+ * So this file is not a sixth fix. It is the invariant: NO composer on ANY
+ * surface may import or render anything that shows a plan, checked over the
+ * whole component tree the composer is built from, not just the top level. A
+ * colleague who puts a plan back at the prompt box in six weeks gets this test
+ * red with David's sentence in the failure message.
+ *
+ * Three surfaces, two files: ChatView is both Chat and Agent (Agent is a toggle
+ * inside the LU tab, not a view of its own), CodexView is Code. ChatInput is
+ * the prompt window itself and is checked as a whole.
+ *
+ * Where a plan is allowed to be instead:
+ * - Code: the BOTTOM of the Explorer column (ExplorerPanel), plan progress
+ * and Approve-and-run together, below the tree and the file preview.
+ * - Chat and Agent: the header band above the transcript, with the other
+ * standing status controls. No right-hand column exists there.
+ *
+ * Run: npx vitest run src/components/chat/__tests__/the-prompt-window-is-the-prompt-window.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync, readdirSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve, basename } from 'node:path'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const COMPONENTS = resolve(here, '../..')
+const CHAT = resolve(here, '..')
+
+const DAVIDS_RULE =
+ 'Im Promptfenster darf nichts von Plaenen zu sehen sein. Das Promptfenster ist das Promptfenster.'
+
+const WHERE_IT_BELONGS =
+ 'The plan has a home: the BOTTOM of the Explorer column on Code (ExplorerPanel), ' +
+ 'and the header band above the transcript on Chat and Agent (ChatView). Put it there.'
+
+/** Every component file under src/components, by component name. */
+function componentFiles(dir: string, out: Record<string, string> = {}): Record<string, string> {
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
+ const full = resolve(dir, entry.name)
+ if (entry.isDirectory()) {
+ if (entry.name === '__tests__') continue
+ componentFiles(full, out)
+ continue
+ }
+ if (!entry.name.endsWith('.tsx')) continue
+ const name = basename(entry.name, '.tsx')
+ if (!/^[A-Z]/.test(name)) continue
+ out[name] = full
+ }
+ return out
+}
+
+const FILES = componentFiles(COMPONENTS)
+
+/**
+ * What counts as "showing a plan", derived from the tree rather than hardcoded,
+ * so a PlanFooBar.tsx added next year is banned the day it is created:
+ * - any component file whose name starts with "Plan"
+ * - the two stores a plan is read from, which catches a plan rendered inline
+ * without a component to name it
+ */
+const PLAN_COMPONENTS = Object.keys(FILES).filter((n) => n.startsWith('Plan'))
+const PLAN_STORE_READS = ['useTodoStore', 'planApprovalByConversation']
+
+/** The JSX/expression a prop is given, brace balanced from `prop={`. */
+function propValue(src: string, prop: string): string {
+ const start = src.indexOf(`${prop}={`)
+ if (start < 0) return ''
+ let i = start + prop.length + 1
+ let depth = 0
+ for (; i < src.length; i++) {
+ if (src[i] === '{') depth++
+ else if (src[i] === '}') {
+ depth--
+ if (depth === 0) return src.slice(start, i + 1)
+ }
+ }
+ return src.slice(start)
+}
+
+/** Locally rendered or imported component names, resolvable to a file. */
+function referenced(src: string): string[] {
+ const names = new Set<string>()
+ for (const m of src.matchAll(/<([A-Z][A-Za-z0-9_]*)/g)) names.add(m[1])
+ for (const m of src.matchAll(/^import\s*\{([^}]*)\}\s*from\s*'\.[^']*'/gm)) {
+ for (const part of m[1].split(',')) {
+ const name = part.replace(/\btype\b/, '').trim().split(/\s+as\s+/)[0].trim()
+ if (/^[A-Z]/.test(name)) names.add(name)
+ }
+ }
+ return [...names].filter((n) => FILES[n])
+}
+
+/** Anything in this source that shows a plan, named for the failure message. */
+function planSightings(src: string): string[] {
+ const hits: string[] = []
+ for (const name of PLAN_COMPONENTS) {
+ if (new RegExp(`<${name}[\\s/>]`).test(src)) hits.push(`renders <${name}>`)
+ else if (new RegExp(`\\b${name}\\b`).test(src)) hits.push(`imports ${name}`)
+ }
+ for (const read of PLAN_STORE_READS) {
+ if (src.includes(read)) hits.push(`reads the plan itself via ${read}`)
+ }
+ return hits
+}
+
+/**
+ * Walks the whole component tree a composer is built from and reports the first
+ * plan it finds, with the path that got there.
+ */
+function scanTree(roots: { label: string; src: string }[]): string[] {
+ const failures: string[] = []
+ const seen = new Set<string>()
+ const queue: { label: string; src: string }[] = [...roots]
+ while (queue.length > 0) {
+ const node = queue.shift()!
+ for (const hit of planSightings(node.src)) failures.push(`${node.label} ${hit}`)
+ for (const name of referenced(node.src)) {
+ if (seen.has(name)) continue
+ seen.add(name)
+ queue.push({ label: `${node.label} > ${name}`, src: readFileSync(FILES[name], 'utf8') })
+ }
+ }
+ return failures
+}
+
+const SURFACES = [
+ { surface: 'Chat and Agent (LU tab)', file: 'ChatView.tsx' },
+ { surface: 'Code (Code tab)', file: 'CodexView.tsx' },
+]
+const COMPOSER_PROPS = ['composerAbove', 'composerActions', 'composerModel']
+
+describe('the plan components the invariant is about', () => {
+ it('are found from the tree, not from a hardcoded list', () => {
+ // If this ever comes back empty the whole file passes vacuously.
+ expect(PLAN_COMPONENTS.sort()).toEqual(['PlanApprovalBar', 'PlanBar'])
+ })
+
+ it('offer no composer shape to reach for any more', () => {
+ const src = readFileSync(resolve(CHAT, 'PlanBar.tsx'), 'utf8')
+ expect(src).toMatch(/PlanBarVariant = 'header' \| 'panel'/)
+ expect(src).not.toMatch(/'composer'/)
+ })
+})
+
+describe('no composer on any surface shows a plan', () => {
+ for (const { surface, file } of SURFACES) {
+ it(`${surface}: nothing handed to the prompt box, at any depth, shows a plan`, () => {
+ const src = readFileSync(resolve(CHAT, file), 'utf8')
+ const roots = COMPOSER_PROPS.map((prop) => ({
+ label: `${file} ${prop}`,
+ src: propValue(src, prop),
+ })).filter((r) => r.src.length > 0)
+ // Sanity: the extraction has to have found something, or this test would
+ // pass by reading nothing at all.
+ expect(roots.map((r) => r.label)).toContain(`${file} composerAbove`)
+ expect(roots.find((r) => r.label === `${file} composerAbove`)!.src).toMatch(/<LoopBar/)
+
+ const failures = scanTree(roots)
+ expect(
+ failures,
+ `${failures.join('; ')}. ${DAVIDS_RULE} ${WHERE_IT_BELONGS}`,
+ ).toEqual([])
+ })
+ }
+
+ it('ChatInput, the prompt window itself, knows nothing about plans', () => {
+ const failures = scanTree([
+ { label: 'ChatInput.tsx', src: readFileSync(resolve(CHAT, 'ChatInput.tsx'), 'utf8') },
+ ])
+ expect(failures, `${failures.join('; ')}. ${DAVIDS_RULE} ${WHERE_IT_BELONGS}`).toEqual([])
+ })
+})
+
+describe('and nothing sits immediately at the prompt box either', () => {
+ // The subtree walk above only covers what is HANDED to ChatInput. A plan
+ // rendered as a sibling right above <ChatInput> would look identical to the
+ // user, so each surface also has to prove where its plan actually is.
+
+ it('the LU tab renders its plan in the header band, above the transcript', () => {
+ const src = readFileSync(resolve(CHAT, 'ChatView.tsx'), 'utf8')
+ const plan = src.indexOf('<PlanBar />')
+ const transcript = src.indexOf('<MessageList')
+ const composer = src.indexOf('<ChatInput')
+ expect(plan).toBeGreaterThan(-1)
+ expect(transcript).toBeGreaterThan(plan)
+ expect(composer).toBeGreaterThan(transcript)
+ // One plan on the surface, so "the other one" cannot quietly be at the box.
+ expect(src.match(/<PlanBar\b/g)).toHaveLength(1)
+ })
+
+ it('the Code tab has no plan in the view at all, panel only', () => {
+ const src = readFileSync(resolve(CHAT, 'CodexView.tsx'), 'utf8')
+ expect(src).not.toMatch(/PlanBar/)
+ expect(src).not.toMatch(/PlanApprovalBar/)
+ // The approve callback still leaves from here, because this view owns the
+ // send. Losing this line would leave an Approve button that runs nothing.
+ expect(src).toMatch(/<ExplorerPanel onApprovePlan=\{\(text\) => sendInstruction\(text\)\} \/>/)
+ })
+})
+
+describe('the Code panel keeps the plan at the bottom', () => {
+ // David, 2026-08-22: the plan sitting at the TOP of the column made no sense
+ // to him. Files first, plan as the footer of the column.
+ const src = readFileSync(resolve(CHAT, 'ExplorerPanel.tsx'), 'utf8')
+ const tree = src.indexOf('{rows.map((row) => {')
+ const preview = src.indexOf('<FilePreview')
+ const approval = src.indexOf('<PlanApprovalBar')
+ const plan = src.indexOf('<PlanBar variant="panel" />')
+
+ it('below the file tree', () => {
+ expect(tree).toBeGreaterThan(-1)
+ expect(approval).toBeGreaterThan(tree)
+ expect(plan).toBeGreaterThan(tree)
+ })
+
+ it('below the file preview, so it is the last section in the column', () => {
+ expect(preview).toBeGreaterThan(-1)
+ expect(approval).toBeGreaterThan(preview)
+ expect(plan).toBeGreaterThan(preview)
+ })
+
+ it('with the approval card, which came down from the composer with it', () => {
+ expect(src).toMatch(/<PlanApprovalBar onApprove=\{onApprovePlan\} \/>/)
+ })
+
+ it('and a collapsed column still says a plan is waiting', () => {
+ // The column can be collapsed to a 7px rail. Without this the only
+ // Approve-and-run button in the app would be unreachable.
+ expect(src).toMatch(/data-testid="explorer-plan-waiting"/)
+ expect(src).toMatch(/A plan is waiting for your approval/)
+ })
+})
diff --git a/src/lib/transcript-visibility.ts b/src/lib/transcript-visibility.ts
index e305498b..2d29be9f 100644
--- a/src/lib/transcript-visibility.ts
+++ b/src/lib/transcript-visibility.ts
@@ -9,7 +9,8 @@
* haben."
*
* `todo_write` is the agent maintaining its own plan, and the plan already has
- * a home: PlanBar, pinned above the composer, always current, one glance. Every
+ * a home: PlanBar, in the header band on LU and at the bottom of the Explorer
+ * column on Code, always current, one glance. Every
* card the tool ALSO drops into the transcript repeats that list in full.
* Captured on the installed build during a 30 step run: the plan text was
* sitting in the transcript between the steps, and on a run that revises its