From 8be91eb853aead777964c4b04f0304d8e95a5263 Mon Sep 17 00:00:00 2001 From: Daniel Rispler Date: Wed, 2 Dec 2026 11:13:33 +0200 Subject: [PATCH 1/3] Studio: a round's step quotes the context its question builds on, says what the agent left out, and asks for it in one click (#1054) Co-Authored-By: Claude Sonnet 5.5 --- core/src/session.rs | 10 +- docs/studio/CONTEXT.md | 2 +- docs/studio/behaviour/cards.md | 5 +- scripts/snap/base.ts | 1 + scripts/snap/fixtures-panel.ts | 2 +- scripts/snap/rail-fixtures.ts | 2 +- server/src/api.rs | 6 ++ server/src/lib.rs | 14 +++ server/tests/web.rs | 23 ++++- server/tests/wire.rs | 1 + ui/rounds.ts | 94 +++++++++++++++++-- ui/style.css | 9 ++ ui/tests/full-text.test.mjs | 1 + ui/tests/rounds.test.mjs | 65 ++++++++++++- ui/types.ts | 4 + understanding/src/rounds.rs | 46 ++++++++- understanding/tests/fixtures/stored/README.md | 4 + .../tests/fixtures/stored/full-9/rounds.json | 52 ++++++++++ understanding/tests/stored_fixtures.rs | 41 ++++++++ understanding/tests/turn_writing.rs | 87 ++++++++++++++++- 20 files changed, 443 insertions(+), 26 deletions(-) create mode 100644 understanding/tests/fixtures/stored/full-9/rounds.json diff --git a/core/src/session.rs b/core/src/session.rs index b0166564..6c227e91 100644 --- a/core/src/session.rs +++ b/core/src/session.rs @@ -1611,14 +1611,16 @@ impl Session { /// Daniel's first prompt that the agent reads after the turn that ended at `after`: one a turn that started after it /// took, or else one queued for the next turn, which starts after every ended turn (spec #998). A prompt queued - /// during a turn is read when the turn that takes it starts, not when it was typed. - pub fn daniels_prompt_after(&self, after: u64) -> Option<&Prompt> { + /// during a turn is read when the turn that takes it starts, not when it was typed. A prompt whose text `skip` says + /// is not one he is looking for (a follow-up that asks for more, #1054) is passed over. + pub fn daniels_prompt_after(&self, after: u64, skip: impl Fn(&str) -> bool) -> Option<&Prompt> { let read_at = |p: &Prompt| { let turn = p.turn.and_then(|t| self.turns.get(t)); p.at.max(turn.map_or(0, |t| t.started_at)) }; - let taken = (self.prompts.iter()).find(|p| p.sender.is_daniels() && read_at(p) > after); - taken.or_else(|| self.queued.iter().find(|p| p.sender.is_daniels())) + let his = |p: &&Prompt| p.sender.is_daniels() && !skip(&p.text); + let taken = (self.prompts.iter()).find(|p| his(p) && read_at(p) > after); + taken.or_else(|| self.queued.iter().find(his)) } /// Where the call an ask written at `asked_ms` names stands, matched as `Block::asks` matches it (#892). A block diff --git a/docs/studio/CONTEXT.md b/docs/studio/CONTEXT.md index 0122d869..323abd25 100644 --- a/docs/studio/CONTEXT.md +++ b/docs/studio/CONTEXT.md @@ -233,7 +233,7 @@ Where Daniel answers a **Round**, in the **Plan view**'s place when no plan wait _Avoid_: Round view, question card (the docked `AskUserQuestion` card) **Round**: -The questions a planning or triage turn's reply asks Daniel, which the summaries writer extracts at the turn's end, quoting every question, recommendation and option from the reply, and giving each option a short name and hint (spec #967). Code checks each quote: a failed option is dropped, while a failed question or recommendation marks its question for the terminal and turns "Accept all" off. The understanding layer keeps each round per session, after the session ends too, with its status (extracting, failed, open, answered or closed), its questions and its answer's source: the page's form, a prompt read by the terminal's rules, or a prompt kept raw. A round with at least one question that survives the check makes its session **Needs you**, through a line in the event log; one with none is closed and logs nothing. Daniel's next prompt answers an open round, from the reply the page copied or the terminal's rules, and one they can't read is kept raw and closes it; a newer round closes it unanswered. A wake-up leaves it open, and the turn the wake-up opened joins it (spec #998): that turn's round carries its questions and adds the turn's new ones, and the older round is closed as joined. The **Planning view** is where he answers it, with **Send** or a copy, and answered rounds join **Context mode**'s decisions. +The questions a planning or triage turn's reply asks Daniel, which the summaries writer extracts at the turn's end, quoting every question, recommendation, option and the part of the reply a question builds on (its context, #1054), and giving each option a short name and hint (spec #967). Code checks each quote: a failed option or context is dropped, while a failed question or recommendation marks its question for the terminal and turns "Accept all" off. A question the agent made no recommendation on offers "Ask for a recommendation", a short follow-up prompt sent or copied the way the reply is, which leaves the round open (it is not Daniel's answer). The understanding layer keeps each round per session, after the session ends too, with its status (extracting, failed, open, answered or closed), its questions and its answer's source: the page's form, a prompt read by the terminal's rules, or a prompt kept raw. A round with at least one question that survives the check makes its session **Needs you**, through a line in the event log; one with none is closed and logs nothing. Daniel's next prompt answers an open round, from the reply the page copied or the terminal's rules, and one they can't read is kept raw and closes it; a newer round closes it unanswered. A wake-up leaves it open, and the turn the wake-up opened joins it (spec #998): that turn's round carries its questions and adds the turn's new ones, and the older round is closed as joined. The **Planning view** is where he answers it, with **Send** or a copy, and answered rounds join **Context mode**'s decisions. _Avoid_: Form (the page's answers to a round), Quiz (retired) **Planned part**: diff --git a/docs/studio/behaviour/cards.md b/docs/studio/behaviour/cards.md index 8d70cfae..c0d4ba94 100644 --- a/docs/studio/behaviour/cards.md +++ b/docs/studio/behaviour/cards.md @@ -46,10 +46,11 @@ A round (spec #967, "Rounds and replies"; ticket #976) is answered by a prompt, - **`rounds`** lists a session's rounds, oldest first, each with its status and its answer, for the planning view and "Decided so far". - **`round_reply`** takes the form's answers (one pick per question: an option, the recommendation, Daniel's own words, or skipped; and a note) and returns the reply, so the page holds it before any click and the clipboard write happens inside it. The reply is one function in the understanding layer (`Round::reply`), so Send and Copy & Jump send the same bytes: one line per answered question, with the agent's label (`Q6: Memory`) or, with none, its position (`2. Keep it`); a picked option by its name; the recommendation by the name of the option it names, else in the agent's words ("your recommendation" for a question with none); Daniel's own text as typed, newlines kept; a skipped question left out; the note last, on its own line. +- **`round_follow_up`** takes a round's turn and a question's position and returns the prompt that asks the agent for its recommendation on it (`Round::follow_up`), the same bytes whether it is sent or copied. It changes nothing the round keeps. - **`round_copied`** keeps the reply, and the answers that made it, as the one the page copied, for an open round only. - **`round_send`** sends the reply with the switchboard's `send` ([the rail](rail.md), "Send") and records the round `answered`, source `form`, the moment `hc send` succeeds. While it sends, the reply is kept as copied, so the sent prompt, if it is read first, records the same answers; a refused or failed send puts back what the round had copied before, still `open`, unless a Copy & Jump made while it waited replaced it, which stays; and answers the reason. -**Reading the next prompt.** Each prompt read live (the core's `Prompted` output) reads the session's open rounds on its turn-writing queue, after the round's own job, against Daniel's first prompt after the round's turn. A prompt queued while a turn runs is read by the turn that takes it, so it counts from when that turn starts, and while it still waits queued it comes after every ended turn: a prompt Daniel queues during a wake-up's turn answers the open round, and the questions that turn adds, whichever comes first, the next turn or that turn's round job (`Session::daniels_prompt_after`). A wake-up is not Daniel's answer (spec #998): it leaves the round open, and the turn it opens joins its questions to it (below). Daniel's prompt answers it: +**Reading the next prompt.** Each prompt read live (the core's `Prompted` output) reads the session's open rounds on its turn-writing queue, after the round's own job, against Daniel's first prompt after the round's turn. A prompt queued while a turn runs is read by the turn that takes it, so it counts from when that turn starts, and while it still waits queued it comes after every ended turn: a prompt Daniel queues during a wake-up's turn answers the open round, and the questions that turn adds, whichever comes first, the next turn or that turn's round job (`Session::daniels_prompt_after`). A wake-up is not Daniel's answer (spec #998): it leaves the round open, and the turn it opens joins its questions to it (below). Nor is a follow-up that asks for a recommendation (#1054, below): a prompt that starts "What do you recommend for " and ends in "?" on one line is passed over, so the round stays open for his first prompt after it. Daniel's prompt answers it: - A prompt equal to the copied reply, once both lose their `` and `` tags, their line ends' trailing whitespace and their outer whitespace, records the form's answers, source `form`. - Otherwise the rules read it, with no model, source `terminal-rules`: "yes", "all" or "go with your recommendations" (any case, a closing `.` or `!` dropped) takes every recommendation; else each line that starts with a question's label or position followed by `:`, `.` or `)` answers it, the lines after it, up to the next such line, going on its answer, and text before the first is the note. A line's answer is an option when it is that option's name, the recommendation when it is its words, "yes" or "recommended" (for a question that has one) or "your recommendation", and else Daniel's own words; a question no line names is skipped. @@ -60,7 +61,7 @@ A round (spec #967, "Rounds and replies"; ticket #976) is answered by a prompt, - **When it opens.** The round is the session's newest, from its newest turn, while it is `extracting`, `open` or `failed`; a later prompt of Daniel's ends it. An open round stays live, and answerable, through the turns wake-ups open after it: Send waits as whenever the agent is busy, and Copy works. When the round they join arrives, it takes the form's picks by each question's label or text; an option pick, or a pick of the recommendation, keeps the option of the same name (the recommendation while that option is still the one it names), and a pick of a recommendation no option holds stays while the agent's words are the same; otherwise the question goes back to untouched. So a pick never becomes another answer because the agent now recommends something else. It shows as a waiting plan does (Q35): at once in Decision mode, or when the round was there when Daniel selected the session; otherwise, under the rail's hold, the dock shows one row, "N questions waiting: open the planning view" ("Reading the questions: …" or "The questions could not be read: …" before it opens), which opens it. Several pending asks stack in the dock: the round's row beside a permission or a question. "Back to the story" leaves it in the dock. - **Minimized and full size** (spec #998, ticket #1005). In the panel a round with questions is the minimized view: "Back to the story", "N questions · ★ the agent's pick" and ⤢ on one line, then one line per question (its number, its title, its current answer, ★ on a recommendation Daniel hasn't touched; an answered or closed round's line is its answer), then the bar, so Send works from it. It is as tall as what it holds, and over the map the left panel ends under it, so it never scrolls. Nothing opens full size by itself: Daniel opens it with ⤢, a line (at its question), the dock's row, or a press on its session: its row in the list or on the map (its Needs you included), or the top bar's Needs you. A press on a session opens its open round full size once the session's rounds are known, under the rail's Context mode too, as the dock's row does; a press that finds no open round, or a session left before its rounds came, asks nothing more, so a round that arrives later shows minimized. Full size is a modal `` over the map (`showModal()`, `closedby="any"`, and a press and release both outside it where the browser lacks `closedby`): the session's name, which holds its issue once, its planning state and how many questions, ⤡, then the stepper and the step below and the bar. The focus opens on the question. Esc, a click outside or ⤡ closes it to the minimized view, the focus on the line of the question it showed. A redraw keeps it open, its form, the focus and a typed answer's caret; it closes when the round leaves the view (Send, a later prompt of Daniel's, a waiting plan). A wake-up's join keeps it open on the joined round. A round still read, or whose read failed, shows its message in the panel instead, as below, and has no full size. -- **The stepper and the steps.** One number per question: the agent's label without its "Q" (`Q8` is 8), or its position when it has none. The current one is filled; one whose answer is no longer the untouched default is ringed in the needs-you colour. There is no review step. Each step is card B, "side by side" (spec #998): a label line ("Question 1 of 2", the planning or triage state, the agent's label, the question's category as a chip, and a "new" chip on a question a wake-up's turn `added`), the title (the writer's `title`, its markdown rendered inline, else the question's text), the `dilemma` and the `example` as a quote line, then one column per option: its short name with a "recommended" pill, its hint (what it does), "In the example" with its `outcome`, a **Pick** button (**Picked** once it is Daniel's own answer) and a **+** that opens the option's trade-off in the agent's words under the column. A field the writer left empty draws no line, so a round stored before spec #998 shows the question text and the hints. The recommended option is the one the recommendation names, which the writer names and the server keeps on the question (`recommended`: else its quote or name in the recommendation's words, word for word, or its "(b)" tag); a recommendation no option holds is no column: it is one full line, "Agent recommends: …", with its own Pick, and an untouched question sends it all the same. "Decided so far" and an answered step write a recommendation taken by that option's name too. The recommendation is pre-selected, tinted and dashed (no hover hint says so); an option Daniel picked or confirmed takes a solid edge. Then "Why