Draw a background task's command as code, and frame the card it opens
A backgrounded command in a session's panel was a terminal glyph beside its words. The glyph said "command" and so did the monospace face, which is the same fact twice -- so the mark goes and the command is drawn the way every other verbatim thing in this app is: highlighted, monospace, on the raw surface. The glyph stays for the kinds whose description is prose, and for a command a provider never named. Tapping one landed the tool card against the bottom edge of the screen, since a reversed list anchors an item by its bottom -- so a tall card arrived at its last line. A card that fits the viewport is centred now, and one that does not has its top put at the top, which is where reading it starts. Only for a journey the reader asked for: a restore still puts them back exactly where they stopped. The panel's own close chevron is gone -- the drag, the scrim and Back all close it -- and the count is drawn even when it is zero, so "nothing is running" and "nobody has asked yet" stop looking identical. There is then nothing to expand, so that heading carries no chevron either. Checked on the emulator against the sandbox: the card centred in a mid-transcript tap, sat at the newest end where the list clamps, and the zero heading drew with no control.
This commit is contained in:
1 parent
cedb18e8c1
commit
df48a334f7
4 files changed
+114
-50
No files matched your search
@@ -817,6 +817,38 @@ fun SessionScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the row at [index] where it can be read, once something has scrolled to it.
|
||||
*
|
||||
* A reversed list anchors an item by its *bottom*, so a scroll to a tool card lands it against
|
||||
* the bottom edge with the turn that follows it above -- and for a tall card that means
|
||||
* arriving at its last line. What was asked for is the card: one that fits is centred, and one
|
||||
* that does not has its top put at the top of the viewport, where reading it starts.
|
||||
*
|
||||
* Only for a journey the reader asked for. A restore puts somebody back exactly where they
|
||||
* stopped, and exactly is the whole of what that means.
|
||||
*
|
||||
* The size is waited for rather than read: the row may not have been laid out yet in any
|
||||
* composition this scroll has had.
|
||||
*/
|
||||
suspend fun frameRow(index: Int) {
|
||||
val size =
|
||||
snapshotFlow {
|
||||
listState.layoutInfo.visibleItemsInfo.firstOrNull { it.index == index }?.size
|
||||
}
|
||||
.first { it != null }!!
|
||||
val layout = listState.layoutInfo
|
||||
// The room between the paddings, which is what a row is drawn in. Nothing to frame against
|
||||
// while the list has no size at all, and the scroll already made is as good an answer.
|
||||
val viewport =
|
||||
layout.viewportSize.height - layout.beforeContentPadding - layout.afterContentPadding
|
||||
if (viewport <= 0) return
|
||||
// Negative, so the row's bottom sits that far *inside* the viewport rather than past its
|
||||
// edge. The list clamps it where there is not enough behind the row to scroll.
|
||||
val offset = if (size <= viewport) -(viewport - size) / 2 else size - viewport
|
||||
listState.scrollToItem(index, offset)
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the reader at [anchor], paging history back until the row holding it is loaded.
|
||||
*
|
||||
@@ -831,7 +863,8 @@ fun SessionScreen(
|
||||
*
|
||||
* [openCall] opens the tool call at the anchor, and the run it is drawn inside, on the way
|
||||
* past. That is what makes a tapped background task land on its own card with its output
|
||||
* showing, rather than on a shut group the reader then has to find it in.
|
||||
* showing, rather than on a shut group the reader then has to find it in -- and [frameRow] is
|
||||
* what then puts the card where it can be read.
|
||||
*/
|
||||
suspend fun travelTo(anchor: ScrollAnchor, openCall: Boolean = false) {
|
||||
// Pages until the anchor's row is loaded and has something older behind it. The oldest
|
||||
@@ -909,6 +942,7 @@ fun SessionScreen(
|
||||
snapshotFlow { unitIndexFor(currentUnits, rowSeq, anchor.unit) }
|
||||
.first { it != null }!!
|
||||
listState.scrollToItem(index + 1, anchor.offset)
|
||||
if (openCall) frameRow(index + 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user