fix(client): address trajectory review feedback

This commit is contained in:
_Kerman
2026-07-28 22:16:45 +08:00
parent 62dd2ab38e
commit f942c30f4b
14 changed files with 116 additions and 18 deletions

View File

@@ -3,7 +3,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import type { ConvViewProps } from '@deepseek-ai/dsh-client-ui-conversation/client'
import type {
AssistantMessageNode, ConversationContext, RequestView,
AssistantMessageNode, ConversationContext, ConversationNode, RequestView,
} from '@deepseek-ai/dsh-client-runtime/client'
import {
deriveTrajectoryContextBranches, trajectoryBranchContainsSeq,
@@ -84,6 +84,12 @@ function searchableJson(value: unknown): string {
}
}
function isInterruptedNode(node: ConversationNode): boolean {
return node.kind === 'assistant'
? node.interrupted === true
: node.kind === 'tool-result' && node.error?.code === 'interrupted'
}
function searchMatches(
turns: ReturnType<typeof deriveTrajectoryLayout>,
query: string,
@@ -170,7 +176,13 @@ export function TrajectoryView({ useSession, loadAllHistory }: ConvViewProps & T
)
const currentBranch = branches.at(-1)
if (currentBranch === undefined) throw new Error('trajectory branch projection must not be empty')
const selectedNodes = currentBranch.nodes
const selectedNodes = useMemo(() => {
const selected = new Map(currentBranch.nodes.map(node => [node.seq, node]))
for (const node of nodes) {
if (isInterruptedNode(node)) selected.set(node.seq, node)
}
return [...selected.values()].sort((left, right) => left.seq - right.seq)
}, [currentBranch, nodes])
const selectedRequests = useMemo(
() => requests.filter(request =>
trajectoryBranchContainsSeq(currentBranch, request.startSeq),

View File

@@ -538,7 +538,10 @@ function expandAssistant(
let index = startIndex - 1
const usage = node.usage as UsageLike | undefined
const streaming = opts?.streaming === true
const messageDuration = streaming ? null : durationSeconds(node.time, prevAbsTime)
const recordedStart = finiteTime(node.timing?.stepStartTime)
const messageDuration = streaming
? null
: durationSeconds(node.time, recordedStart ?? prevAbsTime)
const nodeAbs = streaming ? null : finiteTime(node.time)
const messageText = node.blocks
.filter(block => block.kind === 'text' && (!streaming || block.text !== ''))
@@ -561,7 +564,7 @@ function expandAssistant(
...(thinkingText !== '' ? { thinkingDetail: thinkingText } : {}),
sourceBlocks: node.blocks.map(block => assistantSourceBlock(block)),
timeSeconds: messageDuration,
startedAt: finiteTime(node.timing?.stepStartTime),
startedAt: recordedStart,
}
attachUsage(message, usage)
message.assistantMetrics = {