Repository navigation
feat(perf): item 17 全屏完整 pre-compact 历史 + :598 解耦 synthetic (CC 2.1.224, #111) - #123
Merged
Merged
Conversation
…24, #111) item 17 (enhance-0819.md §99/§204): 全屏模式跨多次压缩保留完整 pre-compaction 历史。删 REPL.tsx fullscreen compact_boundary cap (仅保一个 compact-interval scrollback)。:598 (issue #111) 解耦 syntheticStreamingToolUseMessages 出昂贵 transform — 删 cap 的前置 (否则 n 增长 + 每 delta O(n) 双重恶化)。 问题: :598 useMemo 依赖 syntheticStreamingToolUseMessages, synthetic 每 input_json_delta 变 → 每 delta 重跑 filter/reorder/applyGrouping/collapse/ buildMessageLookups 全 O(n) → GC 100-173ms stop-the-world。真瓶颈非 n 增长, 是每 delta 重跑。 路径 C (非 issue #111 原判 A 全增量, surgical 避 hazard 2/3 内部重构): Change 1 (Messages.tsx :598 memo, 606-702): 昂贵 transform (reorder/group/ collapse/lookups) 仅 keyed on normalizedMessages (流式期间稳定, 变在 turn 边界 /compact/rewind)。reorderMessagesInUI(<filtered>, []) real-only (synthetic 尾 append no-op)。buildMessageLookups(normalizedMessages, messagesToShowReal) — real-only 避免 at(-1) orphan-marker 见 synthetic。dep 数组删 syntheticStreamingToolUseMessages → [verbose, normalizedMessages, isTranscriptMode, shouldTruncate, tools, isBriefOnly]。下游廉价 memo 尾 append synthetic: collapsed_0 = synthetic.length ? [...collapsedReal, ...synthetic] : collapsedReal (O(k)), lookups/truncated/hidden passthrough。 正确性根 (本人独立复核): StreamingToolUse.contentBlock: BetaToolUseBlock, type:"tool_use" 硬编码 (anthropic-protocol.ts:493) → synthetic 永远 plain tool_use 非 server_tool_use。shouldRenderStatically assistant 分支 plain tool_use 走 streamingToolUseIDs.has short-circuit (lookups 前) → synthetic id 在 streamingToolUseIDs → 返 false (动态) 不查 lookups。lookups helper absent id 空默认。 故 synthetic 渲染不需 lookups 条目, 解耦正确。hazard 2/3 内部逻辑零改动 (非前缀可定稿 hazard 本 PR 不碰, 解真瓶颈=每 delta 重跑)。 Change 2 (REPL.tsx 3549-3555): 全屏 compact_boundary 分支 setMessages(old => [...getMessagesAfterCompactBoundary(old,{includeSnipped:true}), newMessage]) → setMessages((old) => [...old, newMessage]) (删 cap)。useLogMessages append-only-aware, first-uuid-stable → 增量记尾 newMessage 正确无需改。 Messages.tsx 全屏已渲染全 array (verbose||isFullscreenEnvEnabled ? normalizedMessages : boundary filter), 兼容。query.ts 仍 boundary 裁 API 调用。 测试 (Rule 9 — 现零覆盖): 新 src/__tests__/utils/messages.test.ts 9 测 4 describe: (1) reorderMessagesInUI 尾-append 属性 (synthetic 纯尾 append, real 顺序不变, 单/空/多合成块); (2) buildMessageLookups absent-id 空默认 (synthetic id 不在 lookups, getProgress/getSibling 返空, resolved 不含, real id 对照在); (3) shouldRenderStatically 短路前提条件链 (BetaToolUseBlock.type 硬编码 tool_use 非 server_tool_use + getToolUseID 返 block.id + id ∈ streamingToolUseIDs has=true → shortCircuitsDynamic); (4) applyGrouping synthetic 透传 (空 tools 透传, real 尾++synthetic = applyGrouping(real+synthetic) 去 synthetic 尾, synthetic 不成组)。 shouldRenderStatically 本体不可单测 (Messages.tsx 顶层 feature() 是 bun:bundle 编译宏, 模块加载即抛), 故测锁定其短路前提条件链。 验证: typecheck 0 errors / 389 测全 pass (9 新 + 380 旧无回归) / build:dev pass。 2 prod 文件 +31/-19 + 1 新 test 文件。hazard 2/3 零改动, 无 vendored-ink 文件触, tab 缩进保现风格。 Co-Authored-By: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 22, 2026
Patch release bundling 17 commits since v0.4.23: - item 15(a) MLX OOM auto-recovery gc+retry (#129) - #7 one-click diagnostic fixAction framework (#131) - 维度5 background-default spawn FUSION_SUBAGENT_DEFAULT_BACKGROUND (#127) - #4 proactive MLX OOM detection via /v1/health (#125) - item 17 fullscreen pre-compact history + :598 synthetic decouple (#123) - item 25B workflow stagger fan-out (#122) - item 21 auto-mode local rule classifier test coverage (#120) - item 23 archive plugin source + SHA-256 lock (#118) - item 24 marketplace command source (#116) - item 6 transcript disk trimming + crash-safe checkpoint (#114) - item 5 normalizeMessages secondary normalize cache (#112) - item 19 screen-reader plaintext render (#110) - item 16 compact retry countdown + stall hint (#108) - item 25A workflow execution runtime docs (#106) - item 25A minimal workflow execution runtime (#105) - item 12 subagent auto-background threshold (#103) - item 20 vimInsertModeRemaps dual-key INSERT sequence (#101) Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
closes #111
item 17 (enhance-0819.md §99/§204, CC 2.1.224): 全屏模式跨多次压缩保留完整 pre-compaction 历史。:598 (issue #111) 解耦 syntheticStreamingToolUseMessages 出昂贵 transform — 删 item 17 cap 的前置。
问题
setMessages(old => [...getMessagesAfterCompactBoundary(old,...), newMessage])仅保一个 compact-interval scrollback。注释明言 normalizeMessages/applyGrouping O(n) per render 故裁。:598useMemo 依赖syntheticStreamingToolUseMessages, synthetic 每 input_json_delta 变 → 每 delta 重跑 filter/reorder/applyGrouping/collapse/buildMessageLookups 全 O(n) → GC 100-173ms stop-the-world。非 n 增长, 是每 delta 重跑。路径 C (非 issue #111 原判 A 全增量)
issue #111 原判 = A 全增量缓存, 阻塞于 hazard 2/3 (applyGrouping 全数组扫 / buildMessageLookups orphan-marker 非前缀可定稿), correctness 高风险 → 推迟。
本 PR = 路径 C: 解耦 synthetic 出昂贵 transform (不碰 hazard 2/3 内部), 删 cap 安全。surgical 避 L-size 重构。
Change 1 — 解耦 synthetic 出 :598 (Messages.tsx:606-702)
昂贵 transform (reorder/group/collapse/lookups) 仅 keyed on
normalizedMessages(流式期间稳定, 变在 turn 边界/compact/rewind)。reorderMessagesInUI(<filtered>, [])real-only (synthetic 尾 append no-op)。buildMessageLookups(normalizedMessages, messagesToShowReal)real-only 避免at(-1)orphan-marker 见 synthetic。dep 数组删syntheticStreamingToolUseMessages。下游廉价 memo 尾 append synthetic O(k):collapsed_0 = synthetic.length ? [...collapsedReal, ...synthetic] : collapsedReal, lookups/truncated/hidden passthrough。正确性根 (本人独立复核):
StreamingToolUse.contentBlock: BetaToolUseBlock,type:"tool_use"硬编码 (anthropic-protocol.ts:493) → synthetic 永远 plain tool_use 非 server_tool_use。shouldRenderStaticallyassistant 分支 plain tool_use 走streamingToolUseIDs.hasshort-circuit (lookups 前) → synthetic id 在 streamingToolUseIDs → 返 false (动态) 不查 lookups。lookups helper absent id 空默认。故 synthetic 渲染不需 lookups 条目, 解耦正确。hazard 2/3 内部逻辑零改动。Change 2 — 删 item 17 全屏 cap (REPL.tsx:3549-3555)
setMessages(old => [...getMessagesAfterCompactBoundary(old,{includeSnipped:true}), newMessage])→setMessages((old) => [...old, newMessage])。useLogMessagesappend-only-aware, first-uuid-stable → 增量记尾正确无需改。Messages.tsx 全屏已渲染全 array, 兼容。query.ts 仍 boundary 裁 API。测试 (Rule 9 — 现零覆盖, 必须新建)
新
src/__tests__/utils/messages.test.ts9 测 4 describe:shouldRenderStatically本体不可单测 (顶层 feature() 是 bun:bundle 编译宏, 模块加载即抛), 故测锁定其短路前提条件链。验证
bun run typecheck— 0 errors ✓bun test src/__tests__/— 389 pass (9 新 + 380 旧无回归) ✓bun run build:dev— pass ✓风险
shouldRenderStaticallyplain tool_use short-circuit 在 lookups 前) 独立复核确认, 测 1-3 lock。任一 fail 保推迟 (不预期)。Co-Authored-By: Claude Fable 5 [email protected]