refactor(tui): classify replay by marker, matching the live listener

The replay loop spelled the classification as
`isSurfaceEligibleType(event.type) && !isAppendSurfaceEvent(event)` while
the live listener used `isReplacementSurfaceEvent(event)`. Under the
mandatory-marker invariant these select the same set: the only divergence
is a surface-eligible event carrying no marker, which no active Session
can hold — `Session.append` and the seed construction loop both reject it
through the same `planSurfaceEvent`.

Using the same predicate on both paths makes "both paths classify a
surface event by the same marker" structural rather than argued, and
retires the TUI's last `isSurfaceEligibleType` use.

No behavior change: the TUI suite and all 113 snapshot fixtures pass
unchanged.
This commit is contained in:
Hypatia May
2026-07-29 17:56:24 +08:00
parent b7bb4842df
commit b0c7a4f324

View File

@@ -35,9 +35,7 @@ import type { ContentBlock, MessageId } from '@deepseek-ai/dsh-llm'
import type {} from '@deepseek-ai/dsh-llm-retry'
import { renderPrompt } from '@deepseek-ai/dsh-system-prompt'
import {
isAppendSurfaceEvent,
isReplacementSurfaceEvent,
isSurfaceEligibleType,
SessionId,
type SessionEvent,
type UserMessage,
@@ -852,7 +850,7 @@ export function createTuiChat(
todo.update([])
const transcriptCalls = transcriptToolCallIds(agent.session)
for (const event of agent.session.events) {
if (isSurfaceEligibleType(event.type) && !isAppendSurfaceEvent(event)) {
if (isReplacementSurfaceEvent(event)) {
if (isCompactCheckpoint(event)) renderCompactionMarker()
continue
}