Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ae1b6ac
Studio map: a part's purpose draws code spans, and its hint shows no …
danielrispler Nov 28, 2026
4b20c89
Studio: the subagent chip keeps its status, the drawer never scrolls …
danielrispler Nov 28, 2026
a7d65a1
Snap: no non-null assertion in the chip fixture (#825)
danielrispler Nov 28, 2026
530614e
Studio: a pasted prompt's turn reads its first pasted line, and old t…
danielrispler Nov 28, 2026
ba70dc8
Studio: the session list's hold keeps new subagent rows out until the…
danielrispler Nov 28, 2026
e0b3448
Merge issue-826-purpose-code (#826)
danielrispler Nov 28, 2026
8671cd6
Studio: an earlier turn's folded line draws its Markdown (#827)
danielrispler Nov 28, 2026
3a64305
Merge branch 'issue-820-qa-fixes' into issue-827-folded-markdown
danielrispler Nov 28, 2026
6886cc1
Tests: the chip's cut children are covered by the button's title (#825)
danielrispler Nov 28, 2026
3964089
Merge issue-824-pasted-prompts (#824)
danielrispler Nov 28, 2026
2367460
Merge origin/main
danielrispler Nov 28, 2026
1fc7144
Merge issue-828-held-subagents (#828)
danielrispler Nov 28, 2026
3628fb3
Studio: a subagent chip's long result is cut at half the chip; the ch…
danielrispler Nov 28, 2026
7c5c764
Merge issue-827-folded-markdown (#827)
danielrispler Nov 28, 2026
bc9cbfe
Merge issue-820-qa-fixes into issue-825-chip-drawer-gear
danielrispler Nov 28, 2026
5912285
Snap: unescaped quotes in a comment (#825)
danielrispler Nov 28, 2026
c402410
Merge #825: the subagent chip keeps its status, the drawer never scro…
danielrispler Nov 28, 2026
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
9 changes: 5 additions & 4 deletions core/src/saved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
use crate::Studio;
use std::{cell::Cell, collections::BTreeMap, fmt};

/// The saved state's format. Bump it when a saved field changes meaning or a field the pane's JSON
/// leaves out is added, so an older file is not read as the new shape: a field the old file lacks
/// makes it unreadable anyway, unless it has a default.
const FORMAT: u32 = 10;
/// The saved state's format. Bump it when a saved field changes meaning, the replay makes a saved
/// field differently (11: a pasted prompt's turn line, #824), or a field the pane's JSON leaves out
/// is added, so an older file is not read as the new shape and the first launch replays the whole
/// log: a field the old file lacks makes it unreadable anyway, unless it has a default.
const FORMAT: u32 = 11;

thread_local! {
static SAVING: Cell<bool> = const { Cell::new(false) };
Expand Down
46 changes: 39 additions & 7 deletions core/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,13 +1324,7 @@ impl Session {
let line = match &prompt.sender {
// From the wake-up's own task: a queued one's turn starts after the row's `returned` may be cleared.
Sender::WakeUp(task_id) => format!("worker {} returned", self.agent_name(task_id)),
_ => prompt
.text
.lines()
.map(str::trim)
.find(|l| !l.is_empty())
.unwrap_or_default()
.into(),
_ => prompt_line(&prompt.text),
};
if let Some(turn) = self.turns.last_mut().filter(|t| t.prompt.is_empty()) {
turn.prompt = line;
Expand Down Expand Up @@ -1682,3 +1676,41 @@ pub(crate) fn card_time(id: &str) -> u64 {
pub(crate) fn short(id: &str, n: usize) -> &str {
id.get(..n).unwrap_or(id)
}

/// A prompt's line in the feed: its first non-empty line once every `<pasted_content id="N">` and
/// `</pasted_content id="N">` tag is removed, wherever it sits (#824), and `Pasted text` for a
/// prompt whose paste holds no text.
fn prompt_line(text: &str) -> String {
let mut kept = String::with_capacity(text.len());
let mut pasted = false;
let mut rest = text;
while let Some(at) = rest.find("<") {
kept.push_str(&rest[..at]);
let tag = &rest[at..];
match pasted_tag_len(tag) {
Some(len) => {
pasted = true;
rest = &tag[len..];
}
None => {
kept.push('<');
rest = &tag[1..];
}
}
}
kept.push_str(rest);
match kept.lines().map(str::trim).find(|l| !l.is_empty()) {
Some(line) => line.into(),
None if pasted => "Pasted text".into(),
None => String::new(),
}
}

/// The length of the pasted-content tag `text` starts with, opening or closing, if it starts with one.
fn pasted_tag_len(text: &str) -> Option<usize> {
let after = (text.strip_prefix("<pasted_content id=\""))
.or_else(|| text.strip_prefix("</pasted_content id=\""))?;
let digits = after.bytes().take_while(u8::is_ascii_digit).count();
let close = after[digits..].strip_prefix("\">")?;
(digits > 0).then(|| text.len() - close.len())
}
9 changes: 6 additions & 3 deletions core/tests/saved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ fn saved_state_of_another_format_or_beside_a_shorter_log_is_ignored() {
};

let newline = saved.iter().position(|b| *b == b'\n').unwrap();
let mut other_format = b"studio-state 0".to_vec();
other_format.extend(&saved[newline..]);
again(&other_format, log.len() as u64);
// Format 10 is the build's before #824, whose turns kept a pasted prompt's tag as their line.
for format in ["studio-state 0", "studio-state 10"] {
let mut other_format = format.as_bytes().to_vec();
other_format.extend(&saved[newline..]);
again(&other_format, log.len() as u64);
}
again(&with_terminals(&saved), log.len() as u64);
again(&saved, log.len() as u64 - 1);
again(&saved[..saved.len() / 2], log.len() as u64);
Expand Down
72 changes: 58 additions & 14 deletions core/tests/turns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,68 @@ fn opened(log: &str) -> Vec<(String, bool)> {
}

/// danielrispler/plotkeeper#675: a queued prompt's turn is marked by who sent it, a wake-up's or
/// Daniel's, as a prompt that opens its turn is.
/// Daniel's, as a prompt that opens its turn is. Daniel's is named by its prompt's first line once
/// every pasted-content tag is removed (#824), a wake-up's by the worker that returned.
#[test]
fn a_queued_wake_up_marks_the_turn_it_starts_and_daniels_queued_prompt_does_not() {
let wake_up = r#"<agent-message from=\"aaf57a4236e21f65b\">…</agent-message>"#;
fn a_queued_prompt_marks_and_names_the_turn_it_starts() {
let queued = r#"<pasted_content id=\"8720\">…</pasted_content id=\"8720\">"#;
let woken = QUEUED.replacen(queued, wake_up, 1);
assert_ne!(woken, QUEUED);
let rows = [
// The fixture's own prompt.
("a one-line paste", queued, "…", false),
(
"a paste over several lines",
r#"<pasted_content id=\"6286\">\n\n First pasted line\nsecond\n</pasted_content id=\"6286\">"#,
"First pasted line",
false,
),
(
"typed text before the paste",
r#"\nLook at this:\n<pasted_content id=\"7\">pasted</pasted_content id=\"7\">"#,
"Look at this:",
false,
),
(
"a paste inside a typed line",
r#"Fix <pasted_content id=\"7\">the bug</pasted_content id=\"7\"> now"#,
"Fix the bug now",
false,
),
(
"an empty paste",
r#"<pasted_content id=\"3\"></pasted_content id=\"3\">"#,
"Pasted text",
false,
),
(
"a paste of blank lines",
r#"<pasted_content id=\"3\">\n \n</pasted_content id=\"3\">"#,
"Pasted text",
false,
),
(
"a wake-up",
r#"<agent-message from=\"aaf57a4236e21f65b\">…</agent-message>"#,
"worker ",
true,
),
];
for (case, prompt, line, woken) in rows {
let log = QUEUED.replacen(queued, prompt, 1);
assert!(log.contains(prompt), "{case}");

let daniels = opened(QUEUED);
let wakes = opened(&woken);
let turns = opened(&log);

// The turn before has no prompt in the cut; the wake-up turn is marked either way.
assert_eq!(daniels.len(), 3);
assert_eq!((daniels[1].1, wakes[1].1), (true, true));
// The turn the queued prompt starts, which its text names.
assert_eq!(daniels[2], (queued.replace('\\', ""), false));
assert!(wakes[2].1, "{wakes:?}");
assert!(wakes[2].0.starts_with("worker "), "{wakes:?}");
// The turn before has no prompt in the cut; the wake-up turn is marked either way.
assert_eq!(turns.len(), 3, "{case}");
assert!(turns[1].1, "{case}");
// The turn the queued prompt starts.
assert_eq!(turns[2].1, woken, "{case}");
if woken {
assert!(turns[2].0.starts_with(line), "{case}: {turns:?}");
} else {
assert_eq!(turns[2].0, line, "{case}");
}
}
}

/// danielrispler/plotkeeper#675: a queued wake-up's turn names the worker that returned even when the running turn's own step
Expand Down
2 changes: 1 addition & 1 deletion docs/studio/behaviour/map.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/studio/behaviour/rail.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The rail, on the window's left, tells the selected session's story, ranked by wh
- Running: "You asked" with your prompt, then the intention, boxed, with its age and the step line. The intention is the latest thing the agent wrote in its own words; it shows only while the session runs, and small, as "Why it asks", while it needs you. At your turn the Headline says what happened, and the turn-end intention is the final response's first line, never the summary's.
While it runs, the box's last line, under the step and set apart by a hair line, is a **Wait tip** (#523, spec #520): "Tip: …", muted and small, one line ending in "…" when cut, its full text scrolling into view on hover. It teaches one feature, naming its palette action with the key your keymap binds it to now ("in the palette" when unbound). One tip shows per Running stretch and stays for it; it is gone at Needs you, Your turn and Idle. Among the tips whose context holds (the shown project has a map, a PR brief waits in the tray, the agent records each turn's files) that have shown fewer than 5 times and are out of cooldown, the one shown longest ago, or never, wins. The cooldown is `max(1, min(4, eligible − 1))` Running stretches, counted at the start of every stretch while tips are on, so a tip never shows twice in a row and a lone eligible tip shows every other stretch. The list is in `ui/tips.ts`; the show history (the stretch counter and each tip's count and last stretch) is in the page's `localStorage`, so clearing it starts tips again. `"tips": false` in `settings.json` turns them off ([Settings files](../settings.md)).
- Needs you: the docked question, plan or permission, then "Why it asks" and "So far this turn", the facts the hooks recorded.
- Your turn, idle or ended: "You asked", the **Headline**, the evidence line, the Body lines, one line for each subagent and its checks, and "Full response", folded. A session returned to after a while opens on "Where we were" (see [The Brief and Where we were](brief.md)).
- Your turn, idle or ended: "You asked", the **Headline**, the evidence line, the Body lines, one line for each subagent (a chip whose status, running, done or failed, always shows at its natural width, while its purpose and kind line take the rest and end in "…") and its checks, and "Full response", folded. A session returned to after a while opens on "Where we were" (see [The Brief and Where we were](brief.md)).

**Full response** (spec #661) is the turn's whole reply: the newest turn's texts from the transcript, an earlier turn's final reply fetched when its fold first opens. When the Headline is the reply's first line (no stored Headline), that line is left out, so the fold never opens on the sentence the Headline already shows; a stored Headline, a writer's or one read from an older summary, leaves the reply whole. The newest turn has no Full response when nothing is left, and an earlier turn's fold, whose reply is not on hand until it opens, says "The reply was only its Headline."

Expand All @@ -37,7 +37,7 @@ A failed check's row opens its exit code and the last 40 lines of its output. A

**Real code.** A file row opens its real hunk between the turn's trees, in place, at most about 40 lines; a capped hunk's "N more lines" opens the turn's whole diff, . The palette's "studio::OpenFullDiff" opens the whole diff of the newest turn that has files, in the centre column's place, one fold per file with its hunk read whole, and a button to go back. The page has no editor to open a file in.

**Earlier turns** fold to one line each: your prompt, the Headline and a mark for a check that ended failed. A turn a wake-up opened reads "Woken by" in place of "You asked", and its line's prompt is the returning task after a muted "Woken by" (#675). A click opens the turn's block under it and folds it again. Opening or closing the evidence line, a hunk or a folded turn changes only that node: the rail's others are kept, the scroll position does not move, and what is open stays open when the studio's state refreshes.
**Earlier turns** fold to one line each: your prompt, the Headline and a mark for a check that ended failed. The Headline draws its Markdown inline, as the newest turn's does, with code as code and bold as bold, but a link shows as its text, so a press anywhere on the line folds or unfolds the turn (#820). A turn a wake-up opened reads "Woken by" in place of "You asked", and its line's prompt is the returning task after a muted "Woken by" (#675). A turn's prompt, after "You asked" and in its folded line, is the prompt's first non-empty line once every `<pasted_content id="N">` and `</pasted_content id="N">` tag is removed, wherever it sits on a line: a pasted prompt reads its first pasted line, or the first line typed before the paste, and a paste holding no text reads "Pasted text" (#824). A click opens the turn's block under it and folds it again. Opening or closing the evidence line, a hunk or a folded turn changes only that node: the rail's others are kept, the scroll position does not move, and what is open stays open when the studio's state refreshes.

**The story is patched in place** (spec #661). The rail is drawn again on each change of the selected session, its cards or a turn's summary, and "now", the banner and the feed are each drawn through the keyed patch the session list uses: an element whose key is the same is the node it was, so a press lands where it was aimed, and the scroll position, the focus, a text selection and an open fold stay. A turn's key is its session, its index, whether it is the newest or a past row, and a stamp of what its handlers read: its id, prompt, reply, summary and files. A turn whose stamp changed, as when its summary arrives, is drawn anew, and the others are kept. A fold, an Ask box (with what is typed in it and its answer), the banner's Brief, a subagent's line, a file's or a failed check's row and a citation each have their own key; an Ask box is the same node, what is typed in it and its answer included, while it stays in its turn. When its turn is drawn anew, it leaves the page for a moment with the old turn's node, and the patch gives the focus back to it once it is in the new one. A counting time (a check's) keeps one key for the thing it counts, so it is kept and goes on counting. The dock, the Brief under the feed and the decision history are drawn again only when what they show changed.

Expand Down
Loading