Take subagent reports out of the main transcript, and separate turns with a rule
A row per finished background task is a screenful of dividers about work the reader was not asking after, and one of them turned out to be a whole shell command drawn as centred prose, because its words came from somewhere with no reason to keep them short. `Event::TaskNote` is gone entirely, along with the row that drew it. A subagent's closing report is recorded as that subagent's own transcript's closing text and is read in the subcard, which is where it was already going; what the parent gets a row for is a message a subagent genuinely sends it, which arrives by the peer path and has had one all along. What remains is the actual defect and the smallest thing that fixes it. The fold still refuses to grow a settled reply, so a turn boundary is always a message boundary, and where two replies then abut it puts a `TurnBreak` between them: a hairline, no words, no colour. Made by the fold rather than sent by the server, because it is not something that happened -- it is the boundary between two things that did. `joinPages` puts one in at a page seam, which the fold never gets to see. The task notification is still what closes a task in `Status::Waiting`'s bookkeeping, and the registry lookup that recognises one this translator never saw start is what makes that work for a session adopted across a restart. Verified on the emulator: three replies, three rules, and nothing about the helpers anywhere in the parent. 170 server tests, 85 JVM tests, ktfmt, clippy, rustfmt and Android lint clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ef1aad8776
commit
1bbb642973
13 files changed
+171
-407
No files matched your search
@@ -47,18 +47,40 @@ class TranscriptItemsTest {
|
||||
assertEquals(listOf("Still running its tests."), texts(items))
|
||||
}
|
||||
|
||||
/**
|
||||
* The rule that replaced the wall of reports. A turn that starts with nothing recorded in front
|
||||
* of it -- a subagent finishing, the CLI picking a conversation back up -- leaves two replies
|
||||
* abutting, and only the break says they are two.
|
||||
*/
|
||||
@Test
|
||||
fun a_task_reporting_back_is_a_row_between_the_two_turns() {
|
||||
fun two_replies_that_meet_are_separated_by_a_rule_and_nothing_else() {
|
||||
val items =
|
||||
fold(
|
||||
SessionEvent.AssistantText("Launched it."),
|
||||
SessionEvent.Status("waiting"),
|
||||
SessionEvent.TaskNote("toolu_1", "the Dev Updater agent", "completed", "pushed"),
|
||||
SessionEvent.AssistantText("Noted."),
|
||||
)
|
||||
assertEquals(3, items.size, "$items")
|
||||
assertTrue(items[1] is TranscriptItem.TaskNote, "$items")
|
||||
assertTrue(items[1] is TranscriptItem.TurnBreak, "$items")
|
||||
assertEquals(listOf("Launched it.", "Noted."), texts(items))
|
||||
// Distinct keys: the break shares the reply's seq, and two items with one key take the
|
||||
// app down.
|
||||
assertEquals(3, items.map { it.key }.toSet().size, "$items")
|
||||
}
|
||||
|
||||
/**
|
||||
* A reply after anything that draws a row of its own needs no rule: that row is the boundary.
|
||||
*/
|
||||
@Test
|
||||
fun a_reply_after_a_row_of_its_own_gets_no_rule() {
|
||||
val items =
|
||||
fold(
|
||||
SessionEvent.AssistantText("Launched it."),
|
||||
SessionEvent.Status("idle"),
|
||||
SessionEvent.UserMessage("carry on", null, emptyList()),
|
||||
SessionEvent.AssistantText("Noted."),
|
||||
)
|
||||
assertTrue(items.none { it is TranscriptItem.TurnBreak }, "$items")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,23 +103,7 @@ class TranscriptItemsTest {
|
||||
listOf(TranscriptItem.AssistantMsg(2, "The next.", settled = true)),
|
||||
)
|
||||
assertEquals(listOf("One turn.", "The next."), texts(whole))
|
||||
}
|
||||
|
||||
/** The endings nobody builds a screen for -- see [taskNoteSummary]. */
|
||||
@Test
|
||||
fun a_task_note_says_which_ending_it_was() {
|
||||
val said = "it said hello"
|
||||
// A subagent is named, and its own words stay in its own transcript rather than being
|
||||
// repeated here.
|
||||
assertEquals("helper 1 reported back", taskNoteSummary("helper 1", "completed", said))
|
||||
assertEquals("helper 1 failed", taskNoteSummary("helper 1", "failed", null))
|
||||
assertEquals("helper 1 was cancelled", taskNoteSummary("helper 1", "cancelled", said))
|
||||
// A word this build has never seen is said as itself, not mapped onto the nearest one.
|
||||
assertEquals("helper 1: evicted", taskNoteSummary("helper 1", "evicted", said))
|
||||
// A backgrounded command has no title and no transcript of its own, so its summary is the
|
||||
// only record of it there is -- and it is already a sentence.
|
||||
val command = """Background command "build the kernel" completed (exit code 0)"""
|
||||
assertEquals(command, taskNoteSummary(null, "completed", command))
|
||||
assertEquals("A background task failed", taskNoteSummary(null, "failed", null))
|
||||
// And the rule between them, which the fold that would have made it never got to see.
|
||||
assertTrue(whole.any { it is TranscriptItem.TurnBreak }, "$whole")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user