feat(record): 导出带 settled 页面状态的 Trace v3 bundle - #107
Open
shnpd wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR upgrades the recording pipeline from exporting a single trace.json to exporting a Trace v3 bundle directory (trace/trace.json + trace/states/sN.txt), with the extension producing v3 traces that include settled page observations and the CLI writing them atomically. It also preserves compatibility by falling back to legacy v2 output when talking to older extensions.
Changes:
- Extension: negotiate
trace_version, record v3 traces with settled pre/post-action states, and stabilize navigation/action ordering (redirect coalescing + stop draining). - CLI: export v3 as a bundle directory with locking + staging + rollback; keep v2 fallback as a single JSON output.
- Docs/UI: update SKILL docs and extension i18n/popup guidance to reference the bundle layout.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| skill/SKILL.md | Updates recording docs to describe v3 bundle output + v2 fallback semantics. |
| crates/bsk-cli/skill/SKILL.md | Mirrors SKILL documentation updates within the CLI crate. |
| packages/i18n/src/locales/zh-CN/extension.json | Updates CN popup copy to reference the ./trace bundle output. |
| packages/i18n/src/locales/en-US/extension.json | Updates EN popup copy to reference the ./trace bundle output. |
| crates/bsk-protocol/src/tools/record.rs | Adjusts on-disk naming/semantics from pages/ to states/ and updates tests. |
| crates/bsk-cli/src/cli/record.rs | Implements bundle export (v3) + atomic directory writing and v2 fallback export behavior. |
| crates/bsk-cli/tests/record_stop_retry.rs | Adds CLI integration test for retryable record stop and bundle export verification. |
| apps/extension/src/tools/record.ts | Adds v3 negotiation, settled observation capture, redirect coalescing, and stop/drain stability logic. |
| apps/extension/src/tools/tests/record-steps.test.ts | Adds comprehensive tests covering ordering, redirects, stop race/drain, v2 fallback, etc. |
| apps/extension/src/lib/trace-reducer-v2.ts | Drops hover in v2 output to avoid breaking legacy v2 readers. |
| apps/extension/src/lib/recording-step-buffer.ts | Enhances step buffering (navigation cause mapping, redirect coalesce signaling, safer indexing). |
| apps/extension/src/lib/record-observation.ts | Improves target matching fallback and redirect landing handling during coalescing. |
| apps/extension/src/lib/record-bridge.ts | Expands step payload schema (geometry, commit, scroll, transition metadata). |
| apps/extension/src/lib/match-target.ts | Adds semantic target matching fallback when geometry is unavailable. |
| apps/extension/src/lib/tests/trace-reducer-v2.test.ts | Updates expectations for hover dropping behavior in v2. |
| apps/extension/src/lib/tests/recording-step-buffer.test.ts | Adds tests for capture fallback retention and redirect coalesce behavior. |
| apps/extension/src/lib/tests/match-target.test.ts | Adds tests for semantic fallback matching behavior. |
| apps/extension/src/entrypoints/popup/App.test.tsx | Updates popup test assertions to expect bundle-based instructions. |
| apps/extension/src/entrypoints/background.ts | Wires the CDP runner into recording listeners. |
| apps/extension/src/content/record-capture.ts | Adds geometry + commit metadata and improves stop flushing/retry behavior for step delivery. |
| apps/extension/src/content/tests/record-capture.test.ts | Adds tests covering stop retry behavior and geometry capture. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
shnpd
force-pushed
the
feat/trace-v3-recorder
branch
from
August 18, 2026 07:36
a7c0737 to
3c6a67f
Compare
shnpd
requested review from
Ljy-0827 and
iuyo5678
and
a lite review from Copilot
August 18, 2026 08:50
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.
一句话总结
把录制结果从「单个
trace.json」升级为完整的 Trace v3 bundle:trace/trace.json+trace/states/sN.txt背景
feat/record-settled-states已经具备「页面 settle 后再捕获状态」的能力。本 PR 在此基础上把录制链路补齐为可交付产物,让 Agent 能直接消费录制结果:
steps)states)主要改动
1. 扩展侧:真正产出 Trace v3
核心文件:
apps/extension/src/tools/record.tsrecord start支持协商trace_versionstate:动作前页面状态result.state:动作 settle 后页面状态bsk observe相同的 VOM 格式pages[] + stepshover2. 导航与动作时序更稳
这里不是新功能,而是修「谁先谁后、绑到哪一页」的竞态问题。
以前容易录乱的典型场景:
login → callback → dashboardclick与webNavigation几乎同时到达本 PR 的处理方式:
navigate,后续 click 绑定落地页,而不是中间 hoprecord stop并发时,共享同一次结束结果(成功/失败都一致回传)3. CLI:导出目录包,而不是单文件
核心文件:
crates/bsk-cli/src/cli/record.rs推荐产物变为:
关键行为:
--output默认改为目录tracetrace.json只保留 state 索引;正文落到states/sN.txttrace.json,不生成states/--max-page-tokens、--redact-valuessN.txt,不误删用户自有文件record stop若为可重试失败,会保留 recording session,允许再次 stop4. 协议 / 文档 / i18n 对齐
pages/调整为states/,文件名约定为sN.txt./trace目录包(trace.json+states/)对用户可见的变化
之前:
现在(推荐):
语义:
steps[].state:动作发生前的页面观察steps[].result.state:动作 settle 后的页面观察states/sN.txt:对应 settled page observation 的正文若连接的是旧扩展,CLI 仍可导出 v2 单文件,但不会有完整
states/。测试覆盖
扩展侧新增
record-steps.test.ts,覆盖:trace_versionCLI 新增
record_stop_retry.rs,覆盖:trace.json+states/s1.txt建议 Review 重点