mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-05 15:09:42 +02:00
fix(web): show the whole last turn in the Claude response viewer's brief view
The eye button rendered `data.text`, which is one row: the last assistant
row of the transcript. A Claude answer is a median of 3 model messages
(p90 11) split around tool calls, so the brief view usually showed the tail
of an answer ("Done.", "Let me look.") and the substance appeared only after
More. The full view was fine, which is why the brief one read as broken by
comparison.
The brief view now asks `?context=turn`. The reader answers with the
assistant messages of the last ANSWERED turn (`selectLastAnsweredTurn`: the
highest `turn` that has an assistant row, so a prompt queued after the
answer does not blank the view) and the frontend renders them exactly as
the full view renders that turn: one badge, then continuation segments,
gated on the numeric `turn` as before.
`data.text` is unchanged in every context — still the last assistant row,
never `messages.at(-1)` — because agent pollers hash it. Readers that emit
no turns (Codex, the pane parser, DeepSeek, an older server) return `text`
only for `context=turn`, and the brief view keeps its single card for them.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McLWqCWBuQYGuPMScb4Aou
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
5b667264b4
commit
bd61735393
@@ -359,3 +359,30 @@ export function getLastTranscriptResponse(blocks: ResponseViewerTranscriptBlock[
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* The messages of the most recent turn that has an answer: every assistant
|
||||
* message whose `turn` matches the highest turn any assistant message carries.
|
||||
*
|
||||
* This is what the viewer's brief ("Last Response") view renders for Claude.
|
||||
* The brief `text` is one row — the last assistant row — and a Claude turn is
|
||||
* a median of 3 rows (p90 11), so that row alone was usually the tail of the
|
||||
* answer ("Done.") with the substance in the rows before it. Reading the whole
|
||||
* turn gives the same cards the full view shows for it, and no more.
|
||||
*
|
||||
* Deliberately NOT "everything after the last user message": a prompt queued
|
||||
* while the agent works opens a new, still-unanswered turn, and the honest
|
||||
* brief view is then the previous, answered one — exactly the row `text`
|
||||
* already points at. Messages without a numeric `turn` (Codex, the pane
|
||||
* parser, an older reader) yield an empty list so callers fall back to `text`.
|
||||
*/
|
||||
export function selectLastAnsweredTurn<T extends { role: string; turn?: number }>(messages: T[]): T[] {
|
||||
let latest = -1;
|
||||
for (const message of messages) {
|
||||
if (message.role === 'assistant' && typeof message.turn === 'number' && message.turn > latest) {
|
||||
latest = message.turn;
|
||||
}
|
||||
}
|
||||
if (latest < 0) return [];
|
||||
return messages.filter((message) => message.role === 'assistant' && message.turn === latest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user