@@ -8,7 +8,7 @@ import type { ChatItem, MessageGroup, ToolCard } from "../../lib/chat/chat-types
88import { extractTextCached } from "../../lib/chat/message-extract.ts" ;
99import { normalizeMessage , normalizeRoleForGrouping } from "../../lib/chat/message-normalizer.ts" ;
1010import { senderIdentityKey } from "../../lib/chat/sender-label.ts" ;
11- import { extractToolCardsCached , isToolCardError } from "../../lib/chat/tool-cards.ts" ;
11+ import { extractToolCardsCached } from "../../lib/chat/tool-cards.ts" ;
1212import { resolveMessageToolUseId , resolveToolBlockId } from "./chat-thread-items.ts" ;
1313import {
1414 assistantGroupIsForwardedBoundary ,
@@ -460,52 +460,6 @@ export function coalesceToolActivityMessages(items: ChatItem[]): ChatItem[] {
460460 return coalesced . filter ( ( _ , index ) => ! suppressedIndexes . has ( index ) ) ;
461461}
462462
463- function assistantGroupHasReplyText ( group : MessageGroup ) : boolean {
464- return group . messages . some ( ( { message } ) => {
465- if ( extractTextCached ( message ) ?. trim ( ) ) {
466- return true ;
467- }
468- return safeNormalizeMessage ( message ) ?. content . some ( ( block ) => block . type === "canvas" ) ?? false ;
469- } ) ;
470- }
471-
472- export function annotateToolTurnOutcome (
473- items : Array < ChatItem | MessageGroup > ,
474- ) : Array < ChatItem | MessageGroup > {
475- let sawAssistantReply = false ;
476- for ( let index = items . length - 1 ; index >= 0 ; index -= 1 ) {
477- const item = items [ index ] ;
478- if ( ! item || item . kind !== "group" ) {
479- if ( item && chatItemStartsUserTurn ( item ) ) {
480- sawAssistantReply = false ;
481- }
482- continue ;
483- }
484- const role = item . role . toLowerCase ( ) ;
485- const forwardedBoundary = role === "assistant" && assistantGroupIsForwardedBoundary ( item ) ;
486- const startsTurn = chatItemStartsUserTurn ( item ) ;
487- if ( role === "user" ) {
488- sawAssistantReply = false ;
489- } else if ( role === "assistant" ) {
490- if ( forwardedBoundary ) {
491- // Gateway preserves sessions_send provenance when projecting inputs as assistant groups.
492- // Those groups start a new autonomous turn; they are not replies to an earlier tool.
493- sawAssistantReply = false ;
494- } else if ( assistantGroupHasReplyText ( item ) ) {
495- sawAssistantReply = true ;
496- }
497- } else if ( role === "tool" ) {
498- item . turnSucceeded = sawAssistantReply ;
499- }
500- if ( role !== "user" && ! forwardedBoundary && startsTurn ) {
501- // This group belongs to the new hidden-input turn. Reset only after
502- // processing it so replies from this turn cannot classify older tools.
503- sawAssistantReply = false ;
504- }
505- }
506- return items ;
507- }
508-
509463type RenderChatItem = ChatItem | MessageGroup ;
510464type StreamRunRenderItem = {
511465 kind : "stream-run" ;
@@ -549,7 +503,6 @@ type WorkGroupRenderItem = {
549503 key : string ;
550504 groups : MessageGroup [ ] ;
551505 durationMs : number | null ;
552- hasError : boolean ;
553506} ;
554507
555508type ActivityRunRenderItem = {
@@ -607,17 +560,6 @@ function isFinalReplyGroup(item: TurnRenderItem): boolean {
607560 ) ;
608561}
609562
610- function workGroupHasError ( groups : MessageGroup [ ] ) : boolean {
611- return groups . some (
612- ( group ) =>
613- group . role . toLowerCase ( ) === "tool" &&
614- group . turnSucceeded !== true &&
615- group . messages . some ( ( entry ) =>
616- extractToolCardsCached ( entry . message , entry . key ) . some ( isToolCardError ) ,
617- ) ,
618- ) ;
619- }
620-
621563/**
622564 * Once a turn is done, its intermediate work (tool groups and assistant
623565 * commentary before the final reply) collapses behind one "Worked for X"
@@ -717,7 +659,6 @@ export function collapseCompletedTurnWork(
717659 key : `work:${ finalReply . key } ` ,
718660 groups,
719661 durationMs,
720- hasError : workGroupHasError ( groups ) ,
721662 } ) ;
722663 result . push ( ...turn . slice ( segmentEnd + 1 ) ) ;
723664 }
0 commit comments