diff --git a/src/mobile-web/src/services/SessionEventReducer.ts b/src/mobile-web/src/services/SessionEventReducer.ts index 3007390c53..f57167275b 100644 --- a/src/mobile-web/src/services/SessionEventReducer.ts +++ b/src/mobile-web/src/services/SessionEventReducer.ts @@ -80,7 +80,7 @@ export class SessionEventReducer { const current = readBackgroundDelivery(this.active.backgroundDelivery, turnId); if (delivery && (delivery.executionGeneration ?? 0) < (current?.executionGeneration ?? 0)) return null; const active=this.active;this.active=null; - const message:ChatMessage={id:`${turnId}_assistant`,turn_id:turnId,role:'assistant',content:active.text,thinking:active.thinking,tools:active.tools,items:active.items,timestamp:this.timestamp,status:envelope.event.endsWith('failed')||payload.success===false?'error':envelope.event.endsWith('completed')?'completed':'cancelled',error:typeof payload.error==='string'?payload.error:undefined}; + const message:ChatMessage={id:`${turnId}_assistant`,turn_id:turnId,role:'assistant',content:active.text,thinking:active.thinking,tools:active.tools,items:active.items,timestamp:String(Math.floor(Date.now()/1000)),status:envelope.event.endsWith('failed')||payload.success===false?'error':envelope.event.endsWith('completed')?'completed':'cancelled',error:typeof payload.error==='string'?payload.error:undefined}; if (delivery || active.backgroundDelivery) { message.metadata = { backgroundDelivery: delivery }; const user:ChatMessage = {id:`${turnId}_user`,turn_id:turnId,role:'user',content:this.userText,timestamp:this.timestamp,status:message.status,metadata:{...this.userMetadata,backgroundDelivery:delivery}}; diff --git a/src/mobile-web/src/services/SessionRecordPresentation.ts b/src/mobile-web/src/services/SessionRecordPresentation.ts index d6b7699616..119ffacb81 100644 --- a/src/mobile-web/src/services/SessionRecordPresentation.ts +++ b/src/mobile-web/src/services/SessionRecordPresentation.ts @@ -2,7 +2,7 @@ import type { ChatMessage, ChatMessageItem, RemoteToolStatus } from './RemoteSes /** Rendering accepts rich records without narrowing their stored protocol data. */ export interface MobileStoredTurn { - turnId: string; turnIndex: number; status: string; timestamp: number; + turnId: string; turnIndex: number; status: string; timestamp: number; endTime?: number; userMessage: { id: string; content: string; timestamp: number; metadata?: unknown }; modelRounds: Array<{ roundIndex: number; textItems: RichText[]; thinkingItems?: RichText[]; toolItems: RichTool[] }>; error?: string; @@ -48,6 +48,6 @@ export function presentSessionTurn(turn: MobileStoredTurn): ChatMessage[] { }); return [ {id:turn.userMessage.id,turn_id:turn.turnId,turn_index:turn.turnIndex,role:'user',content:turn.userMessage.content,timestamp:String(turn.userMessage.timestamp),metadata:turn.userMessage.metadata,images:presentUserMessageImages(turn.userMessage.metadata)}, - {id:`${turn.turnId}_assistant`,turn_id:turn.turnId,role:'assistant',content:items.filter(i=>i.type==='text').map(i=>i.content??'').join(''),thinking:items.filter(i=>i.type==='thinking').map(i=>i.content??'').join(''),items,tools:items.flatMap(i=>i.tool?[i.tool]:[]),status:turn.status==='inprogress'?'streaming':turn.status,error:turn.error,timestamp:String(turn.timestamp)}, + {id:`${turn.turnId}_assistant`,turn_id:turn.turnId,role:'assistant',content:items.filter(i=>i.type==='text').map(i=>i.content??'').join(''),thinking:items.filter(i=>i.type==='thinking').map(i=>i.content??'').join(''),items,tools:items.flatMap(i=>i.tool?[i.tool]:[]),status:turn.status==='inprogress'?'streaming':turn.status,error:turn.error,timestamp:String(turn.endTime ?? turn.timestamp)}, ]; }