Mark the answer on the question, and close the notes that are not turns

Four things the transcript and the composer said badly.

**An answered question threw away the question.** It collapsed into
"Answered: Deny", which does not say that Allow was the alternative -- and
whether a tool was allowed or refused is what a reader comes back to that
row for. The options stay now and the one that was taken is marked, in the
same purple border that says "picked" while the question is still open, so
it is one appearance learned once rather than two renderings of one thing.
The buttons are disabled rather than removed, and state their own border
and label colour, because Material dims a disabled button's and that would
have taken the mark with it. Both places got it: the question card, and the
permission ask on a tool row, which had the same line.

An answer typed into **Other** matches no option, so nothing could mark it.
That one is still written out -- it is the state the marking cannot say.

**Memory notes were open.** A `<cc-memory>` note is not part of what was
said to the reader, it is a note about where a claim came from, and left
open it breaks a reply in half around a card. Closed like a tool call and a
peer message, with the file it came from still visible, since that is what
somebody scanning for "why does it think that" is looking for. Open-ness is
the screen's rather than the card's, so a note opened and scrolled past is
still open on the way back.

**Picking a slash command left its own suggestion up.** `/compact` is a
whole command and a prefix of itself, so the list stayed with the one row
already chosen -- something to dismiss, in front of the box it was about to
be sent from.

**A model switch warned when there was nothing to warn about.** The warning
is that a cache is dropped, so it needs there to be one: a session whose
process has exited has nothing holding a cache, and one reporting zero
context is holding nothing. Where the figure is *unknown* the fallback is
what it was -- whether anything has been said -- because unknown is not
nothing, and an import nobody has measured yet is exactly where the
conversation may be enormous.
This commit is contained in:
iris committed 2026-08-31 22:33:31 -04:00
1 parent b7277a5a04
commit ed88bdb31f
5 files changed
+188 -38

No files matched your search

@@ -246,6 +246,9 @@ fun SessionScreen(settings: ServerSettings, summary: SessionSummary, onBack: ()
// A model the reader has chosen and not yet confirmed. See [ModelSwitchWarning]: switching
// makes the session re-read the whole conversation, which is worth asking about first.
var pendingModel by remember { mutableStateOf<String?>(null) }
// What was last taken from the command suggestions, so the list closes behind it; see
// [CommandSuggestions] at its call site.
var picked by remember { mutableStateOf<String?>(null) }
var expandedTools by remember { mutableStateOf(setOf<String>()) }
// Which runs of adjacent tool calls are open. Keyed by the first call's
// id, so a group survives more calls arriving after it.
@@ -257,6 +260,10 @@ fun SessionScreen(settings: ServerSettings, summary: SessionSummary, onBack: ()
// by default, which is the rule for anything new in this transcript: a screen that opens
// everything it can is one nobody can scan.
var expandedNotes by remember { mutableStateOf(setOf<Long>()) }
// Which memory notes are open, by the note's own text -- see [MemoryNote]. Closed by default
// like everything else new in this transcript, and held here rather than in the card so a
// note opened and scrolled past is still open on the way back.
var openMemories by remember { mutableStateOf(setOf<String>()) }
// Uploaded-but-not-yet-sent attachment ids; sent with the next message.
var pendingAttachments by remember { mutableStateOf(listOf<String>()) }
// What this session is set to now, seeded from the row that opened it and
@@ -923,6 +930,11 @@ fun SessionScreen(settings: ServerSettings, summary: SessionSummary, onBack: ()
}
}
/** Opens or closes one memory note, wherever it is drawn; see [MemoryNote]. */
fun toggleMemory(text: String) {
openMemories = if (text in openMemories) openMemories - text else openMemories + text
}
fun act(onDone: () -> Unit = {}, action: () -> Unit) {
scope.launch {
try {
@@ -1209,7 +1221,14 @@ fun SessionScreen(settings: ServerSettings, summary: SessionSummary, onBack: ()
) { unit ->
when (unit) {
is TranscriptUnit.Block -> MarkdownText(unit.text, replies)
is TranscriptUnit.Memory -> MemoryNote(unit.part, replies)
is TranscriptUnit.Memory ->
MemoryNote(
unit.part,
replies,
unit.part.text in openMemories,
) {
toggleMemory(unit.part.text)
}
is TranscriptUnit.Whole -> {
val row = unit.row
Box(
@@ -1322,6 +1341,8 @@ fun SessionScreen(settings: ServerSettings, summary: SessionSummary, onBack: ()
AssistantMessage(
item.text,
replies,
openNotes = openMemories,
onToggleNote = ::toggleMemory,
live = true,
)
is TranscriptItem.ToolRun ->
@@ -1505,8 +1526,17 @@ fun SessionScreen(settings: ServerSettings, summary: SessionSummary, onBack: ()
// Between the transcript and the box: above what is being typed, so the list does not
// cover the thing the command is about, and below everything that explains it.
CommandSuggestions(
commands = suggestedCommands(input),
onPick = { command -> input = command.typed() },
// Nothing to suggest about a suggestion that was just taken. `/compact` is a
// whole command *and* a prefix of itself, so picking it left the list standing
// there with the one row already chosen -- the reader has to dismiss a list that
// has nothing left to offer, in front of the box they are about to send from.
// Held by what was picked rather than by a flag, so typing anything else brings
// the list back without needing a second thing to reset.
commands = if (input == picked) emptyList() else suggestedCommands(input),
onPick = { command ->
input = command.typed()
picked = command.typed()
},
)
// Always enabled -- a send while the session is running becomes a
@@ -1579,7 +1609,8 @@ fun SessionScreen(settings: ServerSettings, summary: SessionSummary, onBack: ()
// see [ModelSwitchWarning].
onPick = { chosen ->
if (
modelLabel(chosen) == modelLabel(model) || items.isEmpty()
modelLabel(chosen) == modelLabel(model) ||
!worthWarningAbout(status, contextTokens, items)
) {
act { setSessionModel(settings, summary.id, chosen) }
} else {
@@ -1806,6 +1837,32 @@ private data class QueuedMessage(
val refusal: String? = null,
)
/**
* Whether a model switch has anything to warn about -- see [ModelSwitchWarning].
*
* What the warning is about is a *cache* being dropped, so the question is whether there is one.
* Two answers say there is not, and both used to produce the dialog anyway:
*
* A session whose process has exited has nothing running to hold a cache, so the next turn was
* always going to re-read the conversation -- the switch adds nothing to that bill. And a session
* reporting zero context is holding nothing, which is what `/clear` leaves behind.
*
* Where the figure is *unknown* rather than zero the fallback is what it always was: whether
* anything has been said at all. Unknown is not nothing, and treating it as nothing would drop the
* warning on exactly the sessions -- an import, a fresh reattach -- where nobody has measured yet
* and the conversation may be enormous.
*/
private fun worthWarningAbout(
status: String,
contextTokens: Long?,
items: List<TranscriptItem>,
): Boolean =
when {
status == "exited" -> false
contextTokens != null -> contextTokens > 0
else -> items.isNotEmpty()
}
/**
* Asked before switching model, because switching is not free and the cost is invisible.
*