Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 6 additions & 4 deletions core/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/studio/CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:
Expand Down
5 changes: 3 additions & 2 deletions docs/studio/behaviour/cards.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<pasted_content …>` and `<hc from=…>` 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.
Expand All @@ -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 `<dialog>` 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 <option>: <why>" when the question has a `why` and recommends something ("Why: <why>" beside a recommendation no option holds); a question that recommends nothing shows no why. Under the columns: "write my own" (a box whose text is the answer), "skip" ("undo skip") and "why?", which opens the agent's whole message; then Back and "Next: Q9". A question that failed the check says to answer it in the terminal and has no rows; a question with dropped options says how many.
- **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 the question's `context` (#1054: the part of the reply it builds on, quoted by the writer, at most a few sentences, shown as a quote folded to two lines, with "Show more" / "Show less" once it is longer than about two lines; nothing when it is empty), 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 <option>: <why>" when the question has a `why` and recommends something ("Why: <why>" beside a recommendation no option holds); a question that recommends nothing shows no why, and says "The agent gave no recommendation" with **Ask for a recommendation** (#1054). That action sends a short follow-up prompt, "What do you recommend for Q7?", naming the question by the agent's label, else its title, else its position (`round_follow_up`, held before the click so the copy happens inside it), the way the reply goes: **Send** in Herdr past the guard, else Copy & Jump or Copy reply. The round stays open and the status line says "Asked the agent for a recommendation on Q7" or "Copied the request for a recommendation on Q7: paste it in the terminal"; the agent's next turn makes a new round, which closes this one. Under the columns: "write my own" (a box whose text is the answer), "skip" ("undo skip") and "why?", which opens the agent's whole message; then Back and "Next: Q9". A question that failed the check says to answer it in the terminal and has no rows; a question with dropped options says how many.
- **The bar** answers the whole round from any step: one status line, then the buttons by where the session runs. The status line is a failed send, copy or reply while the view is full size, "Sending…", "Copied: paste it in the terminal", why Send is off ("Send is off: The agent is busy"), why there is no Jump ("No jump: …"), else "Waiting for your answers" or how many questions Daniel answered ("1 of 4 answered"). In Herdr.app, **Copy & Jump** and **Send in Herdr**, disabled with the guard's reason until `send_guard` passes; in another terminal the Jump knows, **Copy & Jump**; elsewhere **Copy reply**. Then **Accept all**, which takes every untouched recommendation and answers as the bar's main button (Send when it is on, else the copy); it is off when the round's `accept_all` is false. The guard is asked when a Herdr session's round opens, and again after a failed Send.
- **The reply.** The page asks `round_reply` again with each change of the form and holds the answer, so Copy writes the clipboard inside the click, on the copy button's path (the copy toast holds the reply to copy by hand when the clipboard refuses). Copy then calls `round_copied`, Copy & Jump the Jump, and the bar says "Copied: paste it in the terminal". Send calls `round_send`, "Sending…" meanwhile; once it is sent the view closes and its row goes. A refused send shows its reason on the notice line and leaves the round open. While the view is full size the notice line is inert behind it, so the round's own errors (a refused send, a failed copy or reply, Copy & Jump's Jump) show on the status line instead ("Not sent: The agent is busy") and go to plotkeeper's log, until the next send or copy.
- **The round's states.** While `extracting`, the step is the agent's message split by its own Markdown headings, folded, with the last section holding a question open, and the bar says "Reading the questions…"; a message with no headings shows whole. A `failed` round shows the message the same way, "The questions could not be read: <reason>" and the session's Jump (or why there is none), as the reply has nothing to copy. A partial round has a notice of what is missing ("1 question could not be checked against the message: answer it in the terminal; 1 option was left out. Accept all is off."); it says Accept all is off only when it is, so a round that only lost options reads "1 option was left out." A round the view shows that is then answered or closed stays in it read-only, each step its answer (or the reply as typed), the bar one line: "Answered on the page", "Answered in the terminal", or "Closed: a later prompt or round came first". A round read to have no question (closed, asking nothing) leaves the view, and the story is back.
Expand Down
1 change: 1 addition & 0 deletions scripts/snap/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const base = {
rounds: [],
round_reply: "",
round_copied: "",
round_follow_up: "What do you recommend for Q7?",
plan_files: { root: "/w/plotkeeper", files: [] },
settings_files: { settings: null, keymap: null },
subagent_log: null,
Expand Down
Loading
Loading