Hold an open call out of its run without taking one out of a group
Being open did two things to grouping, and only one of them was wanted. It held a call standing on its own out of the run it belongs to, so a command finishing behind the card being read no longer shuts it and folds it away mid-sentence. It also took a call *out* of the group it was already inside, and that is what made collapsing jump: grouping is what gives a row its identity, so one tap rebuilt the rows around the finger -- opening a call inside a group split the group into two pieces with mismatched keys, and closing one replaced three rows with one, which no anchor survives. Measured at 450px of jump, with the card that was closed going with it. So the held-out set is now the screen's, not the transcript's: a call that has never been drawn inside a group and is open stands out of its run, and a call that has been in one stays in it whatever the reader does to it. Being inside a group once is a fact about what the reader has been shown, which is why the screen is what remembers it. Checked with ktfmtFormat, compileDebugKotlin, lintDebug and testDebugUnitTest, and on the emulator against the sandbox: opening a call inside an open group of six leaves it one group of six and closing it returns every row to the pixel it came from; a call opened while standing alone survives a reply landing behind it, and folds back into "Called 3 tools" when it is closed without moving the rows below it.
This commit is contained in:
1 parent
463acb28fa
commit
b86a5dc37a
4 files changed
+73
-36
No files matched your search
@@ -97,20 +97,26 @@ sealed class TranscriptRow {
|
||||
* A single call is left alone: "Called 1 tool" hides a card to say the same thing in more words,
|
||||
* and the run this exists for is the burst of five greps nobody wants to scroll past.
|
||||
*
|
||||
* The last call is left alone too, as is one still running or one the reader has open, wherever in
|
||||
* its run it sits. What the session is doing, did last, or is being read is the one thing worth
|
||||
* seeing without a heading hiding it. A finished call therefore folds back into its run only once
|
||||
* it has been overtaken and is closed.
|
||||
* The last call is left alone too, and so is one still running wherever in its run it sits. What
|
||||
* the session is doing, or did last, is the one thing worth seeing without opening anything, and a
|
||||
* heading counting it hides it. What folds a call back into its run is therefore not finishing but
|
||||
* being overtaken: anything arriving behind it, a reply included, makes it history.
|
||||
*
|
||||
* [heldOut] is the one thing being read can change, and only in that direction: a call standing on
|
||||
* its own that somebody is reading is not overtaken while they read it. Opening a call *already*
|
||||
* inside a group does not pull it out (2026-09-16, after it briefly did) -- it is visible where it
|
||||
* is, and grouping is what gives a row its identity, so a rule that reads the open set both ways
|
||||
* makes the reader's own tap rebuild the rows around it: three rows became one the moment a call
|
||||
* was closed, and no anchor survives a row that no longer exists -- the list jumped by 450px and
|
||||
* took the closed card with it. Which calls are held out is [SessionScreen]'s to say, since being
|
||||
* inside a group once is what settles it.
|
||||
*/
|
||||
fun groupToolRuns(
|
||||
items: List<TranscriptItem>,
|
||||
expandedTools: Set<String> = emptySet(),
|
||||
): List<TranscriptRow> = DebugStats.timed("grouped tool runs") { groupRuns(items, expandedTools) }
|
||||
heldOut: Set<String> = emptySet(),
|
||||
): List<TranscriptRow> = DebugStats.timed("grouped tool runs") { groupRuns(items, heldOut) }
|
||||
|
||||
private fun groupRuns(
|
||||
items: List<TranscriptItem>,
|
||||
expandedTools: Set<String>,
|
||||
): List<TranscriptRow> {
|
||||
private fun groupRuns(items: List<TranscriptItem>, heldOut: Set<String>): List<TranscriptRow> {
|
||||
val rows = mutableListOf<TranscriptRow>()
|
||||
var run = mutableListOf<TranscriptItem.ToolRun>()
|
||||
// A run can occupy more than one non-adjacent piece, so claimed keys span the whole transcript
|
||||
@@ -150,9 +156,10 @@ private fun groupRuns(
|
||||
when {
|
||||
call == null -> rows += TranscriptRow.Single(item)
|
||||
// Standing outside the run is the call's place in the list as it is now, not something
|
||||
// recorded on the call: the same finished call is a row of its own while it is last or
|
||||
// open, and part of its group once something follows it and the reader closes it.
|
||||
call.done && call.id !in expandedTools && index != items.lastIndex -> run += call
|
||||
// recorded on the call: the same finished call is a row of its own while it is the last
|
||||
// thing that happened, or open and never yet grouped, and part of its group once a
|
||||
// reply lands behind it.
|
||||
call.done && call.id !in heldOut && index != items.lastIndex -> run += call
|
||||
else -> {
|
||||
flush()
|
||||
run += call
|
||||
|
||||
Reference in new issue
Block a user