Repository navigation
feat(web-shell): bridge trajectory history and live lifecycle state - #13952
Conversation
Independent E2E verificationReviewed implementation: Real daemon + controlled provider + SDK/source trajectory state
All three controlled scripts exited 0; model requests stayed on a loopback fixture provider. Test daemon/provider/browser processes were cleaned up. Chromium functional fixture1440×1000, real trajectory components with eight synthetic history pages. After navigating to the older four-page window, filtering Automated validationBuild, bundle, full-workspace typecheck, changed-file ESLint/Prettier and 1,970 relevant tests passed: Web Shell 821; bridge 999; SDK 93; CLI redaction/Standalone 43; replay routes 5; App/artifact trajectory 9. Bridge tests simulate published-but-unpersisted lifecycle frames and verify the bounded supplement at the same watermark. Provider React tests cover replay, reconnect, ring recovery, heartbeat auth failure and same-session cross-workspace replacement. LimitsNo real filesystem-delay injection, full App-to-daemon browser recovery, or new native concurrent subagent/PostToolUse/permission E2E was performed. Hosted CI is separate from these local results. Existing tool timings cannot be associated with executions without a stable execution ID, so those executions remain a separate bounded collection. No deployment or production validation is claimed. |
🩺 serve daemon A/BBuilt the PR base vs this PR head
|
| field | PR base (before) | this PR (after) |
|---|---|---|
activeWorkStaleMs |
5 |
4 |
— Qwen Code · serve A/B
🖼️ web-shell visual previewRendered against a mock daemon (no real backend): the PR base vs this PR head Screenshots · before / afterFull-resolution recordings (.webm) are attached to the workflow run. — Qwen Code · web-shell visuals |
PR6C 独立验收:暂不通过验收提交: [P2] 缺口恢复会卸载轨迹面板,丢失正在浏览的历史窗口Provider 遇到 ring eviction / epoch reset 后重新加载会话,常规路径会设置 独立 App 组件测试已复现:
这是完整 App 组件树配合 mock connection 的复现;Provider 设置该 flag 的路径另经源码核对。现有直接驱动 store 的浏览器 fixture 始终保持面板挂载,因此没有覆盖此路径。清空 tabs 的逻辑原已存在,但 PR6C 承诺的“缺口恢复保留历史位置”尚未在 App 集成层完成。 请在同一会话恢复时保留面板实例,或显式保存并恢复窗口及交互状态,同时保持跨 session/workspace 隔离;补充 App 层恢复回归,覆盖旧页、筛选、选择和视口,而不只测试 store 状态切换。 CI 门禁Ubuntu Test 失败: 已通过与证据边界
另有非阻塞测试建议:为生命周期 supplement 增加 turn_complete 后的覆盖。替身测试可复现既有 compaction 合并连续 request 元数据,但真实 backward transcript 读取会先 flush recorder,尚未证明构成生产环境新增缺陷,因此不将其列为第二个阻塞项。 |
|
Thanks for the PR — this is a carefully built piece of work and the description is unusually honest about its own limits. Template looks good ✓ Problem: Real, but it is an architectural gap rather than an observed user-facing bug. A cursor-paged transcript load and a bus-watermark subscription genuinely can disagree, and a replayed Direction: Aligned. The web-shell trajectory surface is actively developed, #13836 landed the native tool-execution lifecycle recording, and surfacing that recorded evidence in the inspector is the obvious next step. The wire change is additive and optional ( Size: This spans four packages ( Approach: The shape matches what I would have designed independently — a bounded in-memory supplement emitted at the page's own watermark, carried as an optional additive field, folded client-side with terminal-wins semantics, owner/epoch-scoped, and gap-sticky until a fresh snapshot. Reuse is good: it drives the SDK's existing
Neither is a blocker on its own; together they are the "would cutting this make the PR worse?" question. Risk: No elevated risk signals — none of the changed paths match the revert-correlated set. The real risk sits in Stage 2: a required check is red on this head. Moving on to code review. 🔍 中文说明感谢贡献——这个 PR 做得很细致,描述对自身局限也相当坦诚。 模板完整 ✓ 问题: 真实存在,但属于架构性缺口,而非已观测到的用户可见 bug。游标分页加载与总线水位订阅确实可能不一致,回放出的 方向: 对齐。web-shell 轨迹界面正在积极开发,#13836 已落地原生工具执行生命周期记录,把这些已记录的证据展示到检查器是自然的下一步。协议改动是可选新增字段( 规模: 跨四个包( 方案: 整体结构与我独立设想的方案一致——在页面自身水位上补发有界内存数据,作为可选新增字段承载,客户端以"终态优先"折叠,按 owner/epoch 限定作用域,出现缺口后保持粘性直到重新取快照。复用做得好:调用 SDK 已有的
两者单独都不构成阻断,合起来就是"砍掉这部分会不会让 PR 变差"的问题。 风险: 无升级风险信号——改动路径均未命中与回滚相关的高风险集合。真正的风险在 Stage 2:当前 head 上有一个必需检查是红的。 进入代码审查 🔍 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
Code reviewI read the diff against an independent proposal written first from the title and the "Why it's needed" section. The shape matched what I would have built — bounded supplement at the page's own watermark, optional additive wire field, terminal-wins fold, owner/epoch scoping, gap-sticky until a fresh snapshot — so this is a review of execution, not of direction. 🔴 Blocker: a required check is red on this head, and the diff is a cause
This is the transcript-entry size ceiling, not a flaky timing assertion. That test's own docblock states the daemon hook runtime is not absent from the transcript entry — The docblock records main at 1,321,586 and this branch at 1,324,022 — about 978 bytes of margin, now overshot by 3,613. Some of that drift is main growing in parallel, which the docblock also documents as normal. But the PR cannot merge with a red required check either way, and I would not fix it by raising the ceiling: the docblock says to "re-measure and lower it if the entry gets leaner", i.e. the number is meant to bound real growth. The durable fix is to keep the store out of the transcript entry's static graph — lazy-import it, or hoist Verified correct — the load-bearing contractsThese are the places where a silent mismatch would have made the feature a no-op while every test still passed, so I checked each against the SDK rather than trusting the names:
Non-blocking
sequenceDiagram
participant P1 as Bridge session entry
participant P2 as SDK session client
participant P3 as Session provider
participant P4 as Trajectory live store
participant P5 as Lifecycle projection
participant P6 as Trajectory inspector
P1->>P2: restored session, paged replay
P1->>P2: lifecycle supplement at same watermark
P2->>P3: replay snapshot with lifecycle frames
P3->>P4: begin with owner, sessionId, scope, epoch
P3->>P4: ingest each subscription event
P4->>P4: fold, terminal wins over replayed start
P4->>P5: live snapshot
P5->>P5: join request rows by execution id
P5->>P6: lifecycle for the selected row
Files changed (24)
Test evidenceThis is an unattended CI run, so per the gate's rules I did not build or execute any PR-derived code. Everything below is the PR's own CI, read through the API for the reviewed commit The suite is overwhelmingly green — 11,298 of 11,299 tests pass — and the single failure is the bundle ceiling analysed above. It is not pre-existing infra noise: it is a deterministic size assertion on a bundle this diff grows, and it failed identically on all three retries. Final CI results for
One row per check name (latest run); skipped checks omitted; failures sort first. / 每个检查名一行(取最新一次运行),省略 skipped,失败项排在最前。 Three checks were still in flight at review time; I did not poll or guess their outcome. The The Not verified: the author's local results — 1,970 targeted tests, the Chromium fixture, and the real-daemon replay/eviction/epoch scripts — are the author's own claim on macOS, not independently re-run here, and I am not presenting them as evidence. The PR body itself scopes out "full App-to-daemon browser recovery", and the fixture omits the full App theme, so the App-level integration path is the gap. Sandboxed verification would settle this: Real-scenario testingN/A — unattended CI run. Per the gate's rules I never build or execute PR-derived code here; the live-behaviour signal is the sandboxed lane named above. 中文说明代码审查我先只根据标题和"为什么需要"独立写出方案,再对照 diff。整体结构与我独立设想的一致——在页面自身水位补发有界数据、可选新增协议字段、终态优先折叠、按 owner/epoch 限定、缺口保持粘性直到重新取快照——所以这是对实现质量的审查,而非对方向的审查。 🔴 阻断项:当前 head 上有一个必需检查是红的,且本 diff 是成因之一
该测试的注释明确说明 transcript 入口包含 daemon hook 运行时,因为 注释记录 main 为 1,321,586、本分支为 1,324,022,余量约 978 字节,现已超出 3,613 字节。其中一部分是 main 并行增长(注释也认为这属正常)。但无论如何,必需检查为红就不能合并;而且我不建议靠调高上限来解决——注释写的是"若入口变瘦应重新测量并调低",说明这个数字是用来约束真实增长的。更持久的修法是让 store 不进入 transcript 入口的静态依赖图:改为懒加载,或把 已验证正确的关键契约以下都是"一旦不匹配就会让整个功能静默失效、但测试照样全绿"的位置,所以我逐条对照 SDK 核实,而不是看名字推断:
非阻断项
(时序图见英文部分,此处不重复。) 测试证据本次为无人值守 CI 运行,按门禁规则我没有构建或执行任何来自 PR 的代码。以下内容全部是通过 API 读取的、针对被审 commit 测试套件绝大多数是绿的——11,299 项中 11,298 项通过——唯一失败就是上文分析的包体积上限。它不是既有的基础设施噪声:这是一个确定性体积断言,针对的正是本 diff 会撑大的产物,且三次重试失败完全一致。 审查时有三项检查仍在运行;我没有轮询,也没有猜测其结果。CI 稳定后由
未验证: 作者的本地结果——1,970 项定向测试、Chromium fixture、真实 daemon 的回放/淘汰/epoch 脚本——是作者在 macOS 上的自述,此处未独立重跑,我也不将其作为证据呈现。PR 正文自身也把"完整 App 到 daemon 的浏览器恢复"列为范围外,且 fixture 没有完整 App 主题,所以 App 级集成路径就是缺口所在。 沙箱验证可以解决这个问题: 真实场景测试N/A——无人值守 CI 运行。按门禁规则此处绝不构建或执行 PR 代码;实时行为信号来自上文点名的沙箱通道。 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
Confidence: 2/5 — the engineering is genuinely good and every load-bearing contract I checked holds, but a required check is red on this head and the diff is a cause, so it cannot merge as-is. Going back to the proposal I wrote before opening the diff: this PR matches it closely, and in a few places exceeds it. Reusing the SDK's existing lifecycle reducers instead of writing parallel ones was the right call, and threading the existing skill/workflow redaction paths rather than adding a new sanitiser is exactly how that should be done. The failure modes it defends against — epoch reset, ring eviction, watermark reuse, owner switch, a replay-complete marker arriving after a gap — are the ones I would have enumerated, and the test names show they are pinned individually rather than asserted in passing. I spent most of my effort trying to break the join, because that is where this design can fail silently: if the client's key format drifted one field from the SDK's, or What stops me is the bundle ceiling. It is not a flake and it is not pre-existing noise: a deterministic size assertion on an artifact this diff grows, failing identically three times. The interesting part is why it grew — the transcript entry now statically pulls in the trajectory-live subsystem, which it never renders. That is the guard doing its job, catching an architectural leak rather than a rounding error, and raising the ceiling would discard the signal. It also happens to be the finding I would most want a maintainer to see, since the fix (lazy-import, or hoist the provider) is a small change with a real design implication. My honest reservation beyond the blocker is the one from Stage 1, and the red check sharpens it rather than resolving it: five of six projection fields have no production reader, and the entire tool-lifecycle half is computed and merged every render without ever reaching the UI. The PR is upfront that live bars and following are follow-ups, so this is plumbing landed ahead of its consumer. That is a defensible way to sequence a six-part series — but it means the diff is larger than what this PR actually delivers, and the bundle ceiling is a concrete symptom of that: code with no reader in this entry is still being paid for in this entry. Six months from now I would thank the author for the reducer reuse, the explicit staleness, and the tests; I would ask why the transcript entry ships trajectory-live code. Two process notes for whoever picks this up. First, this spans four packages, which makes it core infrastructure under the gate's definition, and at 746 production lines it crosses the threshold where a Requesting changes on the strength of the red required check — that is a concrete, fixable blocker, not a judgement call about direction. @qqqys, the rest of this is close; the bundle fix and a decision on the unread surface are what stand between it and a merge. 中文说明Confidence: 2/5 — 工程质量确实不错,我核查的每一个关键契约都成立,但当前 head 上有一个必需检查是红的,且本 diff 是成因之一,因此按现状不能合并。 回到我在打开 diff 之前写下的方案:本 PR 与之高度一致,某些地方还更好。复用 SDK 已有的生命周期 reducer 而不是另写一套,是正确选择;沿用既有的 skill/workflow 脱敏路径而不是新增一个脱敏器,也正是应该的做法。它所防御的失败模式——epoch 重置、ring 淘汰、水位复用、owner 切换、缺口之后才到达的 replay-complete 标记——就是我会列举的那些,而且从测试名称可以看出这些是被逐条固定的,不是顺带断言的。 我花了最多精力试图打破"关联"这一环,因为这是该设计唯一可能静默失效的地方:如果客户端的键格式与 SDK 差一个字段,或者 拦住我的是包体积上限。它不是抖动,也不是既有噪声:这是一个确定性的体积断言,针对的正是本 diff 会撑大的产物,且三次失败完全一致。更值得注意的是它为什么变大——transcript 入口现在静态引入了 trajectory-live 子系统,而它从不渲染这个子系统。这正是该守卫在发挥作用:它抓到的是架构上的泄漏,而不是四舍五入的误差;调高上限会把这个信号丢掉。这也恰好是我最希望维护者看到的一条,因为修法(懒加载,或把 Provider 上提)改动很小,却有实质的设计含义。 除阻断项之外,我真实的保留意见就是 Stage 1 提到的那条,而这次的红灯让它更尖锐,并没有化解它:六个投影字段中有五个没有生产读者,整个工具生命周期这一半每轮渲染都被计算和合并,却从不进入 UI。PR 坦率地说明实时条带与跟随属于后续工作,所以这是先于消费方落地的管道代码。对一个六部曲系列来说,这样的排期是可以辩护的——但它意味着 diff 比本 PR 实际交付的东西更大,而包体积上限正是这一点的具象症状:在这个入口里没有读者的代码,仍然要由这个入口付出体积代价。 六个月后回看,我会感谢作者在 reducer 复用、显式 staleness 和测试上的用心;但我会问,为什么 transcript 入口要打包 trajectory-live 代码。 给接手的人两条流程提示。第一,本 PR 跨四个包,按门禁定义属于核心基础设施,746 行生产代码也已越过 基于必需检查为红这一条请求修改——这是一个具体、可修的阻断项,不是对方向的判断。@qqqys,其余部分已经很接近了;需要做的就是修包体积,并对未被读取的接口面做一个决定。 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Needs a fix before this can merge — see my notes above. 🙏
Blocker: Test (ubuntu-latest, Node 22.x) is red on this head, deterministically (same assertion across all three retries):
build-artifact.test.ts > keeps the transcript entry a fraction of the interactive entry
AssertionError: expected 1328613 to be less than 1325000
The transcript entry ships DaemonSessionProvider, and this PR adds a static import of the trajectory-live store to that module — so the new subsystem is now bundled into an entry that never renders the trajectory panel. I'd fix the leak rather than raise the ceiling: lazy-import the store, or hoist TrajectoryLiveContext.Provider above DaemonSessionProvider so the provider module doesn't statically depend on it. That test's docblock explicitly asks for the ceiling to be re-measured downward when the entry gets leaner, so the number is meant to bound real growth.
Everything else I checked holds up well — the client/SDK key formats match exactly, event.kind is 'request' on both sides of the join, terminal-wins is genuinely enforced by the SDK reducer, the context is reachable from the panel, and both loader call sites pass the new scope. The reducer reuse and redaction threading are the right calls.
One thing to decide while you're in there: five of the six fields on TrajectoryLifecycleProjection have no production reader, and the tool-lifecycle half is computed and merged every render without reaching the UI. Fine if it's scaffolding for the follow-ups — just worth a deliberate choice rather than an accident.
Also flagging for maintainer awareness: this spans four packages (core infrastructure under the gate's definition) at 746 production lines, so it needs a human sign-off rather than a bot approval even once the suite is green. And nobody has yet exercised the App-to-daemon path — @qwen-code /verify would settle it.
中文说明
合并前需要先修一处——详见上面的审查意见。🙏
阻断项: 当前 head 上 Test (ubuntu-latest, Node 22.x) 为红,且是确定性的(三次重试断言完全相同):
build-artifact.test.ts > keeps the transcript entry a fraction of the interactive entry
AssertionError: expected 1328613 to be less than 1325000
transcript 入口会打包 DaemonSessionProvider,而本 PR 在该模块中静态引入了 trajectory-live store——于是这个从不渲染轨迹面板的入口,现在把新子系统一起打包了进去。建议修掉泄漏本身,而不是调高上限:改为懒加载 store,或把 TrajectoryLiveContext.Provider 提到 DaemonSessionProvider 之外,使 provider 模块不静态依赖它。该测试的注释明确要求在入口变瘦时把上限重新测量下调,说明这个数字是用来约束真实增长的。
其余我核查的部分都站得住——客户端与 SDK 的键格式完全一致,关联两侧的 event.kind 都是 'request',终态优先确实由 SDK reducer 强制保证,面板可以取到 context,两处 loader 调用都传了新的 scope。复用 reducer、沿用脱敏路径都是正确的选择。
顺手想请决定一件事:TrajectoryLifecycleProjection 六个字段中有五个没有生产读者,工具生命周期这一半每轮渲染都被计算和合并却进不了 UI。如果是为后续 PR 预留的脚手架那没问题——只是希望这是一个有意识的选择,而不是无意留下的。
另外提请维护者知悉:本 PR 跨四个包(按门禁定义属于核心基础设施),生产代码 746 行,因此即使测试全绿也需要人工签核,而非机器人批准。另外 App 到 daemon 这条路径尚无人验证——@qwen-code /verify 可以解决。
— Qwen Code · qwen3.8-max-2026-09-02
[P2] 生命周期补充读取有损压缩结果,可能漏掉已发布但未落盘的请求核实提交: session-control-plane.ts:8016–8024 使用 在该 head 直接运行 因此,当这个已完成 turn 的持久化仍落后时,分页结果没有第一个 execution,内存 supplement 也已经丢掉它;返回的 建议让补充来源保留每个 execution 的生命周期(例如避免生命周期帧进入有损文本合并),并补充 turn 完成后、持久化尚未完成 的回归。当前新增 bridge 测试只发送生命周期帧,没有触发 验证边界:这是 exact-head 压缩器脚本复现,加上 supplement 消费路径的源码核实,不是真实文件系统延迟 E2E。另独立运行了 trajectory、DaemonSessionProvider 与 App 相关测试,22 个文件 / 1,980 项通过;此前同会话恢复丢失历史窗口、筛选、选择及滚动位置的回归已通过,不再重复报告旧问题。 |
|
已修复本条 P2,并补充了 turn 完成后的回归。提交: 对应验收意见:#13952 (comment) 根因确实是请求生命周期帧进入了文本合并:同一 turn 中两个 execution 的 started/ended 在压缩后只剩最后一条元数据。现在请求生命周期帧独立保留,沿用现有 replay 字节预算和淘汰机制;生命周期 supplement 的 1,024 条上限与截断标记保持不变。 验证:
验证边界:这是确定性的 bridge/压缩器回归,模拟持久化尚未完成;未做真实文件系统延迟注入,也不代表完整浏览器到 daemon E2E。新提交的远端 CI 和复审仍需单独完成。 |
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Partially reviewed — gaps disclosed. Suggestions are inline.
2 Suggestion-level finding(s) this review confirmed are already reported on this PR and are not repeated:
- project-trajectory-lifecycle.ts:135-142 byExecution/outsideWindow have no production reader — already reported (review 5487929747 and triage comment 6120101450)
- session-control-plane.ts:8064 lifecycleReplayIncomplete terminates in a field no production code reads — already reported (review 5487929747)
Not explored to full depth (tool budget reached): "agent reverse-audit (round 1)": whether a transcript page fetched for session X can carry executionLifecycle frames stamped with sessionId !== X — settling it needs the resume/fork path in…; "agent reverse-audit (round 1)": the third createTrajectoryPageLoader call site ( App.tsx:6604 ) was not read, so I did not confirm whether any production loader passes scope === undefined ;…; "agent reverse-audit (round 3)": whether expect(blocks).toEqual([]) in the two new bridge tests is vacuous — I confirmed the provider has no lifecycle-frame filter ( grep toolLifecycle|execut…; chunk 6: did not read the daemon's getSessionTranscriptPage route implementation to settle whether a history_truncated marker can appear in trajectory pages (bearing…; "agent reverse-audit (round 4)": whether the row side's executionId ( timing.executionId ← uiEvent['execution_id'] , acp-bridge/src/transcript-replay.ts:953-956 ) and the frame side's exe…, and 8 more.
Not reviewed: reverse audit — did not converge within the reverse-audit round cap of 5.
中文说明
仅完成部分审查,审查缺口已披露。 建议见行内评论。
本轮确认的 2 条建议级发现已在 PR 上报告过,不再重复发布(列表见上方英文部分)。
未探索到全部深度(达到工具调用预算):"agent reverse-audit (round 1)":whether a transcript page fetched for session X can carry executionLifecycle frames stamped with sessionId !== X — settling it needs the resume/fork path in…;"agent reverse-audit (round 1)":the third createTrajectoryPageLoader call site ( App.tsx:6604 ) was not read, so I did not confirm whether any production loader passes scope === undefined ;…;"agent reverse-audit (round 3)":whether expect(blocks).toEqual([]) in the two new bridge tests is vacuous — I confirmed the provider has no lifecycle-frame filter ( grep toolLifecycle|execut…;chunk 6:did not read the daemon's getSessionTranscriptPage route implementation to settle whether a history_truncated marker can appear in trajectory pages (bearing…;"agent reverse-audit (round 4)":whether the row side's executionId ( timing.executionId ← uiEvent['execution_id'] , acp-bridge/src/transcript-replay.ts:953-956 ) and the frame side's exe…,另有 8 条。
未审查:反向审计——在 5 轮的反审轮数上限内未收敛。
— qwen3.8-max via Qwen Code /review (v0.25.1)
| compactedReplay = [...page.events, turnErrorEvent]; | ||
| } | ||
| } | ||
| const lifecycleSnapshot = entry.events.snapshotReplay(); |
There was a problem hiding this comment.
[Suggestion] R1-2: The paged-restore branch builds its lifecycle supplement from an unconditional full snapshotReplay(), which costs twice over. First, it re-sends frames the persisted page already carries: the page is projected with includeTiming: true (history-replay-page.ts:486-487) and transcript-replay.ts:1709-1711 re-emits executionLifecycle/toolLifecycle frames from persisted telemetry records, so the same recent lifecycle frames ride in both arrays — up to 1024 duplicated events. That contradicts the field's own doc (bridgeTypes.ts:783, "Bounded in-memory lifecycle supplement for a persisted replay page") and the new test's name ("supplements a persisted page with %i unpersisted lifecycle frames"). The overlap is expected rather than incidental, because this branch is entered only when !entry.promptActive with unchanged epoch and watermark — i.e. the turn completed and persisted. Both reducers no-op on identical duplicates, so nothing renders wrong today; the cost is payload and serialization on the session-reopen path the surrounding code optimizes for. Second, latency: snapshot() is not memoized — it goes through flattenReplaySegments() (compactionEngine.ts:989-993, a slice().flatMap() over every retained event) and then liveJournalSnapshot('full') (:376-390, which rebuilds each merged text segment) — so every paged loadSession pays a full window flatten plus a full-journal rebuild to keep only the few frames whose _meta carries a lifecycle record. The branch two lines above deliberately uses the cheaper accessor, whose own docblock reads "Cheaper than snapshot(): no replay-window flatten." The call also drops the liveReplayMode parameter in scope at :7937 (used at :7948 and :8086), so a client that asked for summary still pays a full journal rebuild.
Witness:
witness: not run — no mutation or bench was applied. `review scratch-tree` returned
`available: false` (repo-local includeIf.gitdir points at a missing credentials file), so no
isolated tree existed to instrument; the mechanism is established by reading snapshot()'s call
chain and by the two texts that both say "unpersisted" (the field doc and the test name).
Suggested fix: add a bounded, lifecycle-only accessor on the event bus that walks the raw segments without flattening and yields only frames whose _meta carries executionLifecycle/toolLifecycle, honouring liveReplayMode; then filter the result against the record ids the persisted page already carried before assigning lifecycleReplay.
One premise the fix must not violate: a cheaper accessor must still read the full journal, not the summary one. isSummaryReplayEvent returns false for any session_update whose _meta.parentToolCallId is a non-empty string differing from its own toolCallId (replay-summary.ts:32-38), and EventBus.publish applies that projection before the ring and engine see the event when eventDetailMode === 'summary' (eventBus.ts:594-598). A subagent request-lifecycle frame carries exactly that parentToolCallId — the compaction test this PR adds parameterizes it (it.each([undefined, 'parent-tool'])) — so a summary-mode accessor would silently drop subagent lifecycle frames.
Acceptance criterion: extend the existing bridge.test.ts case that feeds both a persisted page and an in-memory window so it asserts refreshed.lifecycleReplay contains only frames absent from refreshed.compactedReplay/liveJournal; removing the dedup filter must turn it red.
中文说明
分页恢复分支用一次无条件的完整 snapshotReplay() 来构造 lifecycle 补充数据,这带来两重开销。第一,它会重复发送持久化页已经携带的帧:分页数据是以 includeTiming: true 投影出来的(history-replay-page.ts:486-487),而 transcript-replay.ts:1709-1711 会从持久化的 telemetry 记录中重新发出 executionLifecycle/toolLifecycle 帧,因此同一批近期 lifecycle 帧会同时出现在两个数组里——最多 1024 个重复事件。这与字段自身的文档相矛盾(bridgeTypes.ts:783:"Bounded in-memory lifecycle supplement for a persisted replay page"),也与新增测试的名称相矛盾("supplements a persisted page with %i unpersisted lifecycle frames")。这种重叠是必然而非偶然,因为只有在 !entry.promptActive 且 epoch 与水位线都未变化时才会进入该分支——也就是回合已完成并已持久化。两个 reducer 对完全相同的重复帧都是空操作,所以目前不会渲染出错;代价体现在会话重新打开这条路径上的负载与序列化开销,而周围代码恰恰是为这条路径做优化的。第二,延迟:snapshot() 没有做记忆化——它会经过 flattenReplaySegments()(compactionEngine.ts:989-993,对所有保留事件做 slice().flatMap()),再经过 liveJournalSnapshot('full')(:376-390,会重建每一个合并后的文本段)——因此每次分页 loadSession 都要付出一次完整的窗口展开加一次 full journal 重建,只为留下少数几个 _meta 中带 lifecycle 记录的帧。而就在上面两行的分支刻意使用了更廉价的访问器,其文档注释写着 "Cheaper than snapshot(): no replay-window flatten."。此处调用还丢弃了作用域内的 liveReplayMode 参数(:7937 定义,:7948 与 :8086 使用),所以请求 summary 的客户端仍会付出一次 full journal 重建。
证据:
witness: not run — 未做变更或基准测试。`review scratch-tree` 返回 `available: false`
(仓库本地 includeIf.gitdir 指向一个缺失的凭据文件),因此没有可用于插桩的隔离代码树;
该机制是通过阅读 snapshot() 的调用链,以及字段文档与测试名称这两处都写明 "unpersisted"
的文本确立的。
建议修复:在 event bus 上增加一个有界的、只取 lifecycle 的访问器,它直接遍历原始分段而不做展开,只产出 _meta 中携带 executionLifecycle/toolLifecycle 的帧,并遵守 liveReplayMode;然后在赋值给 lifecycleReplay 之前,用持久化页已携带的 record id 过滤结果。
修复必须遵守的前提:更廉价的访问器仍必须读取 full journal,而不是 summary journal。isSummaryReplayEvent 对任何 _meta.parentToolCallId 为非空字符串且与自身 toolCallId 不同的 session_update 都返回 false(replay-summary.ts:32-38),并且当 eventDetailMode === 'summary' 时,EventBus.publish 会在 ring 与 engine 看到事件之前就应用该投影(eventBus.ts:594-598)。子代理的 request-lifecycle 帧恰好携带这样的 parentToolCallId——本 PR 新增的 compaction 测试就对其做了参数化(it.each([undefined, 'parent-tool']))——因此 summary 模式的访问器会静默丢弃子代理的 lifecycle 帧。
验收标准:扩展 bridge.test.ts 中那个同时提供持久化页与内存窗口的既有用例,断言 refreshed.lifecycleReplay 只包含 refreshed.compactedReplay/liveJournal 中不存在的帧;去掉去重过滤后该断言必须变红。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Confirmed as a bounded performance improvement; deferred to PR7. This round keeps the existing full replay snapshot because subagent lifecycle records can live in that journal, and introducing a separate event-bus accessor would expand the repair. Page/supplement overlap is now documented and covered by idempotent request/tool replay tests. Follow-up: measure maximum-window refresh allocation and add a lifecycle-specific extraction path with subagent and truncation coverage. Leaving this thread open.
| subagentId?: string; | ||
| executionId: string; | ||
| }) => | ||
| JSON.stringify([item.sessionId, item.subagentId ?? null, item.executionId]); |
There was a problem hiding this comment.
[Suggestion] R1-4: The store-level running → unknown downgrade is one-way: an execution the client actually observed live is downgraded by a transient stream_closed, and then cannot be re-promoted even after the store itself reports 'live' again — because the forced-'replay' source override here blocks the reducer's live arm. unknownRunning (:57-80) rewrites stored entries and nothing restores them. After reconnect() plus replay_complete puts the snapshot back at 'live', re-delivering the same live 'started' frame still yields 'unknown', because applyLifecycleUnchecked forces source: 'replay' for any key already in entries, and both reducers grant 'running' only for prior?.status === 'running' || options.source === 'live' — the prior is now 'unknown', so neither disjunct holds. The sibling projection computes the same downgrade reversibly at read time (project-trajectory-lifecycle.ts derives it from live.status and never mutates the store), so the same stored 'running' entry projects 'unknown' at 'stale' and 'running' at 'live'. To be fair to the diff's intent: the reducer's contract is "a replayed start does not prove a live request" (execution-lifecycle.ts:129) and trajectory-live-store.test.ts pins the reconnect-window downgrade deliberately, so that part is a design decision and not a defect. But that doctrine answers a start never seen live; nothing argues the third state this gate also covers — discarding a liveness fact the client observed live and then refusing to re-accept it once the store reports 'live'. Two scoping notes: the wrong window runs from the drop until the execution ends (the 'ended' frame still resolves the terminal, so it is not permanent), and the observable surface is narrow — the entry reaches only TrajectoryInspector.tsx:107 as a JSON.stringify dump, so the cost is "status": "unknown" instead of "status": "running" in the request inspector's Summary tab, with no row badge, filter or tone keying off it.
Witness (probe against the real createTrajectoryLiveStore and the real projectTrajectoryLifecycle):
{"observedLive":["running"],
"afterInvalidate":["unknown"], <- invalidate(owner,'stream_closed')
"afterReconnect":["unknown"], <- reconnect(owner)
"backToLiveStatus":"live", <- replay_complete restored 'live'
"afterRedelivery":["unknown"], <- the SAME live 'started' frame re-delivered
"projectedNotLive":["unknown"], "projectedLive":["running"]} <- projection IS reversible
Suggested fix: distinguish "entry is terminal" from "entry was downgraded to unknown" so a genuinely live re-delivery can re-promote — in applyLifecycleUnchecked, pass source: 'live' when the incoming source is live and the existing entry's status is 'unknown' (rather than forcing 'replay' for every known key), or record a downgradedFrom marker in unknownRunning and let a later live frame clear it.
One premise the fix must not violate: the forced-'replay' override is not simply deletable, because without it a duplicate live 'started' frame would clobber a terminal 'success' back to 'running' via the reducer's source === 'live' disjunct. trajectory-live-store.test.ts pins both directions — 'keeps replay %s starts unknown and only new live starts running' and 'preserves %s terminal evidence across duplicates and reconnect' (asserting ['success','unknown'] immediately after reconnect()) — so a fix must keep terminals terminal. The re-promotion variant is untested.
Acceptance criterion: a new case in trajectory-live-store.test.ts that seeds a live 'running' entry, calls invalidate(owner,'stream_closed'), reconnect(owner), ingests replay_complete, then re-delivers the same live 'started' frame and asserts the entry is 'running' again; removing the re-promotion must turn it red.
中文说明
store 层的 running → unknown 降级是单向的:客户端确实实时观察到的执行会被一次瞬时的 stream_closed 降级,之后即使 store 自身已重新报告 'live',也无法被重新提升——因为此处强制的 'replay' source 覆盖挡住了 reducer 的 live 分支。unknownRunning(:57-80)会改写已存储的条目,而没有任何逻辑会把它恢复。在 reconnect() 加 replay_complete 把 snapshot 重新置为 'live' 之后,重新投递同一个实时 'started' 帧仍然得到 'unknown',因为 applyLifecycleUnchecked 对任何已存在于 entries 的 key 都强制 source: 'replay',而两个 reducer 都只在 prior?.status === 'running' || options.source === 'live' 时才授予 'running'——此时 prior 已是 'unknown',两个析取项都不成立。同一 PR 中的投影层则以可逆方式在读取时计算同样的降级(project-trajectory-lifecycle.ts 从 live.status 推导,从不修改 store),因此同一个存储为 'running' 的条目在 'stale' 时投影为 'unknown',在 'live' 时投影为 'running'。为本 PR 的意图说句公道话:reducer 的契约是 "a replayed start does not prove a live request"(execution-lifecycle.ts:129),而 trajectory-live-store.test.ts 也刻意固定了重连窗口内的降级行为,所以那部分是设计决定而非缺陷。但该原则针对的是从未实时见过的 start;这个判断同时覆盖的第三种状态却没有任何理由支持——即丢弃客户端已实时观察到的存活事实,并在 store 报告 'live' 之后拒绝重新接受它。两点范围说明:错误窗口从降级持续到该执行结束('ended' 帧仍会解析出终态,因此不是永久的);可观察面很窄——该条目只以 JSON.stringify 转储的形式到达 TrajectoryInspector.tsx:107,所以代价是请求检查器 Summary 页里显示 "status": "unknown" 而非 "status": "running",没有任何行标记、筛选器或色调依赖它。
证据(针对真实的 createTrajectoryLiveStore 与真实的 projectTrajectoryLifecycle 探针运行):
{"observedLive":["running"],
"afterInvalidate":["unknown"], <- invalidate(owner,'stream_closed')
"afterReconnect":["unknown"], <- reconnect(owner)
"backToLiveStatus":"live", <- replay_complete 恢复了 'live'
"afterRedelivery":["unknown"], <- 重新投递同一个实时 'started' 帧
"projectedNotLive":["unknown"], "projectedLive":["running"]} <- 投影层是可逆的
建议修复:区分"条目已终态"与"条目被降级为 unknown",使真正的实时重投递能够重新提升——在 applyLifecycleUnchecked 中,当传入 source 为 live 且已有条目状态为 'unknown' 时传 source: 'live'(而不是对所有已知 key 一律强制 'replay');或者在 unknownRunning 中记录一个 downgradedFrom 标记,让后续的 live 帧清除它。
修复必须遵守的前提:强制 'replay' 的覆盖不能简单删除,否则一个重复的 live 'started' 帧会通过 reducer 的 source === 'live' 析取项把终态 'success' 覆盖回 'running'。trajectory-live-store.test.ts 同时固定了两个方向——'keeps replay %s starts unknown and only new live starts running' 与 'preserves %s terminal evidence across duplicates and reconnect'(断言 reconnect() 之后立即为 ['success','unknown'])——因此修复必须保持终态仍为终态。该重新提升变体尚未经测试验证。
验收标准:在 trajectory-live-store.test.ts 中新增用例——先种入一个 live 的 'running' 条目,调用 invalidate(owner,'stream_closed')、reconnect(owner),摄入 replay_complete,再重新投递同一个实时 'started' 帧,断言该条目重新变为 'running';去掉重新提升逻辑后该断言必须变红。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Keeping the conservative behavior. replay_complete establishes replay delivery completion, not current execution liveness; a repeated started record does not prove that work survived a disconnect. Added request/tool regressions showing unknown survives a duplicate start and terminal evidence settles it. Promoting old starts would recreate false running state. Leaving this semantic disagreement open for reviewer/maintainer confirmation.
| }); | ||
| await flushPromises(); | ||
| }); | ||
| expect(snapshot?.status).not.toBe('live'); |
There was a problem hiding this comment.
[Suggestion] R1-12: Mutation and coverage instrumentation over the unmodified tree found twelve sites where the production logic this PR adds can be deleted, or a clause simplified, and the entire suite stays green — including the test at this anchor, whose name claims to pin the retention behaviour this PR was written to fix. Every site below was established by mutating an isolated copy of the PR commit and running the affected suites, with a control mutation proving the harness does detect changes nearby, so these are holes in specific tests rather than a weak suite. The sharpest three: (a) this test — the only one pinning trajectory retention across a same-id workspace switch — asserts status not.toBe('live') and !tools.entries.some(running), and both hold on an empty store (clear() publishes emptySnapshot() whose status is 'unavailable' and whose tools.entries is empty), so replacing the teardown invalidate at DaemonSessionProvider.tsx:4588 with clear() leaves the full web-shell suite byte-identical to baseline while every same-session workspace switch blanks the panel for the whole load window; (b) trajectory-live-store.test.ts:120 — the only epoch-less case never passes an epoch to ingest, so neither leg that makes an epoch-less seed recoverable is witnessed, and removing snapshot.epoch !== undefined && at trajectory-live-store.ts:189 leaves 11305 tests green while converting the cursor-less-attach path reported separately on this review into a permanently frozen store; (c) session-control-plane.ts:8036 — the toolLifecycle half of the new supplement has zero producer coverage (its spread's true arm executed 0 times against 1030 for the executionLifecycle arm), mirrored on the consumer side where the provider fixture emits toolLifecycle exclusively (EXEC=0 TOOL=12 against a control arm's EXEC=276 TOOL=268), so the two halves are never exercised together on any path — and the request half is the user-visible one, since byRowKey can only ever hold execution entries.
Witness (all arms ran in isolated /tmp copies of commit 642acc33b5; the shared review worktree was never edited):
(a) m-fb1a invalidate(:4588) -> clear() web-shell 25 failed | 11280 passed = byte-identical to baseline
m-fb1b line deleted provider file 1 passed
m-fb1ctl (:4784 reason flattened) provider file FAILS both heartbeat auth tests <- control
(b) MUT1 remove `snapshot.epoch !== undefined &&` (:189) 426 files / 11305 tests / EXIT=0
MUT2 `(epoch ?? snapshot.epoch)` -> `snapshot.epoch` 11305 passed / EXIT=0
CTL remove `epoch !== snapshot.epoch` (:190) 2 failed | 17 passed (19) <- control
CTL remove `epoch !== undefined &&` (:188) 15 failed | 4 passed (19) <- control
(c) v8 coverage, acp-bridge 56 files / 2651 tests: L8050 `? { toolLifecycle: ... }` count=0;
branch 8049:54-8050:64 true arm =[0]; control L8047 `? { executionLifecycle: ... }` count=1030
(f) MUTANT delete skill-details-redaction.ts:82-88 4 files / 1415 tests passed
CONTROL delete workflow-session-gate.ts:77-83 3 tests FAIL (2 standalone + 1 load-response)
(g) m-fb3 delete scope arg at App.tsx:5952 App.test.tsx 2 files passed, suite harness-only
m-fb3ctl identical deletion at App.tsx:6903 FAILS 'isolates trajectory recovery...': expected 8, got 12
(h) v8 coverage App.test.tsx (1144 tests): :6600 count=18, :6601 count=8, :6602 count=8, :6603 count=5
-> the 8->8 step across `trajectoryAvailable` proves it short-circuited zero times
(i) instrumented invalidate: provider OVERRIDE=131 BLOCKED=316; all 131 overrides transient->transient,
permanent `next` reasons: zero. m-fb5 guard simplified -> harness-only; m-fb5ctl deleted -> FAILS
(e) v8 br#1953 L8027 counts=[1], loop L8026 count=1182; m-fb2 both lines deleted -> 2651/2651 green
(j) m-fb4 drop `|| event.type === 'stream_error'` -> 19/19 passed; m-fb4ctl drop `session_died` -> FAILS
(k) MUTANT drop `candidate !== owner ||` from reconnect -> 19/19 and 822/822 passed;
CONTROLS drop the same guard from ingest -> 2 failed, from invalidate -> 1 failed
(l) grep sweep: `lifecycle` in components/artifacts/*.test.tsx -> 0 matches; no test renders
TrajectoryPanel or TrajectoryInspector under a populated TrajectoryLiveContext
Suggested fix — pin each site with the test its own control mutation proves the harness can see:
DaemonSessionProvider.test.tsx:826(this anchor) — assert the retained shape instead of a negative:expect(snapshot).toMatchObject({ status: 'stale' })plus the seeded entry surviving as'unknown'. The App-level test does not cover this site:App.test.tsx:1123mocksDaemonSessionProviderwith a stub that just renderschildren, so the real store never runs there.trajectory-live-store.test.ts:120— add a case that ingests with anepochargument and asserts adoption ({status:'catching-up', epoch:'b'}) then promotion to'live'.session-control-plane.ts:8036— add a producer case feeding atoolLifecycleframe and assert it reacheslifecycleReplay.DaemonSessionProvider.test.tsx:607— parameterize the fixture overkind: 'tool' | 'request'and assertsnapshot.requests.entriesalongsidesnapshot.tools.entries, including one duplicated execution frame spanning the persisted page and the supplement.session-control-plane.ts:8026— oneexpect(refreshed.lifecycleReplayIncomplete).toBe(true)inbridge.test.ts:8181, the test that already executes that line (it currently asserts onlycompactedReplay).skill-details-redaction.ts:82— add alifecycleReplaycase to the existingdescribe('omitSkillDetailsFromReplayArrays'); the fixtures are already there.App.tsx:5947— add a retention pass after the button click in the'opens one trajectory tab from the panel and reuses it'case.App.tsx:6600— add a case that withdraws thetrajectorypanel item and then enters a transient state.trajectory-live-store.test.ts:108— addinvalidate('stream_closed')theninvalidate('auth_failure')thenreconnectthenreplay_complete, asserting the permanent reason survives.trajectory-live-store.test.ts:88— drive a realstream_errorevent throughingest, mirroring thesession_closed/session_diedcase at:135.trajectory-live-store.ts:175— add a foreign-ownerreconnectcase asserting snapshot identity, seeded with a live or transient-stale snapshot.TrajectoryPanel.tsx:1662— render the panel under a populatedTrajectoryLiveContextand assert the inspector's 'Recorded details' value; the label is not a unique selector (TrajectoryInspector.tsx:165renders the same label for tool blocks), and a fixture needsexecutionIdplus a loader built throughcreateTrajectoryPageLoaderorbyRowKeyis always empty and the test passes for the wrong reason.
One premise the fixes must respect, quoted from the tests that already exist: trajectory-live-store.test.ts:251-269 pins {status:'stale', reason:'epoch_reset', epoch:'b', lastEventId: undefined} for a defined-to-different-defined epoch change, so an epoch-less recovery case must not weaken that latch; skill-details-redaction.test.ts:155-161 pins expect(omitSkillDetailsFromReplayArrays(session)).toBe(session) and server.test.ts:17643-17649 pins immutable reshaping, so a redaction test must not invite an always-rebuild or mutating fix; and App.test.tsx:11588 resets mockConnection.sessionContext = undefined in beforeEach, where sessionContextKey(undefined) returns 'legacy' (session-context.ts:122-127) — a button-site retention test does not need a workspace context (the mutated site keys [sessionId, null] against retention's [sessionId, 'legacy'], already a mismatch) but it does need a retention pass after the click.
Acceptance criterion: each named control mutation is the criterion for its own site — the control already reddens, so the new test must reddish for the mutant that currently survives. For this anchor that is m-fb1a; for trajectory-live-store.test.ts:120 it is MUT1 and MUT2; for session-control-plane.ts:8036 it is the toolLifecycle disjunct and the spread at :8049.
中文说明
在未修改的代码树上做变更测试与覆盖率插桩,发现了十二处:删除本 PR 新增的生产逻辑、或简化其中某个子句之后,整个测试套件仍然全绿——其中包括本锚点处的这个测试,而它的名字声称固定了本 PR 为修复而写的保留行为。下面每一处都是通过在 PR 提交的隔离副本中做变更后运行相关套件确立的,并且都配有一个对照变更来证明测试框架确实能检测到附近的改动,因此这些是具体测试中的漏洞,而不是套件本身太弱。最关键的三处:(a) 本测试——唯一固定"同 id 工作区切换时轨迹保留"的测试——断言 status not.toBe('live') 与 !tools.entries.some(running),而这两条在空 store 上都成立(clear() 发布的 emptySnapshot() 其 status 为 'unavailable',tools.entries 为空),因此把 DaemonSessionProvider.tsx:4588 处拆卸时的 invalidate 换成 clear(),整个 web-shell 套件的失败集合与基线逐字节相同,而实际上每次同会话工作区切换都会在整个加载窗口内让面板空白;(b) trajectory-live-store.test.ts:120——唯一的无 epoch 用例从不向 ingest 传 epoch 参数,因此让无 epoch 种子可恢复的两条逻辑腿都没有被见证,而去掉 trajectory-live-store.ts:189 的 snapshot.epoch !== undefined && 之后 11305 个测试仍全绿,同时把本次评审另行报告的"无游标 attach"路径变成一个永久冻结的 store;(c) session-control-plane.ts:8036——新补充数据的 toolLifecycle 那一半在生产端覆盖率为零(其展开表达式的真分支执行 0 次,而 executionLifecycle 分支为 1030 次),消费端也对称地如此:provider 的测试夹具只发 toolLifecycle(EXEC=0 TOOL=12,而对照臂为 EXEC=276 TOOL=268),所以两半在任何路径上都从未被同时验证——而 request 那一半才是用户可见的一半,因为 byRowKey 只可能持有 execution 条目。
证据(所有分支都在提交 642acc33b5 的隔离 /tmp 副本中运行;共享的评审工作树从未被修改):
(a) m-fb1a invalidate(:4588) -> clear() web-shell 25 failed | 11280 passed = 与基线逐字节相同
m-fb1b 整行删除 provider 文件 1 passed
m-fb1ctl(:4784 原因被压平) provider 文件 两个心跳鉴权测试均 FAIL <- 对照
(b) MUT1 去掉 `snapshot.epoch !== undefined &&`(:189) 426 files / 11305 tests / EXIT=0
MUT2 `(epoch ?? snapshot.epoch)` -> `snapshot.epoch` 11305 passed / EXIT=0
CTL 去掉 `epoch !== snapshot.epoch`(:190) 2 failed | 17 passed (19) <- 对照
CTL 去掉 `epoch !== undefined &&`(:188) 15 failed | 4 passed (19) <- 对照
(c) v8 覆盖率,acp-bridge 56 files / 2651 tests:L8050 `? { toolLifecycle: ... }` count=0;
分支 8049:54-8050:64 真分支 =[0];对照 L8047 `? { executionLifecycle: ... }` count=1030
(f) 变更:删除 skill-details-redaction.ts:82-88 4 files / 1415 tests passed
对照:删除 workflow-session-gate.ts:77-83 3 个测试 FAIL(2 个 standalone + 1 个 load-response)
(g) m-fb3 删除 App.tsx:5952 的 scope 参数 App.test.tsx 2 files passed,全套件仅剩环境问题
m-fb3ctl 在 App.tsx:6903 做完全相同的删除 FAILS 'isolates trajectory recovery...':期望 8 次,实际 12 次
(h) v8 覆盖率 App.test.tsx(1144 tests)::6600 count=18、:6601 count=8、:6602 count=8、:6603 count=5
-> `trajectoryAvailable` 处 8->8 的台阶证明它一次都没有发生短路
(i) 对 invalidate 插桩:provider OVERRIDE=131 BLOCKED=316;131 次覆盖全部是 transient->transient,
永久原因作为 `next` 出现:0 次。m-fb5 简化守卫 -> 仅剩环境问题;m-fb5ctl 删除守卫 -> FAILS
(e) v8 br#1953 L8027 counts=[1],循环 L8026 count=1182;m-fb2 删除两行 -> 2651/2651 全绿
(j) m-fb4 去掉 `|| event.type === 'stream_error'` -> 19/19 passed;m-fb4ctl 改去 `session_died` -> FAILS
(k) 变更:从 reconnect 去掉 `candidate !== owner ||` -> 19/19 与 822/822 passed;
对照:从 ingest 去掉同一守卫 -> 2 failed;从 invalidate 去掉 -> 1 failed
(l) grep 扫描:components/artifacts/*.test.tsx 中 `lifecycle` -> 0 匹配;没有任何测试在已填充的
TrajectoryLiveContext 下渲染 TrajectoryPanel 或 TrajectoryInspector
建议修复——为每一处补上其对照变更已证明框架能看见的那个测试:
DaemonSessionProvider.test.tsx:826(本锚点)——断言保留后的形态而不是一个否定式:expect(snapshot).toMatchObject({ status: 'stale' }),加上种入的条目以'unknown'存活。App 层测试并不覆盖此处:App.test.tsx:1123把DaemonSessionProvidermock 成一个只渲染children的桩,因此真实 store 在那里从不运行。trajectory-live-store.test.ts:120——新增一个带epoch参数摄入的用例,断言先被采纳({status:'catching-up', epoch:'b'})随后提升为'live'。session-control-plane.ts:8036——新增一个生产端用例,喂入一个toolLifecycle帧并断言它进入了lifecycleReplay。DaemonSessionProvider.test.tsx:607——把夹具按kind: 'tool' | 'request'参数化,并在断言snapshot.tools.entries的同时断言snapshot.requests.entries,其中包含一个横跨持久化页与补充数据的重复 execution 帧。session-control-plane.ts:8026——在bridge.test.ts:8181(即已经执行到该行的那个测试,目前只断言compactedReplay)中加一句expect(refreshed.lifecycleReplayIncomplete).toBe(true)。skill-details-redaction.ts:82——在现有的describe('omitSkillDetailsFromReplayArrays')中增加一个lifecycleReplay用例;夹具已经具备。App.tsx:5947——在'opens one trajectory tab from the panel and reuses it'用例中,于点击按钮之后补一次保留流程。App.tsx:6600——新增一个先撤下trajectory面板项、再进入瞬时状态的用例。trajectory-live-store.test.ts:108——新增invalidate('stream_closed')、再invalidate('auth_failure')、再reconnect、再replay_complete,断言永久原因得以保留。trajectory-live-store.test.ts:88——让一个真实的stream_error事件经过ingest,与:135处的session_closed/session_died用例对称。trajectory-live-store.ts:175——新增一个外来 owner 调用reconnect的用例,断言 snapshot 引用不变,且需以live 或瞬时 stale 的 snapshot 作为起点。TrajectoryPanel.tsx:1662——在已填充的TrajectoryLiveContext下渲染面板,并断言检查器 'Recorded details' 的取值;该标签不是唯一选择器(TrajectoryInspector.tsx:165对 tool 块渲染同一标签),且夹具需要带executionId并通过createTrajectoryPageLoader构造 loader,否则byRowKey恒为空、测试会因错误的原因通过。
修复需要遵守的前提,均引自现有测试:trajectory-live-store.test.ts:251-269 固定了"已定义 epoch 变为另一个不同的已定义 epoch"时得到 {status:'stale', reason:'epoch_reset', epoch:'b', lastEventId: undefined},因此无 epoch 恢复用例不得削弱该闩锁;skill-details-redaction.test.ts:155-161 固定了 expect(omitSkillDetailsFromReplayArrays(session)).toBe(session),server.test.ts:17643-17649 固定了不可变重塑,因此脱敏测试不得诱导出"总是重建"或"修改入参"的修法;App.test.tsx:11588 在 beforeEach 中把 mockConnection.sessionContext = undefined 重置,而 sessionContextKey(undefined) 返回 'legacy'(session-context.ts:122-127)——按钮站点的保留测试不需要工作区 context(被变更的站点以 [sessionId, null] 为键,而保留逻辑以 [sessionId, 'legacy'] 为键,本就不匹配),但确实需要在点击之后走一次保留流程。
验收标准:每一处点名的对照变更就是该站点自身的标准——对照已经会变红,因此新增测试必须让当前能存活的那个变更体变红。就本锚点而言是 m-fb1a;就 trajectory-live-store.test.ts:120 而言是 MUT1 与 MUT2;就 session-control-plane.ts:8036 而言是 toolLifecycle 析取项与 :8049 处的展开。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Added the requested targeted assertions in 9f388aeb43: retained unknown entry during workspace recovery; epoch adoption; tool supplement producer; request/tool Provider consumers plus page/supplement duplicates; incomplete marker; immutable supplement redaction; button-opened tab retention and host opt-out; transient-to-permanent invalidation; stream_error ingestion; foreign reconnect; and actual request lifecycle values in Recorded details. The affected suites pass. Several behavior regressions were checked fail-before, but the entire mutation matrix in this comment was not rerun, so I am leaving this thread open rather than claiming full mutation acceptance.
|
Addressed the review at
Validation on this revision: repository build, bundle and typecheck passed; Web Shell 2,105 tests, bridge 1,001 tests and CLI/documentation contracts 23 tests passed; ESLint, Prettier and diff checks passed. The transcript bundle budget passed unchanged. Several regressions were verified failing before the corresponding fix. This is deterministic local verification, not a new real daemon/browser E2E run. Hosted CI for this pushed revision is reported separately. Update: hosted Lint & Static on |
yiliang114
left a comment
There was a problem hiding this comment.
Approving at 456d0984.
Note on the red light: the only CHANGES_REQUESTED on this PR (review 5487929747) is pinned to c39ad80c. Its blocker — the transcript-entry bundle budget — is resolved at the current head: Test (ubuntu-latest, Node 22.x) and Lint & Static are both green on 456d0984. The delta 9f388aeb…456d0984 is a merge of main only, so the R1 fix round is what is being approved.
What I verified at this head:
- The R1 fixes claimed in
9f388aebare present: text frames advance the cursor without publishing, cursorless promotion waits for an epoch, the owner guard rejects foreign begin/reconnect/invalidate, and the keep-session cleanup invalidates exactly once. - Supplement confinement: the bridge re-wraps only
_meta.executionLifecycle/_meta.toolLifecycleintolifecycleReplay, and both redaction paths (skill details, workflow gate) now thread the new array. - Join safety: a lifecycle frame stamped with another sessionId (e.g. from a forked transcript) can never join a row — the projection keys on the loader's sessionId + scope, so cross-stamped frames fail closed.
- The terminal-wins, transient-vs-permanent invalidation, and epoch/ring-eviction semantics match what the new store and provider tests pin down.
Already on the record and non-blocking: R1-2 (bounded snapshot scan) is deferred to PR7, and the unread projection fields (byExecution, outsideWindow) are declared scaffolding for the live-bars follow-up. I left one new P3 inline about the gap notice also firing on the plain artifactsLoading path.
CI: everything required is green at 456d0984; web-shell E2E Smoke, Hosted process fault gates, and Capture web-shell visuals were still running when I submitted this — pending checks, not a finding.
| setArtifactPanelOpen(shouldOpen); | ||
| setArtifactPanelTabs([]); | ||
| setActiveArtifactPanelTabId(null); | ||
| retainCurrentTrajectory(); |
There was a problem hiding this comment.
[P3 · non-blocking] retainCurrentTrajectory() also runs on the plain artifactsLoading branch, so an artifact-list reload with no transcript gap still bumps historyGapRevision and shows “History may have changed while disconnected” until a manual refresh. Might be worth bumping the revision only in the loadingTranscript / status !== 'connected' branches, or keying the notice off an actual stream-gap signal from the live store.
qwen-code-dev-bot
left a comment
There was a problem hiding this comment.
Approved at head 456d098, after completing a full read of the production surface.
This supersedes my earlier pass on this PR, which declined to sign on capacity grounds after reading only the two redaction sites. That was an honest boundary at the time and it is no longer the state of my knowledge: I have now read every production hunk in this diff, all eighteen files, plus the new live-store module in full and the provider store call sites and teardown in context. What follows is what I verified, and the coverage statement at the end says what I still did not do.
Gate 1. Head SHA fixed as above and every conclusion targets that SHA only.
Gate 2. Thirteen review threads, nine resolved and four open, and I read all four open ones in full rather than counting them. None is a Critical and each carries a disposition from its own author.
Two are the round-2 Suggestions the author deliberately left open. The paged-restore supplement is built from an unconditional full snapshot, which costs duplicate frames and a flatten on the reopen path; the author confirmed it as a bounded performance improvement, deferred it to the follow-up, documented the overlap and added idempotent replay tests. The store-level running-to-unknown downgrade is one-way; the author kept the conservative behaviour on the stated ground that a replay-complete signal establishes delivery and not current liveness, added regressions showing an unknown entry survives a duplicate start and that terminal evidence settles it, and left the semantic disagreement open for a maintainer. The maintainer who approved this head did not answer that thread explicitly, so I record it as implicitly ratified rather than settled, and I do not adopt it as a blocker: the wrong window is bounded by the ended frame, the observable surface is a single inspector field, and the projection layer computes the same downgrade reversibly, so the two layers disagree in a direction that is conservative rather than lossy.
The third is the mutation-coverage report, which found twelve sites where added production logic could be deleted or simplified with the whole suite still green, each established against an isolated copy with a control mutation proving the harness detects nearby changes. The author added eleven targeted assertions in response, covering the retained unknown entry across workspace recovery, epoch adoption, the tool supplement producer, the request and tool provider consumers with page and supplement duplicates, the incomplete marker, immutable supplement redaction, button-opened tab retention with host opt-out, transient-to-permanent invalidation, stream-error ingestion, foreign reconnect, and real request lifecycle values in the recorded details. The author states plainly that several were checked fail-before but the full mutation matrix was not re-run, and left the thread open rather than claiming acceptance. That is the right way to leave it, and it is a verification-completeness gap rather than a known defect.
The fourth is a P3 marked non-blocking by its own author, who approved one second later: the retention helper also runs on the plain artifacts-loading branch, so an artifact-list reload with no transcript gap still bumps the gap revision and shows the disconnected notice until a manual refresh. Real, small, and correctly labelled.
There is no Critical anywhere in this record and no necessary Suggestion outstanding.
Gate 3. Twenty-three substantive groups at this head, all settled green, nothing pending, cancelled or failing, read over full pagination. Skipped lanes are counted as settled, which is how I read this repository throughout, and I disclose that this is a judgement. The round-2 review noted that the CLI integration lane, where the renderer matrix lives, was skipped and that its author did not run it locally; the real-renderer verification anchored to this head by another reviewer covers that dimension, and I did not execute it myself.
Gate 4. No new Critical. I read the whole production surface and checked the mechanisms that would silently defeat this change if they were wrong.
The loader identity comparison is sound, and this was the first thing I tried to break. The retention helper filters open tabs by comparing a stored loader against a freshly constructed one with the strict equality operator, which would be permanently false and make the whole helper dead code if the factory returned a new closure per call. It does not: the factory is memoized through a WeakMap from client to a map keyed by the session id and scope serialized together, and returns the existing loader for that key. So the comparison is a real identity check. The same change is what makes it safe, because the cache key previously carried only the session id; adding the scope means one session under two workspace scopes yields two distinct loaders, so retention cannot carry a trajectory across a scope change. A second WeakMap records the session and scope each loader was built with, which is how the windowing hook later obtains an identity to match against the live store.
Cross-loader staleness is closed at the render boundary rather than only in an effect. The hook now tracks which loader its loaded pages belong to and returns an empty window state whenever that owner differs from the current loader, so there is no frame in which the previous session or scope can render its pages, its cursors, its navigation flags or its error state. Every returned field reads from that gated state rather than from the raw one, and I checked each of the fourteen rather than assuming the rename was applied uniformly.
Live data cannot bleed into the wrong panel. The projection only merges the live snapshot when the loader identity has a defined scope and both the session id and the scope match the store, and when they do not match it reports the status as unavailable and forces the incomplete flag true. Forcing incomplete rather than defaulting it false is the right direction: an unattributable live view is declared partial instead of being presented as whole.
Terminal evidence wins at two layers, not one. The projection skips a live entry when the historical entry for the same key has already ended, which is independent of the reducer contract that a replayed start does not prove a live request. Entry keys include the kind, the session, the subagent and the execution id, so a request and a tool entry for one execution cannot collide, and the historical projection uses the same composite key the store uses for its eviction accounting.
The accounting flags reach the user rather than dying in a data structure. Both new banner strings are rendered in the two places the panel shows status text, in both languages, and they are driven by the incomplete and truncated flags the projection returns. The store-side incomplete flag is itself a six-way disjunction that includes the case where a history page size was configured but the server sent no lifecycle supplement at all, so a missing supplement is reported as incomplete rather than silently treated as complete.
The supplement cannot carry content it should not. The control plane builds each supplement event from scratch, copying only the execution and tool lifecycle metadata out of the source frame, so transcript text and command or skill metadata are not present to leak. Both existing redactors were nevertheless widened to cover the new array, in the type bound, the early-return guard and the conditional spread, and the redaction test pins that the output is redacted, that the source event still carries the removed field, and that the array element is the same reference rather than a copy.
The external store contract is respected. The context module keeps a module-level empty snapshot and a stable subscribe fallback, which is what the store hook requires to avoid a new object per call, and it passes the same getter for both the client and server snapshot arguments. The provider store is created once through a memo with an empty dependency list and added to the two dependency arrays that use it, so its stable identity cannot cause those effects to re-run.
One thing I checked because it looked like a defect and is not. The retention helper evaluates the session-identity condition inside the filter callback rather than once outside it, which reads as though it were per-tab when it is constant for the call. It is harmless, since a false constant simply yields an empty retention set, which is the intended result when the session changed.
Non-blocking observations, recorded rather than requested.
Three of the six fields on the lifecycle projection have no reader in this diff. The row-key map and the two accounting flags are consumed; the by-execution map, the outside-window list and the status field are not, and the tool-lifecycle half of the merge is computed on every render without reaching the interface. The round-1 review asked for a deliberate choice here and I have not seen one recorded. If this is scaffolding for the follow-up, saying so in the design document would settle it; if it is not, the merge cost is being paid for nothing.
The gap notice is acknowledged only when a refresh produces a different trajectory reference. A successful refresh that returns the same reference leaves the disconnected notice standing. That is the conservative direction and I would not change it on my say-so, but it is worth knowing.
The compaction change routes an agent message chunk carrying execution lifecycle metadata into the discrete slot, and does not test for tool lifecycle metadata in the same place. If a tool lifecycle frame can ride that update type it would be merged into a text segment instead of staying discrete. I could not establish whether that combination occurs, so this is a question for the author and not a finding.
The cursor-less reconnect passes live-only mode when the session has no last event id, so the first ingested event is applied as a live source. The forced replay override for keys the store already holds covers the common case, and the projection additionally downgrades a running entry to unknown whenever the live status is not live. The residual case would be a key outside the replay window re-delivered on a cursor-less connection, and I could not establish from the client side whether the daemon replays history in that situation.
Coverage statement. I read all eighteen production hunks in this diff, the new live-store module in its entirety, the new projection and context modules in their entirety, the loader identity and memoization change, the provider store call sites including the epoch-reset reload path and the teardown cleanup, both collector and redaction sites, and the two new banner strings in both languages. I did not read the roughly nineteen hundred added test lines beyond the specific assertions quoted in the review record, so I can confirm that the production code is correct but I cannot confirm from my own reading that every new assertion bites. I executed nothing, ran no mutation testing, and rendered no component. My confidence about real renderer behaviour rests on the green lanes and on the verification others anchored to this head, not on my own execution.
Gate 5. Head SHA, PR state, checks over full pagination and unresolved thread count were re-read atomically immediately before submitting this review.
|
Released in v0.25.2. |








What this PR does
Connects the trajectory's historical window to bounded request and tool lifecycle state through the existing session subscription. Request details expose recorded lifecycle evidence. Reconnects preserve the historical page, selection, filters, and scroll position.
Paged session loads include a bounded in-memory lifecycle supplement at the same event watermark, so events published before persistence are still available. The SDK retains this metadata separately from chat replay and releases it after consumption. Snapshot gaps, epoch changes, and incomplete history remain explicit.
Why it's needed
A transcript file cursor cannot resume the live event stream. Loading a persisted page and subscribing from a bus watermark could miss a lifecycle event that had not reached disk. Replayed starts also cannot prove that an execution is still running. This supplies the continuity contract needed before adding live trajectory rendering and following.
Reviewer Test Plan
How to verify
Local validation: build, bundle, full workspace typecheck, changed-file ESLint/Prettier, and 1,970 relevant tests passed (Web Shell 821, bridge 999, SDK 93, CLI redaction/Standalone 43, replay routes 5, App/artifact trajectory 9). These are targeted suites, not the entire repository test suite. Pre-commit formatting/lint passed and committed sources match the verification manifest.
Evidence (Before & After)
Controlled Chromium fixture, 1440×1000, using the real trajectory components and synthetic lifecycle data. These screenshots show the same implementation before and after reconnect, not a main-versus-branch visual comparison. The fixture omits the full App theme, so it is functional evidence rather than final visual acceptance.
The historical four-page window,
qwenfilter, selected request #7, scroll offset 518, and history calls[0,1,2,3,4,5,6,7]stayed unchanged. The inspector displays the associated lifecycle evidence.Real local daemon + controlled provider + SDK/source state tests passed snapshot-to-subscription replay, short disconnect, epoch mismatch, actual daemon restart detection, and ring eviction. A deterministic bridge test covers the unpublished-to-disk window; it is not real filesystem delay injection. A separate comment contains the E2E coverage and limits.
Tested on
Environment (optional)
Isolated local daemon configuration and runtime directories, loopback controlled model provider, and Chromium. No external model calls were needed for these E2E checks.
Risk & Scope
Linked Issues
Trajectory PR6C, following #13836.
中文说明
本 PR 的改动
通过现有会话订阅,将轨迹历史窗口接到有界的请求和工具生命周期状态。请求详情可查看已记录的生命周期证据。重连保持历史页、选择、筛选和滚动位置。
分页加载在同一事件水位下补带有界内存生命周期,保证已发布但尚未落盘的事件仍可获取。SDK 将这部分元数据与聊天回放分开保留,并在消费后释放。快照缺口、epoch 变化和历史不完整都有明确状态。
为什么需要
文件轨迹游标不能用于续订实时事件。读取持久化页后从总线水位订阅,可能遗漏尚未落盘的生命周期事件;回放中的开始事件也不能证明执行仍在运行。本 PR 为后续实时轨迹渲染和跟随提供接续契约。
评审验证计划
如何验证
本地 build、bundle、全仓 typecheck、修改文件 ESLint/Prettier 和 1,970 项相关测试通过:Web Shell 821、bridge 999、SDK 93、CLI 脱敏/Standalone 43、replay 路由 5、App/artifact 轨迹 9。它们是相关测试集,不是全仓全部测试。提交钩子的格式和 lint 通过,提交源码与验证清单一致。
前后证据
上表为 Chromium 1440×1000 受控 fixture,使用真实轨迹组件和合成生命周期。截图展示同一实现重连前后,不是主干与分支的视觉对比。fixture 没有完整 App 主题,因此仅作为功能证据。
历史四页窗口、
qwen筛选、选中请求 #7、滚动位置 518 和分页调用[0,1,2,3,4,5,6,7]均保持不变。检查器显示对应生命周期。真实本地 daemon、受控 provider、SDK/源码状态测试通过快照到订阅补发、短断线、epoch mismatch、实际 daemon 重启检测和 ring 淘汰。尚未落盘窗口由确定性 bridge 单测覆盖,不等同真实文件系统延迟注入。独立评论列出 E2E 范围与限制。
测试平台与环境
macOS(Node 24.14.1、本地 daemon、Chromium fixture)已测试;Windows、Linux 未本地测试。使用隔离的本地配置/运行目录及 loopback 受控模型服务;E2E 不需要外部模型调用。
风险与范围
关联
轨迹 PR6C,承接 #13836。