feat(compact): item 16 压缩重试倒计时 + 卡顿提示 (CC 2.1.228) - #108
Merged
Conversation
compact 期间用户只见静态 spinner, 无重试/耗时可见性。MLX 大上下文摘要
单次流可 30s+ 无 token, 用户无法区分 "正常慢" vs "卡住重试中"。
扩展 CompactProgressEvent 2 新变体:
- compact_retry {attempt, maxRetries, reason}: 截断重试发生时 emit,
reason 复用已算的 isEmptyMlxOom/isMlxServerError/PTL 判定不重判
(prompt_too_long/mlx_memory/mlx_server_error)。主 + partial 两 PTL 循环各 emit。
- compact_stall {elapsedMs}: 周期 emit (default 10s interval), 前端超
FUSION_COMPACT_STALL_HINT_MS (default 30s) 显耗时提示。
startCompactStallTimer helper: setInterval emit compact_stall, 返 clear fn,
两 compact 函数 try 前声明 + compact_start 启 + 现有 finally clear
(覆盖 throw + hook-blocked 早 return, 防泄漏)。不复用 REPL
loadingStartTimeRef (指 query 起点非 compact 起点, elapsed 不准)。
REPL.tsx onCompactProgress switch 加 compact_retry/compact_stall case,
走现有 spinnerMessage 单通道 (Rule 2 简化, 不引新 state)。无 feature-flag
(纯可见性增强, 默认行为不变)。
验证: typecheck 0 / 4 新单测 pass / 全 214 pass / build + build:dev:full pass /
changed 文件 lint clean。closes #107
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 #107)
enhance-0819.md item 16 (CC 2.1.228): compact 期间用户只见静态 spinner
Compacting conversation(REPL.tsx:3366), 无任何重试/耗时可见性。后端有 PTL 截断重试循环 (compact.ts主 + partial 路径, 各最多MAX_PTL_RETRIES=3), 重试时仅logEvent("tengu_compact_ptl_retry")写遥测, 不 emit 用户可见 progress。LLM-summary compact 单次流可合法 30s+ 无 token (MLX 大上下文摘要慢), 用户无法区分 "正常慢" vs "卡住重试中"。
改动 (3 文件 + 1 test, surgical)
src/Tool.ts—CompactProgressEvent加 2 变体 (纯类型):compact_retry {attempt, maxRetries, reason}— reason ∈ prompt_too_long | mlx_memory | mlx_server_errorcompact_stall {elapsedMs}src/services/compact/compact.ts—startCompactStallTimer(context, startTime, intervalMs=10s)helper: setInterval emit compact_stall, 返 clear fncompactConversation主 +partialCompactConversation) 各 emitcompact_retry(复用已算的isEmptyMlxOom/isMlxServerError/PTL 判定, 不重判)clearStallTimer, compact_start 后启, 现有 finally clear (覆盖 throw + hook-blocked 早 return, 防泄漏)src/screens/REPL.tsx—onCompactProgressswitch 加 compact_retry/compact_stall case, 走现有spinnerMessage单通道:Compacting (retry {attempt}/{maxRetries}: {reason})FUSION_COMPACT_STALL_HINT_MS(default 30s, fail-open) →Compacting conversation — running {formatDuration(elapsedMs)}, large context summaries can take a while设计决策
验证
compactProgress.test.ts): emit 递增 / clear 防泄漏 / no-callback no-op / interval 边界 — 全 passCo-Authored-By: Claude Fable 5 noreply@anthropic.com