Skip to content

[PR] web: blocks pane — collapsible tree (default) + folded-block list + master-detail panel (#4608) - #4737

Merged
ranxianglei merged 14 commits into
masterfrom
feat/session-flame-view
Oct 26, 2026
Merged

ranxianglei merged 14 commits into
masterfrom
feat/session-flame-view

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

What this does

Reworks the Structure → blocks pane in the web session detail view:

  1. Collapsible tree is now the default view. The old flat SVG tier graph is replaced by an org-chart style tree: parents shown on top, children indented below, each node carrying its topic, ref span and token counts. Collapsed nodes show a "+N" chip so you can see the whole structure at a glance; clicking a chip (or a node) expands one level. "Expand all" / "Collapse to roots" buttons plus Esc-to-collapse make long sessions navigable.
  2. The classic folded-block list stays as a second mode (owner decision: keep both, default = tree). It renders the familiar per-block rows with summary text, message rows and expandable details.
  3. Master-detail side panel: selecting any block (tree or list) opens its full content on the right — topic, summary, ref ranges, folded messages with previews — so you never lose your place while browsing the tree.

Both language catalogs (en + zh) got the new strings; the old flame-chart draft from #4545-era exploration is NOT included — it was dropped on request before landing.

Why

The previous single SVG tree was hard to read on real sessions (600+ blocks): no topics visible, no way to collapse, nothing clickable. This gives a readable global picture first (collapsed), drill-down second, and keeps the proven list mode for people who prefer rows.

Scope & tests

Verification (head bb7c249-based rebase):

  • node --import tsx --test tests/web-blocks-tree.test.ts tests/web-i18n.test.ts → 21/21 pass
  • npm run typecheck → clean

Also fixes #4738 — folded-message previews vanishing after host-side native compaction

Symptom. In the session detail page, every folded message of older blocks rendered as "message no longer in the session" — previews that were visible before simply disappeared, though no data was lost.

Root cause. Message previews (and click-to-open text) were served only from lastMessages — the newest full request snapshot the client sent. Folding never drops messages from that window, but host-side native compaction does: once the client's own compressor prunes old messages out of its context, every ref pointing at them reads as "missing", even though the unified store (index.db) still holds every byte (verified on the live session: 41k message rows intact, nothing retired).

Fix. When a ref is absent from the resident window, fall back to storage:

  • UnifiedStore.messageContentByRefNums() — per-ref bodies via chunked ref_num IN query (retired rows excluded like every other view-lane reader).
  • buildSessionDetail batch-hydrates all window-pruned leaves in one query; refs absent from both window and storage keep the honest missing marker — nothing is invented.
  • buildMessageContent (/__bili/sessions/<id>/message?ref=) applies the same fallback, so click-to-open serves any stored message verbatim again.
  • Fail-open throughout: legacy storage mode / disabled sidecar → previous behavior exactly.

Covered by tests/web-storage-fallback.test.ts (prune-then-hydrate e2e over a seeded index.db + fail-open case); existing "pruned reports a miss" test unchanged and passing (it runs with unified storage off).

ci-check and others added 3 commits October 25, 2026 23:02
…ment

#4316 PR3/3 (restampRefsToLedger) re-homes citation numbers once on every
full-mode cold load; goldens pinning exact ref numbers are born-red. Re-pin
the 7 storage-lane tests (engine-proofs x6 + orphan-recovery x1) modulo that
renumbering — zero production code touched.

- golden-storage-drive.ts: per-turn citation-normalized digest (shaCiteNorm)
  and state digest modulo stripOneTimeAlignment (stateDigestAligned); the
  deep-sort helper is hoisted into golden-canonical.ts for sharing.
- corrupt-index-child.ts: new stripOneTimeAlignment normalizer — strips the
  refLedgerAligned stamp and re-homes refs onto canonical raw-id order so a
  clean full-mode read and the legacy fallback load compare equal.
- storage-engine-proofs.test.ts: wire legs assert shaCiteNorm equality vs
  the legacy restart leg and the committed goldens; state legs assert
  stateDigestAligned; rollback leg now spells BILI_STORAGE_UNIFIED=legacy
  explicitly (#3818 flip: absent resolves to full, deleting the env would
  vacate the legacy path).
- storage-orphan-recovery.test.ts: pins the content-addressable
  byRaw->byRef round-trip instead of a counter-era m00003 literal.
- golden/storage-render/*.json regenerated with shaCiteNorm/stateDigestAligned.

Converges the master-red storage-lane family (#4599 plan A, owner directive).
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: feat/session-flame-view (5f57201)

Latest build — install this exact version

npm install -g billion-context@0.0.5837-pr.4737.4a362da

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
5f57201 billion-context@0.0.5837-pr.4737.4a362da build
0ecfcd0 billion-context@0.0.5792-pr.4737.fe8841b build
eb2fa53 billion-context@0.0.5776-pr.4737.80d5b23 build
948009d billion-context@0.0.5772-pr.4737.2198f45 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4737.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title web: blocks pane — collapsible tree (default) + folded-block list + master-detail panel (#4608) [PR] web: blocks pane — collapsible tree (default) + folded-block list + master-detail panel (#4608) Oct 25, 2026
…indow prunes them (#4738)

Host-side native compaction prunes lastMessages client-side, so every folded
message whose bytes left the resident window rendered as 'missing' even though
the unified store still holds them — previews that used to be there vanished
without any data loss (#4738).

- UnifiedStore.messageContentByRefNums: per-ref message bodies (chunked ref_num
  IN query, retired rows excluded, media hydrated)
- UnifiedShadow / SessionStore.unifiedMessageContentByRefs pass-throughs
  (null when the unified sidecar is unavailable — callers stay fail-open)
- buildSessionDetail: leaves absent from the window are batch-hydrated from
  storage; refs absent from BOTH keep the honest missing marker
- buildMessageContent (/message?ref=): same fallback for click-to-open, so any
  stored message serves verbatim again
- tests/web-storage-fallback.test.ts: prune-then-hydrate e2e over a seeded
  index.db + fail-open case with the unified store off
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。 没有其他 open/closed issue 或 PR 做同一件事(blocks pane 改成 tree+list+侧栏)。最接近的:已关闭的 #3917/#4173(旧 structure tab 与树缩放修复,早已合入)、open 的 #4738(同一 pane 里消息预览消失——独立 bug、不同机制,见下面第 2 条);其余 open web PR(#4631/#3337/#4651)各管各的面。

标签: pr(原有)+ scope/ui(web 会话详情页 UI 重构)+ p3(UI 体验改进,无可用性影响)。

这是 [PR] 镜像,按规则不重做工作——核对代码与描述、确认 CI、报结论。初审发现(完整八问结论随后):

  1. 标题里的 issue 号指错了:(Post-fold resaves erase resolved block interval bounds | 折叠后重存会把已解析的块区间边界抹回未知(-1/-1) #4608) 是一个已关闭的存储 bug(折叠后重存抹掉块区间边界,由 [PR] fix(storage): block interval bounds survive post-fold resaves (#4592) #4607 修掉),和本 PR 无关。按规则 agent 不改标题,需要作者/owner 手动把号改对或去掉。
  2. 正文后半段与 diff 不符:正文声称 "Also fixes Web blocks pane: message previews disappear along with native client compaction because they only read the client's late | Web blocks pane: message previews disappear along with native client compaction because they only read the client's late | web 页面里折… #4738"(宿主端原生压缩后消息预览消失 → 回退读存储),并点名了 tests/web-storage-fallback.test.ts、UnifiedStore.messageContentByRefNums() 等;但实际 diff 只动 4 个文件(src/web/client.ts、src/web/i18n.ts、src/web/styles.ts、tests/web-blocks-tree.test.ts)——fallback 代码和新测试文件在 base bb7c249 与 head 948009d 上都不存在(git grep/ls-tree 双向核实过)。像是旧分支版本残留的 body,需要更新;Web blocks pane: message previews disappear along with native client compaction because they only read the client's late | Web blocks pane: message previews disappear along with native client compaction because they only read the client's late | web 页面里折… #4738 本身仍 open、未修。
  3. CI:静态门禁全绿;5 个红 test 分片(u22s3/u24s3/w22s3/s4/s5)与 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 总控记录的 master 自身红簇(storage-lane born-red 家族)同签名,与本 PR diff(纯 web 面)零重叠——待分片日志级核对确认无新增红项。

继续工作中:检出分支本地跑定向套件、通读全量 diff,随后给八问结论。

ranxianglei and others added 10 commits October 26, 2026 00:33
…dger parity masks

The #4316 one-time renumbering restamped messageRefs but left
state.tokenSnapshot keyed by the OLD refs, so post-restart bodies
carried stale per-message token counts (1.3K vs 1.4K) and the
full-mode-restart wire drifted off the legacy baseline (#4599).

persist.ts: two-pass remap (stage moves, delete old keys, then write
new keys) so entries whose new ref collides with another move's old
ref survive; fires only when superseded refs exist.

Aligned normalizer (corrupt-index-child.ts): the cacheLedger's
segment bookkeeping (be/bl/bs, unfinalized tail line), the derived
agg block, and per-line miss-attribution (prov/seam) are restart
experience, not content — no-restart and restart legs legitimately
differ there. Masked in the aligned view only; raw digests keep
full accounting. Goldens regenerated (stateDigest + aligned).

storage-engine-proofs 12/12, golden-storage-render 5/5 locally.
…persisted state (#4599)

The fork-survival test asserted immediately after the compress tool
response, but the fold lands in the live session state asynchronously
(#3573 replay semantics). Slow CI runners persisted the pre-fold state
('0 block(s) (compressions=0)' cold load) and the deepEqual diverged.
Bounded 5s wait on the in-memory fold; fast machines exit on the first
iteration. Product semantics unchanged.
The #4316 cold-load alignment reads the unified sidecar; its ingest of
just-flushed records completes asynchronously. Slow runners compared
the pre-ingest state and saw refLedgerAligned missing while the fold
itself had landed. Poll (bounded 5s) until the loaded state carries
the flag; fast machines exit on the first probe.
…eme-following panes, Esc rebind after navigation

Labeled review fixes for the blocks-pane rework (PR #4737 self-review):

- styles.ts: a find-replace dropped the element suffix on the .block-item
  side of the shared '.block-item .body.md X / .bd-panel .body.md X' rules,
  which left the classic list's summary text unstyled (headings, lists,
  code blocks, quotes, hr) and shifted body color; restore the suffix on
  both sides of every rule.
- styles.ts: .fd-left and .bd-card hardcoded background #fff, breaking the
  dark color scheme; follow the theme instead (var(--bg-elev) / inherited
  from .card).
- client.ts: the once-bound Esc listener closed over the FIRST detail
  pane's renderTree/graphView, so after hash-navigating to another session
  the Escape collapse rendered into detached DOM (dead key); resolve the
  view and renderer at keypress time.
- tests/web-blocks-tree.test.ts: pin the suffixed selector pairs and the
  theme-following pane backgrounds.
Git-for-Windows autocrlf checks the bundled .md posts out with CRLF;
the exact-match '---' fences then failed to parse and every post lost
its title/excerpt/date frontmatter (Windows CI: 'bundled meet-bili post
found' assertion). Normalize CRLF to LF inside parseFrontmatter when
the fence is CRLF-shaped; LF content is byte-identical as before.
Regression test with a CRLF fixture.
… the #4599 bounded-wait commit

Labeled follow-up (review of PR #4737 tree): ci-fixes 8082ee8 added a
direct 'Session | null' -> '{ state: Record<string, unknown> }' cast in the
refLedgerAligned bounded-wait probe, which fails tsc (TS2352 — CompressionState
has no index signature). Route through unknown, matching the test-suite's
existing two-step-cast convention.
… storage mode (#4599)

The #4316 cold-load alignment sets refLedgerAligned only when the
unified store is available; config-clean machines (CI runners) run
legacy mode where it is an honest skip. The test asserted the flag
unconditionally, so every shard carrying this file was born-red on CI
while unified-config machines passed. Expectation now mirrors
store.replicasAvailable(); verified 49/49 in BOTH modes locally.
# Conflicts:
#	tests/plugin-fork.test.ts
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

结论

代码核验通过、方向与描述一致;review 发现的 3 个缺陷已直接在 PR 分支修掉并推送;CI 红全部逐条定位到测试名级 = master 继承的在册簇(与本 PR diff 零交集),已把含修复的最新 ci-fixes tip 合入分支重跑。需人处理两项:标题编号写错、PR body 验证段基于旧 head。

八问

  1. 是什么问题:功能实现 PR——重写 web 会话详情页 Structure→blocks 面板:可折叠树成为默认视图(org-chart 式、折叠节点显示 +N chip、expand-all/collapse-all/Esc 收起)、经典 folded-block 行列表保留为第二模式、右侧新增 master-detail 侧栏(点任意块看 topic/summary/ref 区间/折叠消息预览)。
  2. 什么原因导致的:旧版单一 SVG tier 图在 600+ block 的真实会话上不可读——topic 不可见、不可折叠、无点击交互。
  3. 影响范围与严重程度:纯 web UI 面(src/web/{client,i18n,styles}.ts + 测试);分支另含 Web blocks pane: message previews disappear along with native client compaction because they only read the client's late | Web blocks pane: message previews disappear along with native client compaction because they only read the client's late | web 页面里折… #4738 提交(eb2fa53,resident window 裁剪后从统一存储 hydrate 折叠消息预览——honest-miss 保留、fail-open 降级回原 missing 展示的行为兼容设计)。wire 协议/配置面/持久化格式/kernel/代理行为零改动。即便有问题也只是展示层瑕疵,无可用性风险。
  4. 怎么修复的(review 缺陷,commit aaaa9a2f1):① styles.ts 一处批量替换改错,10 条 markdown 共享规则丢了 .block-item 侧的元素后缀(h2/p/ul/li/pre/code/blockquote/hr/strong)→ 列表模式的标题/列表/代码块/引用排版全部失效,已两侧恢复后缀;② 新面板硬编码 background:#fff 破坏暗色主题 → 改 var(--bg-elev)/继承 .card;③ Esc 收起键位捕获首次绑定的 renderTree 闭包,切换会话后渲染进已脱离 DOM 的节点而失效 → 改为按键时解析元素与渲染函数。tests/web-blocks-tree.test.ts 新增针对 CSS 事实的回归断言(WEB_STYLES)。Web blocks pane: message previews disappear along with native client compaction because they only read the client's late | Web blocks pane: message previews disappear along with native client compaction because they only read the client's late | web 页面里折… #4738 提交本身逐行审过无问题(chunked IN 查询 + retired_at IS NULL、shadow sync-only、失败即 null、JSON guard {id,text}、BLOCK_CONTENT_MAX_BYTES 截断、全程 try/catch fail-open、两个真实 store 种子的回归测试)。
  5. 是否有回归问题:逐项清点过既有行为——zoom 移除(有意,body 已披露);旧图引擎函数(buildGraphSvg/treeMapInnerHtml/bindTreeMap 等)删除后全仓零残留引用(grep 验证);i18n 删掉的 4 个 key 无任何引用;blk-content id 冲突处理改为 closest() 作用域解析(有意,双表面兼容);refreshTreeMap 早退扩到列表模式(有意);经典行 markup(block-item block-node tier-N)与 /block-content 端点契约(feat(web): session detail compact structure tab — tier tree, graph view and lazy originals | feat(web): session detail 压缩结构 tab — tier tree, graph view and lazy originals #3917)不变。typecheck clean;本地定向:web 家族 291/291(含 client/i18n/styles 相关全部 22 个测试文件 + web-storage-fallback + golden-storage-render + storage-engine-proofs + plugin-fork),合 ci-fixes 后 plugin-fork+blogfeed 再跑 57/57。CI:静态门禁全绿;上一 head(0ecfcd0)5 个红分片每个恰好 1 条失败,全部是 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 在册簇且与本 PR diff 零交集:plugin-fork「HTTP fork revision…」×3(refLedgerAligned 仅 unified 模式置位,ci-fixes 1fa93735d 已修)、web-blogfeed「default probing TS source layout」×1(CRLF frontmatter,ci-fixes 1b317de80 已修)、launcher-opencode-inline win32 断言 ×1(仅 Windows 车道的在册 born-red,待哨兵收敛)。新 head 5f57201ac(已合上述两个修复)重跑中:预期前两类转绿,w22s3 可能仍因 opencode-inline 在册簇保持红(与本 PR 无关)。
  6. 是否破坏缓存:不涉及(纯 UI 渲染状态;sessionStorage bili-tree-mode 只记视图偏好)。
  7. 是否改了设计方向:没有——Web UI 内部视图引擎替换,数据流/架构边界未动。
  8. 是否引入新配置:没有(无 env/config/CLI 变更)。

需人处理

判定

代码质量达标、方向正确、本 PR 未引入回归;等 5f57201ac 重跑收敛后(至多剩 opencode-inline 在册簇一项,属 #4599 跟踪范围)即可合并。

@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.841-master.4dc1dc5 (rolling master tag).

npm install -g billion-context@0.0.841-master.4dc1dc5  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant