From 7ff04919d00a0af7961ba1287cbe342e54af20e1 Mon Sep 17 00:00:00 2001 From: Jake Hoffner Date: Thu, 5 Nov 2026 14:19:44 -0500 Subject: [PATCH 1/2] feat(claude-code-style): open a thread as a sheet in threads mode Threads mode opened a thread by replacing the board in the right pane with an in-pane view and a back arrow. Session mode already opens a background task as a flyout sheet over the main thread. Threads mode now uses the same Sheet, and the board stays in the pane behind it. - Sheet takes its scroll feed from the opener instead of creating it, since the thread composer needs the same feed to scroll after a send. - ThreadView renders as a Sheet: the action row and Pin sit at the top of the body, the question, review card and composer in the footer. - ThreadsBoard no longer early-returns the thread view in place of the board. - Tests query the thread as a dialog and close it with the sheet's Close button; one new test covers opening, the board staying put, and Esc. - README describes the sheet. Supersedes the "thread view replaces the board" decision in FIX-2157's DECISIONS.md, which copied the original app's in-pane layout. The spec is left as history. Co-Authored-By: Claude Haiku 5.5 --- labs/claude-code-style/README.md | 2 +- .../src/components/Sheet.tsx | 17 +- .../src/components/TasksPane.tsx | 3 + .../src/components/ThreadView.tsx | 197 +++++++++--------- .../src/components/ThreadsBoard.tsx | 28 ++- labs/claude-code-style/test/address.test.tsx | 4 +- .../test/mutation-buttons.test.tsx | 6 +- .../test/task-actions.test.tsx | 2 +- .../test/threads-screen.test.tsx | 34 ++- 9 files changed, 157 insertions(+), 136 deletions(-) diff --git a/labs/claude-code-style/README.md b/labs/claude-code-style/README.md index 3e0832c028..a07fc2e0dc 100644 --- a/labs/claude-code-style/README.md +++ b/labs/claude-code-style/README.md @@ -50,7 +50,7 @@ threads, each a task in a session of its own, and the right pane is the status b - **The page's address** names the view, the open session and the task open in its pane (`?session=&task=`), so a reload or a link reopens them, and Back returns to what you had open before. A link to a session or task that is gone opens *New session* instead. -- **A thread's view** replaces the board, with a back arrow. You can talk in it: your line steers +- **A thread's view** opens as a sheet over the main thread, the same flyout a session's background task opens in, and the board stays in the pane beside it. You can talk in it: your line steers the thread's task and answers its open question. Cmd+Enter (Ctrl+Enter) answers, or requests changes when it is ready for review; plain Enter is a new line. You can pin it there. Under its header, the same actions as a sheet's, without the *Steer* box, since the composer steers. diff --git a/labs/claude-code-style/src/components/Sheet.tsx b/labs/claude-code-style/src/components/Sheet.tsx index ea935d81f3..e7e3ad92e3 100644 --- a/labs/claude-code-style/src/components/Sheet.tsx +++ b/labs/claude-code-style/src/components/Sheet.tsx @@ -1,4 +1,4 @@ -import { useJumpToLatest } from "@flow-state-dev/react"; +import type { JumpToLatest } from "@flow-state-dev/react"; import { createContext, useContext, useEffect, useState, type ReactNode } from "react"; import { createPortal } from "react-dom"; import { JumpToLatestButton } from "./JumpToLatest"; @@ -31,25 +31,26 @@ export function SheetArea({ children }: { children: ReactNode }) { } /** - * A read-only sheet over the main thread. It closes with its close button, - * Esc, or a click on the main thread around it. What it shows is the opener's - * to keep live; the sheet only frames it. + * A sheet over the main thread. It closes with its close button, Esc, or a + * click on the main thread around it. What it shows is the opener's to keep + * live; the sheet only frames it. The opener owns the scrolling feed (`feed`), + * since it also needs it to scroll after its own sends. */ -export function Sheet({ label, title, subtitle, onClose, children, footer }: { +export function Sheet({ label, title, subtitle, onClose, feed, children, footer }: { /** The sheet's accessible name. */ label: string; title: ReactNode; subtitle?: ReactNode; onClose: () => void; + /** The opener's `useJumpToLatest` for the body: the sheet opens on the latest of what it shows. */ + feed: JumpToLatest; children: ReactNode; footer?: ReactNode; }) { const { host } = useContext(SheetHost); - // Opens on the latest of the work it shows; what arrives after waits below the arrow. - const feed = useJumpToLatest(); useEffect(() => { // Capture phase, and the Esc is spent: it closed the sheet, so it never also counts toward stopping the turn. - // Every Esc while the sheet is open closes it, from any focus: the sheet is read-only and holds no text field. + // Every Esc while the sheet is open closes it, from any focus, its text boxes included. A draft is kept per task, so a close loses no words. const onKey = (event: KeyboardEvent) => { if (event.key !== "Escape") return; event.preventDefault(); diff --git a/labs/claude-code-style/src/components/TasksPane.tsx b/labs/claude-code-style/src/components/TasksPane.tsx index d0ad1688ad..a8911c6fa0 100644 --- a/labs/claude-code-style/src/components/TasksPane.tsx +++ b/labs/claude-code-style/src/components/TasksPane.tsx @@ -1,3 +1,4 @@ +import { useJumpToLatest } from "@flow-state-dev/react"; import { useCallback, useMemo } from "react"; import type { LabAdapter, TaskRow, TaskStatus } from "../adapter"; import { TASK_STATUS } from "../lib/task-status"; @@ -98,10 +99,12 @@ function TaskSheet({ adapter, sessionId, task, onClose }: { adapter: LabAdapter; (emit: Parameters[2]) => adapter.watchTaskWork(sessionId, task.id, emit), [adapter, sessionId, task.id], ); + const feed = useJumpToLatest(); const status = TASK_STATUS[task.status]; return ( diff --git a/labs/claude-code-style/src/components/ThreadView.tsx b/labs/claude-code-style/src/components/ThreadView.tsx index 3223ba337d..51f3cc1071 100644 --- a/labs/claude-code-style/src/components/ThreadView.tsx +++ b/labs/claude-code-style/src/components/ThreadView.tsx @@ -4,38 +4,39 @@ import type { LabAdapter, TaskRow } from "../adapter"; import { useWatch } from "../lib/use-watch"; import { useDraftSend } from "../lib/use-draft-send"; import { Entry } from "./Entry"; -import { JumpToLatestButton } from "./JumpToLatest"; import { LoadEarlier } from "./LoadEarlier"; import { ReviewCard } from "./ReviewCard"; +import { Sheet } from "./Sheet"; import { ErrorBody } from "./flow-state/error"; import { Spend } from "./flow-state/spend"; import { TaskActions } from "./flow-state/task-actions"; import { HarnessTag, statusColumn, statusLine, ThreadIcon } from "./ThreadStatus"; /** - * One task, in place of the board. Its work reads the task's run session. - * You can talk inside a task (spec D3): your line is a steer on it, and - * answers its open question when it has one. When it is ready for - * review, *Resolve* accepts it and *Request changes* sends your words back. - * Under the header, the task's action row: Cancel and Release - * while it is open, Retry once it failed or was cancelled. It has no Steer - * box, since the composer steers. A failed task's error shows as an error. - * A finished task's composer is off. - * Cmd+Enter (Ctrl+Enter) does what the box's main button does: answer or send, - * or request changes when it is ready for review. Plain Enter is a new line. + * One task, as a sheet over the main thread, the same flyout session mode's + * background tasks open in. Its work reads the task's run session. You can + * talk inside a task (spec D3): your line is a steer on it, and answers its + * open question when it has one. When it is ready for review, *Resolve* + * accepts it and *Request changes* sends your words back. Under the header, + * the task's action row: Cancel and Release while it is open, Retry once it + * failed or was cancelled, and Pin beside them. It has no Steer box, since the + * composer steers. A failed task's error shows as an error. A finished task's + * composer is off. Cmd+Enter (Ctrl+Enter) does what the box's main button + * does: answer or send, or request changes when it is ready for review. Plain + * Enter is a new line. Esc closes the sheet, as it does from anywhere in it. */ export function ThreadView({ adapter, sessionId, task, pinned, - onBack, + onClose, }: { adapter: LabAdapter; sessionId: string; task: TaskRow; pinned: boolean; - onBack: () => void; + onClose: () => void; }) { const work = useWatch( (emit: Parameters[2]) => adapter.watchTaskWork(sessionId, task.id, emit), @@ -78,105 +79,109 @@ export function ThreadView({ }; return ( -