修复重构后新会话未显示底部token用量
This commit is contained in:
@@ -141,6 +141,7 @@ const ConversationTabView = memo(function ConversationTabView({
|
||||
const {
|
||||
appendOptimisticTurn,
|
||||
completeTurn,
|
||||
getSession,
|
||||
refetchDetail,
|
||||
syncTurnMetadata,
|
||||
removeConversation,
|
||||
@@ -208,10 +209,13 @@ const ConversationTabView = memo(function ConversationTabView({
|
||||
error: detailError,
|
||||
} = useConversationDetail(effectiveConversationId)
|
||||
|
||||
const runtimeSession = getSession(effectiveConversationId)
|
||||
const effectiveSessionStats = runtimeSession?.sessionStats ?? null
|
||||
|
||||
useEffect(() => {
|
||||
if (!isActive) return
|
||||
setSessionStats(detail?.session_stats ?? null)
|
||||
}, [detail?.session_stats, isActive, setSessionStats])
|
||||
setSessionStats(effectiveSessionStats)
|
||||
}, [effectiveSessionStats, isActive, setSessionStats])
|
||||
|
||||
const externalId = detail?.summary.external_id ?? undefined
|
||||
const draftStorageKey = useMemo(() => {
|
||||
@@ -621,7 +625,7 @@ const ConversationTabView = memo(function ConversationTabView({
|
||||
connStatus={connStatus}
|
||||
isActive={isActive}
|
||||
sendSignal={sendSignal}
|
||||
sessionStats={detail?.session_stats ?? null}
|
||||
sessionStats={effectiveSessionStats}
|
||||
detailLoading={detailLoading}
|
||||
detailError={detailError}
|
||||
hideEmptyState={!hasPersistedConversation || hasSentMessage}
|
||||
|
||||
@@ -49,6 +49,9 @@ export interface ConversationRuntimeSession {
|
||||
syncState: ConversationSyncState
|
||||
activeTurnToken: string | null
|
||||
|
||||
// Session-level stats (token usage, context window, etc.)
|
||||
sessionStats: SessionStats | null
|
||||
|
||||
// Cleanup
|
||||
pendingCleanup: boolean
|
||||
}
|
||||
@@ -141,6 +144,7 @@ function createEmptySession(
|
||||
liveMessage: null,
|
||||
syncState: "idle",
|
||||
activeTurnToken: null,
|
||||
sessionStats: null,
|
||||
pendingCleanup: false,
|
||||
}
|
||||
}
|
||||
@@ -279,6 +283,7 @@ function reducer(
|
||||
detailError: null,
|
||||
externalId: nextExternalId ?? current.externalId,
|
||||
localTurns: [],
|
||||
sessionStats: action.detail.session_stats ?? current.sessionStats,
|
||||
...(isActivelyInteracting
|
||||
? {}
|
||||
: { optimisticTurns: [], liveMessage: null }),
|
||||
@@ -483,6 +488,7 @@ function reducer(
|
||||
...current,
|
||||
localTurns: changed ? patchedTurns : current.localTurns,
|
||||
detail: patchedDetail,
|
||||
sessionStats: action.sessionStats ?? current.sessionStats,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user