Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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 <noreply@anthropic.com>
  • Loading branch information
jhoffner and claude committed Nov 5, 2026
commit 7ff04919d00a0af7961ba1287cbe342e54af20e1
2 changes: 1 addition & 1 deletion labs/claude-code-style/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<id>&task=<id>`), 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.
Expand Down
17 changes: 9 additions & 8 deletions labs/claude-code-style/src/components/Sheet.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions labs/claude-code-style/src/components/TasksPane.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -98,10 +99,12 @@ function TaskSheet({ adapter, sessionId, task, onClose }: { adapter: LabAdapter;
(emit: Parameters<LabAdapter["watchTaskWork"]>[2]) => adapter.watchTaskWork(sessionId, task.id, emit),
[adapter, sessionId, task.id],
);
const feed = useJumpToLatest();
const status = TASK_STATUS[task.status];
return (
<Sheet
label={`Work: ${task.title}`}
feed={feed}
title={
<span className="flex items-center gap-2">
<span className={cn("size-2 shrink-0 rounded-full", status.dot, task.status === "in_progress" && "animate-pulse")} />
Expand Down
197 changes: 101 additions & 96 deletions labs/claude-code-style/src/components/ThreadView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<LabAdapter["watchTaskWork"]>[2]) => adapter.watchTaskWork(sessionId, task.id, emit),
Expand Down Expand Up @@ -78,105 +79,109 @@ export function ThreadView({
};

return (
<aside aria-label={`Task: ${task.title}`} className="flex h-full min-h-0 flex-col bg-inspector">
<div className="flex items-center gap-2 border-b border-border px-3 py-3">
<button type="button" aria-label="Back to tasks" onClick={onBack} className="px-1 text-sm hover:bg-accent">
←
</button>
<ThreadIcon task={task} />
<h2 className="min-w-0 flex-1 truncate text-sm font-semibold">{task.title}</h2>
<HarnessTag task={task} />
<Sheet
label={`Task: ${task.title}`}
feed={feed}
onClose={onClose}
title={
<span className="flex min-w-0 items-center gap-2">
<ThreadIcon task={task} />
<span className="truncate">{task.title}</span>
<HarnessTag task={task} />
</span>
}
subtitle={<Spend spend={task.spend} split />}
footer={
<div className="flex flex-col gap-2">
{question ? (
<div role="note" className="border border-attention bg-attention/10 px-3 py-2 text-sm [overflow-wrap:anywhere]">
<span className="font-semibold">Waiting on you</span> · {question.prompt}
</div>
) : null}
{column === "review" ? <ReviewCard task={task} review={work?.review} /> : null}
{finished ? (
<p role="note" className="text-xs text-muted-foreground">
This task is finished.
</p>
) : (
<form onSubmit={say}>
<textarea
aria-label="Message this task"
rows={2}
value={text}
onChange={(event) => setText(event.target.value)}
onKeyDown={onKeyDown}
placeholder={question ? "Answer the task…" : column === "review" ? "What should change…" : "Say something in this task…"}
className="block w-full resize-none border border-border bg-card px-3 py-2 text-sm outline-none focus:border-ring"
/>
{failure !== undefined ? (
<p role="alert" className="mt-1 text-xs text-destructive">
Not sent: {failure} ·{" "}
<button type="button" className="underline" onClick={() => (column === "review" ? requestChanges() : say())}>
Retry
</button>
</p>
) : null}
{resolve.error === undefined ? null : (
<p role="alert" className="mt-1 text-xs text-destructive">
Couldn't resolve: {resolve.error}
</p>
)}
<div className="mt-2 flex justify-end gap-1.5">
{column === "review" ? (
<>
<button
type="button"
disabled={held}
onClick={() => void resolve.submit(undefined)}
className="bg-primary px-2 py-1 text-xs font-semibold text-primary-foreground disabled:opacity-40"
>
{resolve.busy ? "Resolving…" : "Resolve"}
</button>
<button type="button" disabled={!words || held} onClick={requestChanges} className="border border-border px-2 py-1 text-xs disabled:opacity-40">
Request changes
</button>
</>
) : (
<button type="submit" disabled={!words || held} className="bg-primary px-2 py-1 text-xs font-semibold text-primary-foreground disabled:opacity-40">
{question ? "Answer" : "Send"}
</button>
)}
</div>
</form>
)}
</div>
}
>
<div className="flex flex-wrap items-center gap-2">
{/* No Steer box: the composer below steers the task. */}
<TaskActions key={task.id} id={task.id} status={task.status} actions={actions} />
<button
type="button"
aria-pressed={pinned}
disabled={pin.busy}
onClick={() => void pin.submit(undefined)}
className="border border-border px-1.5 text-xs hover:bg-accent disabled:opacity-40"
className="ml-auto border border-border px-1.5 text-xs hover:bg-accent disabled:opacity-40"
>
{pinned ? "Unpin" : "Pin"}
</button>
</div>
{pin.error === undefined ? null : (
<p role="alert" className="px-4 pt-2 text-xs text-destructive">
<p role="alert" className="text-xs text-destructive">
Couldn't {pinned ? "unpin" : "pin"}: {pin.error}
</p>
)}
{/* No Steer box: the composer below steers the task. */}
<div className="px-4 pt-2 empty:hidden">
<TaskActions key={task.id} id={task.id} status={task.status} actions={actions} />
</div>
{task.status === "errored" && task.error !== undefined ? (
<div role="alert" className="mx-4 mt-2 flex flex-col gap-1 border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive">
<div role="alert" className="flex flex-col gap-1 border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive">
<ErrorBody message={task.error} />
</div>
) : null}
{/* Ready for review is said once, by its card above the composer. */}
{column === "review" ? null : <div className="px-4 pt-2 text-xs text-muted-foreground [overflow-wrap:anywhere]">{statusLine(task)}</div>}
<Spend spend={task.spend} split className="px-4" />
<div ref={feed.ref} className="flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-y-auto px-4 pt-2 pb-8 [overflow-wrap:anywhere]">
<LoadEarlier load={work?.loadEarlier} />
{work?.entries.map((entry) => (
<Entry key={entry.id} entry={entry} mark={entry.kind === "user" ? feed.mine(entry.id) : undefined} />
))}
<JumpToLatestButton feed={feed} />
</div>
{question ? (
<div role="note" className="mx-3 border border-attention bg-attention/10 px-3 py-2 text-sm [overflow-wrap:anywhere]">
<span className="font-semibold">Waiting on you</span> · {question.prompt}
</div>
) : null}
{column === "review" ? <ReviewCard task={task} review={work?.review} /> : null}
{finished ? (
<p role="note" className="px-4 py-3 text-xs text-muted-foreground">
This task is finished.
</p>
) : (
<form onSubmit={say} className="px-3 py-3">
<textarea
aria-label="Message this task"
rows={2}
value={text}
onChange={(event) => setText(event.target.value)}
onKeyDown={onKeyDown}
placeholder={question ? "Answer the task…" : column === "review" ? "What should change…" : "Say something in this task…"}
className="block w-full resize-none border border-border bg-card px-3 py-2 text-sm outline-none focus:border-ring"
/>
{failure !== undefined ? (
<p role="alert" className="mt-1 text-xs text-destructive">
Not sent: {failure} ·{" "}
<button type="button" className="underline" onClick={() => (column === "review" ? requestChanges() : say())}>
Retry
</button>
</p>
) : null}
{resolve.error === undefined ? null : (
<p role="alert" className="mt-1 text-xs text-destructive">
Couldn't resolve: {resolve.error}
</p>
)}
<div className="mt-2 flex justify-end gap-1.5">
{column === "review" ? (
<>
<button
type="button"
disabled={held}
onClick={() => void resolve.submit(undefined)}
className="bg-primary px-2 py-1 text-xs font-semibold text-primary-foreground disabled:opacity-40"
>
{resolve.busy ? "Resolving…" : "Resolve"}
</button>
<button type="button" disabled={!words || held} onClick={requestChanges} className="border border-border px-2 py-1 text-xs disabled:opacity-40">
Request changes
</button>
</>
) : (
<button type="submit" disabled={!words || held} className="bg-primary px-2 py-1 text-xs font-semibold text-primary-foreground disabled:opacity-40">
{question ? "Answer" : "Send"}
</button>
)}
</div>
</form>
)}
</aside>
{/* Ready for review is said once, by its card in the footer. */}
{column === "review" ? null : <div className="text-xs text-muted-foreground [overflow-wrap:anywhere]">{statusLine(task)}</div>}
<LoadEarlier load={work?.loadEarlier} />
{work?.entries.map((entry) => (
<Entry key={entry.id} entry={entry} mark={entry.kind === "user" ? feed.mine(entry.id) : undefined} />
))}
Comment on lines +183 to +185

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve wrapping for task-thread messages

When a task message contains a long URL or unbroken identifier, moving these entries into Sheet removes the previous feed's inherited overflow-wrap:anywhere. The sheet body has no equivalent rule, and Entry's user-message bubble only sets whitespace-pre-wrap, so text now overflows the bubble and requires horizontal scrolling instead of wrapping. Preserve the wrapping rule on the thread content when rendering it inside the sheet.

Useful? React with 👍 / 👎.

</Sheet>
);
}
28 changes: 13 additions & 15 deletions labs/claude-code-style/src/components/ThreadsBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const rowNote = (task: TaskRow) =>
* Threads mode's right pane: the status board, titled *Tasks*. Every row is
* one task row of the session's board, grouped by what you owe it (the
* columns table), and pinned ones on top. Each group has a count and
* collapses; *Resolved* starts collapsed. Opening a thread replaces the board
* with its view, with a back arrow; the main thread stays in the center.
* collapses; *Resolved* starts collapsed. Opening a thread draws its view as a
* sheet over the main thread, as session mode's tasks open; the board stays
* in the pane behind it.
*/
export function ThreadsBoard({
adapter,
Expand All @@ -40,19 +41,6 @@ export function ThreadsBoard({
const now = useNow(true, 30_000);

const open = tasks.find((t) => t.id === openId);
if (open) {
return (
<ThreadView
key={open.id}
adapter={adapter}
sessionId={sessionId}
task={open}
pinned={pins.includes(open.id)}
onBack={() => onOpen(undefined)}
/>
);
}

const groups = COLUMNS.map((column) => ({
...column,
rows: tasks.filter((t) => columnOf(t, pins.includes(t.id)) === column.id),
Expand Down Expand Up @@ -115,6 +103,16 @@ export function ThreadsBoard({
})}
</div>
)}
{open ? (
<ThreadView
key={open.id}
adapter={adapter}
sessionId={sessionId}
task={open}
pinned={pins.includes(open.id)}
onClose={() => onOpen(undefined)}
/>
) : null}
</aside>
);
}
4 changes: 2 additions & 2 deletions labs/claude-code-style/test/address.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ describe("the page's address", () => {
const card = await within(thread()).findByRole("region", { name: "Task: Vendor B · regions" });
await waitFor(() => expect(within(card).getByRole("button", { name: /View thread|Answer/ })).toBeTruthy());
fireEvent.click(within(card).getByRole("button", { name: /View thread|Answer/ }));
expect(screen.getByRole("complementary", { name: "Task: Vendor B · regions" })).toBeTruthy();
expect(screen.getByRole("dialog", { name: "Task: Vendor B · regions" })).toBeTruthy();

reload(adapter);
expect(await screen.findByRole("complementary", { name: "Task: Vendor B · regions" })).toBeTruthy();
expect(await screen.findByRole("dialog", { name: "Task: Vendor B · regions" })).toBeTruthy();
expect(tab("Projects").getAttribute("aria-selected")).toBe("true");
expect(within(thread()).getAllByText(/Research three vendors/).length).toBeGreaterThan(0);
});
Expand Down
Loading
Loading