Repository navigation
[PR] feat(web): Add Context Trace view to conversation detail page (#3201) | [PR] feat(web): 会话详情页新增「上下文轨迹」视图(#3201) - #3337
ranxianglei wants to merge 11 commits into
Conversation
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 全仓检索「trajectory / 轨迹」相关 issue 与 PR(open+closed)后确认:本 PR 是 #3201 的唯一在途实现;#2489/#2492(已关闭)是既有 token 曲线图的 zoom-brush 功能,与本 PR 的「上下文轨迹」视图无重叠。 审核进行中,初步观察:
接下来按规范做完整 review(原 issue 方向、回归清点、代码审查、测试有效性、diff 整洁度),完成后按八问体例给结论。 |
eff0223 to
6efc7a3
Compare
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4791-pr.3337.8f52ce5This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3337.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 进度:分支已 rebase 到当前 master 并推送,CI 跑完后给八问结论。
等 CI check runs 出结果后按八问体例给最终结论。 |
8e6a9be to
c3e26c1
Compare
(ai: vllm-qwen/qwen3.8-27b) 审核结论 — PR #3337「上下文轨迹」视图1. 是什么问题 2. 什么原因导致的
3. 影响范围与严重程度 4. 怎么修复的 5. 是否有回归问题 6. 是否破坏缓存 7. 是否改了设计方向 8. 是否引入了新的配置 非阻塞观察(留档,不在本 PR 处理)
判定:建议合并。 head 0a60339 CI 全绿、mergeable=True(blocked 仅为 review 条件)、4 处缺陷已在源头修复并有测试钉住、行为变更全部如实披露。合并动作请人工执行:#3337 |
0a60339 to
25150f4
Compare
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 本条是系统转发的上游 PR 冲突唤醒,延续 #3201 的既有工作(前序会话已做过接单查重,floor 4),非新缺陷。 处理结果:冲突已解,CI 全绿,PR 可合并。 做了什么:
结构化八问
另:按标题国际化规则,把 PR 与镜像 issue 标题都改成了「英文 | 中文原文」形式(正文未动)。 判定:收工 —— 分支干净、CI 全绿,等待人工合并。 |
|
冲突 |
…ed sidecar (#3201) New <stem>.system-surface.json sibling (hash-gated, <=400K chars per field, atomic tmp+rename, 0600) records the exact system text + tool definitions sent to the upstream on the most recent request, captured at the four wire stamp sites alongside the existing systemPromptTokens measurement. Derived artifact: malformed/corrupt sidecars degrade to 'uncaptured' and never block session load; GC co-deletes with the twin-fallback keep rule and joins the orphan sweep.
Rebuilds the last outbound context as a dsh-style record ledger (system prompt & tools, per-message roles/kinds/refs/turns, folded blocks anchored at their span end) from already-persisted state; replaces the handoff document as the default bottom-of-page display (md copy/download buttons kept), renames the token chart title to avoid the name clash, and adds JSON copy of the normalized view.
…#2671) Two proxy-persist assertions assumed legacy-only top-level entries, but with no storage tier configured the unified store defaults to shadow mode (#2671) and legitimately opens index.db/-wal/-shm beside the namespace dirs. Filter those known sidecars; the 'no stray files' intent is unchanged.
The #3201 PR refactored the twin-fallback companion rule into a shared helper but only exercised the content-store class through tests/session-gc.test.ts; the new .system-surface.json co-delete / twin-fallback / orphan-sweep paths had no direct coverage. Add the four mirror tests (stale co-delete, twin still relies, twin owns its own, orphan age gate).
CI unused-exports gate: WebTrajectoryRecord/WebTrajectory are only used inside src/web/sessions-data.ts — make them module-internal per the checker's fix hint.
…ew (#3201) Review fix for this PR. Two defects in the new trajectory code inside the WEB_CLIENT template literal: 1. Single-escaped \" / \n sequences are pre-evaluated by the OUTER template literal into raw quotes / raw newlines in the emitted browser script -> SyntaxError kills the entire /__bili/ page at load (every vm-based web test failed with 'Invalid or unexpected token'). Doubled per the file's existing convention (e.g. join("\\n")). Sites: trajPreview, tool-chips/traj-json/traj-text class attrs, truncated markers. Verified: node --check on the extracted WEB_CLIENT passes end-to-end after the fix. 2. t("kind." + r.kind) defeated the #1024 reference scanner (false 'kind.' ref). Replaced with a KIND_LABEL map carrying explicit literal keys for all 8 kinds.
Review fix for this PR. det.handoff / det.handoff_hint labeled the handoff card header that this PR replaces with the trajectory view; with the header gone the keys are dead and the #1024 dead-key gate fails ('catalog key never referenced anywhere: det.handoff'). Removed from both locales. The handoff md copy/download buttons keep their still-referenced det.handoff_copy_md/_download/_truncated keys.
Review fix for this PR. The trajectory view introduces the first hyphenated
catalog keys (kind.tool-call, kind.tool-result); all five reference-scanner
regexes in collectRefs() use [\w.]+ which cannot match '-', so a referenced key
was reported as dead ('catalog key never referenced anywhere: kind.tool-call').
Extended the class to [\w.-]+ in all five parallel sites. The closing-quote
anchor keeps captures exact - strictly more precise, no over-capture possible.
…rtion (#3201) The PR renamed the token-curve section label det.trajectory from 上下文轨迹/Context trajectory to 上下文曲线/Context curve (declared behavior change #2, disambiguating it from the new trajectory view). The session report renders that heading via t('det.trajectory') (src/web/report.ts:171), so the zh heading assertion here went stale.
…lper (#3201) findRecordFile() asserted exactly one .json file in the sessions dir, but this PR's e2e flow now also writes the derived <stem>.system-surface.json sidecar next to the record (#3201), so the helper saw two files and failed with 'expected exactly one session record, found 2'. Exclude the companion suffixes (.content-store.json / .system-surface.json), matching the pattern already used by tests/persist-guard-ownership.test.ts and friends.
25150f4 to
897506c
Compare
…oc block (#3201) The unused-exports gate counts comment mentions as usage. This PR's rewrite of the session-gc companion handling dropped the old walk/split block whose comment named contentStoreRelPathFor (persist.ts), leaving the export with no reference outside its own file → INTERNAL_ONLY failure on CI. Restored the mention where the new doc block states the sibling scheme; it is also a real invariant: the GC's suffix pairing must stay consistent with contentStoreRelPathFor.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 仍为 #3201 轨迹视图 PR 的冲突处理延续(前两轮已做过接单查重)。 本轮处置:master 又大幅前移(#3818 存储默认 full 模式、batch-B/mysql 整合等 ~50+ 合并),PR 与 10 个文件真实冲突。已 rebase 到最新 master 并解冲突,修掉一个本 PR 触发的门禁红,CI 除 master 侧既有红风暴测试外全绿。新 head 做了什么:
顺带发现并已立项:#4004(带来源标记) —— 本地 Node 上 4 个持久化完整性测试(proxy-persist ×3 + #2129 corrupt-measurement)确定性失败,但同一代码在 GitHub CI 通过。机制已用 store 日志钉死:#3818 默认 full 模式下 结构化八问
行为变更披露:无新增(沿 PR 描述已声明的 4 项不变)。 判定:收工待合 —— 分支干净、可合并(mergeable=True, base 为当前 master);唯一红是 master 侧 #3769 红风暴测试,建议等其修复或人工判断后合并;发现的新问题已立 #4004 跟踪。 |
Closes #3201
做什么
web UI 会话详情页(/__bili/)新增「上下文轨迹」视图:从已持久化的会话状态重建最近一次发给 LLM API 的出站上下文——不抓包就能看到完整请求内容,对应 dsh 每个会话的「轨迹」页(owner 在 #3201 拍板:详情页最下方默认换成轨迹)。
<stem>.system-surface.json(与 session JSON 同目录):记录最近一次请求的确切系统文本 + 工具定义(此前只持久化了 token 计数)。捕获点 = 四个 wire stamp 处,与既有 systemPromptTokens 测量同点同行;hash 门控(surface 真变化才重写);每字段 ≤400K chars(hash 仍覆盖未截断全量);原子 tmp+rename、mode 0600。derived artifact 语义:缺失/损坏降级为「未捕获」,永不阻塞会话加载;GC 按 twin-fallback 保留规则共删并纳入 orphan 清扫。行为变更(旧 → 新)
[gc] removed orphaned content store <f>→[gc] removed orphaned companion file <f>;汇总行content store file(s)→companion file(s)。原因:orphan pass 现覆盖两类 sidecar(content store + system surface)。<stem>.system-surface.json(每字段 ≤400K chars)。原因:系统提示词文本此前没有任何地方持久化,轨迹视图需要它。Config surface
不涉及 — 无新 config 字段 / env / CLI flag。
测试
边界