Skip to content

feat(web): full UI rewrite — read-only overview / sessions / config / connect (#1420) - #1426

Merged
ranxianglei merged 25 commits into
masterfrom
wt-1420-ework-daemon
Sep 27, 2026
Merged

ranxianglei merged 25 commits into
masterfrom
wt-1420-ework-daemon

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #1420

Complete rewrite of the built-in web UI (src/web/) per the issue: fresh design (ework-web-inspired light/dark cards + tabs), zero dependencies, no CDN assets. This phase is read-only per issue point 2 — config editing comes next phase.

What's new

4 pages (hash-routed, no full reloads):

  • Overview — global stats: session counts (live/disk), total requests, tokens saved, global cache hit rate, input/cached/output totals, per-protocol breakdown, recent sessions; system status (version/stale/in-flight/blind tunnels/passthrough/conflict banner).
  • Sessions — searchable list across the live memory pool and every persisted session on disk (previously only live in-memory sessions were visible). Detail view per session: identity, usage grid with context-window bar, hand-drawn SVG context trajectory chart (input vs cached per request, fold markers, window ceiling line — the fig3-marathon-trajectories style from issue point 4, data from the same cache ledger /acp-cache uses), cache economics (newContent/compRepay/ttlRepay/residual + fold table), compression blocks, and the rendered handoff document (the bili export content, safe server-side markdown→HTML).
  • Config (read-only) — providers/routes/models, upstream proxy mode, compress block (with the full key glossary incl. the feat: neverPreserveRecentTools config knob (acp-kernel 0.0.92) #1332 preserveRecentTools/neverPreserveRecentTools entries), passthrough state; upstream probe button kept.
  • Connect — per-client setup instructions (OpenCode/Codex/Claude/Pi/ZCode-MITM/others).

New endpoints (loopback-gated like all other /__bili/* routes)

Disk scan uses a memoized full-store load with a 5 s TTL (cheap at 5 s poll cadence); strictly read-only.

Behavior changes (flagged per policy)

  • The old Settings/Upstream pages were editable (textareas + save buttons). They now render as read-only displays. The underlying APIs are unchanged: PUT /__bili/config, POST /__bili/upstream/test, passthrough override clearing via API all still work exactly as before — only the UI controls were removed for this phase.
  • Sessions page previously showed only the in-memory pool; it now also lists persisted disk sessions (additive).
  • i18n catalogs (zh-CN/en) rewritten; language toggle preserved (localStorage bili-language).
  • Rebased onto current master and ported two recently-merged web features into the new shell so nothing regresses: 自动识别其他压缩插件存在并在任何可能的情况下报告警告 #1206 co-resident-compressor conflict banner (conflict.on/conflict.desc + data.conflicts handling, now also served by /__bili/overview) and feat: neverPreserveRecentTools config knob (acp-kernel 0.0.92) #1332-review compress-key glossary strings.

Tests & pre-flight (on rebased head)

  • tests/web-i18n.test.ts unmodified, passes (strict catalog parity / dead-key / DOM coverage rules)
  • tests/web-routing.test.ts: 2 assertions updated for the read-only phase (no <textarea>/save buttons); all API round-trip tests untouched
  • New tests/web-sessions.test.ts (6 tests): markdown XSS safety, live+disk merge & precedence, overview aggregation math, detail payload, endpoint wiring incl. 404
  • Preflight: typecheck clean · build OK · full suite 2812 pass / 0 fail (12 skipped by design)

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: wt-1420-ework-daemon (709d444)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1419-pr.1426.634d563

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始核对这个 PR:拉取分支 wt-1420-ework-daemon、检查 CI 状态、按仓库规范做回归与代码审查(对照原 issue #1420 的各点验收)。结论稍后更新在本线程。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

Review complete — code checked out and diff-reviewed against #1420, rebased onto current master, full pre-flight re-run on the new head.

What I did

  • Reviewed the entire 10-file diff (+1953/−292) against the original issue 大幅度改进自带web,提供更好的体验 #1420 point by point.
  • The PR had drifted 6 commits behind master (master passed through release v0.1.157 + chain-checkpoint feat: chain checkpoint step 2 — shadow recognition (parser, JCS digest, carrier contract) #1397 — which also touches src/server.ts, a hot file this PR modifies). Rebased the single commit onto current master cleanly (no conflicts) and updated the branch: wt-1420-ework-daemon ee15bcdd → f1953efd. CI is re-running on the new head.
  • Pre-flight on the rebased head (local): typecheck clean · npm test 2835 total / 2823 pass / 0 fail / 12 skipped (2835 = the claimed 2812 + 23 master-side chain-checkpoint tests — consistent) · build OK.

① Direction vs original issue

All four asks of #1420 are covered: fresh UI (zero deps, no CDN refs — verified by scan; the only external URLs in src/web/ are example strings on the Connect page), read-only phase respected (no edit controls anywhere; the only non-GET call is the kept POST /__bili/upstream/test probe), session list built on the export capability (renderHandoff = bili export content, server-side rendered), global token/savings stats + per-session trajectory chart sourced from the same cache ledger as /acp-cache. The two ported features check out: #1206 conflict banner (conflict.on/conflict.desc present in both catalogs, rendered from data.conflicts) and the #1332 compress-key glossary (incl. preserveRecentTools/neverPreserveRecentTools).

② Regression checklist (existing behaviors on touched paths)

  • /__bili/stats, /__bili/status, /__bili/cache-report, root health-probe JSON, PUT /__bili/config, POST /__bili/upstream/test: unchanged — API round-trip tests untouched and passing.
  • The 3 new routes are registered inside the existing isAdminPath block, after the loopback + trusted-origin gates; tunneled requests remain rejected by the x-bili-tunnel marker.
  • renderUI / version() / config-handler exports in src/web/index.ts unchanged; src/web/api.ts not touched by the diff.
  • Editable Settings/Upstream pages → read-only displays: intentional, already disclosed in the PR body (UI controls removed; APIs intact). Acceptable.
  • Sessions page now lists disk sessions: additive; live-pool entries win per id (tested).
  • Unmodified strict i18n suite (catalog parity / dead keys / DOM coverage) passes → the zh/en rewrite is consistent.
  • No wire/preflight/nudge/compression-mode changes; package.json/lockfile/version untouched (correct for a content branch).

③ Code review highlights

  • sessions-data.ts: 5 s-TTL memoized, single-flight disk scan; the second SessionStore instance is provably write-free (loadAll only; debounce timers arm on writes — verified against src/persist.ts), so no writer contention with the main store; unreadable files skip silently like bili export; _resetDiskCacheForTest exists because the store resolves its dir at construction.
  • markdown.ts: escape-first construction — I traced every line path and no raw byte reaches output unescaped; link sanitizer drops javascript: etc.; fenced-code content escaped; truncation cap (1.5 MB) with a visible notice.
  • server.ts: detail-id parsing treats malformed percent-encoding as unknown session (404, empty-id message stays JSON-safe); sendOverview degrades gracefully if detectStaleInstall hits an fs error.
  • client.ts: all dynamic values routed through escapeHtml; 5 s poll skips hidden tabs; handoffHtml insertion is server-rendered-and-escaped by construction.

④ Test validity

tests/web-sessions.test.ts has teeth, not ceremony: exact-arithmetic assertions on overview aggregation (requests 13, input 1600, hitPct 44…), live-wins-over-stale-disk-twin ordering with a deliberately stale twin, escaped handoff HTML assertion (Sum &lt;text&gt;), raw-HTML/javascript: XSS vectors pinned, real startServer HTTP round-trips over all three endpoints + the 404 path, and listen(0) ports per the #360 determinism rule. The two updated web-routing assertions correctly adapt to the read-only phase (doesNotMatch <textarea / save buttons) while keeping the injectTool/injectNudge round-trip regression pinned through the API.

⑤ Diff cleanliness

10 files, every line related to this feature; no lock-file churn, no generated artifacts, no version bump, no whitespace noise. Working tree verified clean.

Non-blocking observations (for this or the next phase — no action required to merge)

  1. Disk-scan cadence: Overview and Sessions both poll every 5 s and both funnel into loadDiskSessions() whose TTL is exactly 5 s — a long-lived open tab effectively triggers a fresh decode of the entire session store (zstd/GCM) each cycle. Fine for typical stores; on a machine with many large encrypted sessions consider a longer TTL or lazy first-load.
  2. Defensive asymmetry: buildSessionDetail wraps renderHandoff in try/catch but not buildSessionCacheReport — a pathological session would 500 the whole detail payload instead of degrading to ledger: null.
  3. Link sanitizer edge: the ^\/ alternative admits protocol-relative URLs (//host/x) into href. Self-XSS only (the user's own export content, loopback-only UI) so no security impact — noted for completeness.
  4. Test gap (trivial): no case for the malformed-percent-encoding 404 path in sendWebSessionDetail.

Verdict

No regressions found; behavior changes are disclosed and match the agreed phase plan. Mergeable — CI on the rebased head f1953efd should land green (previous head was green; local pre-flight on the new head is green). Merging itself stays with you.


中文摘要: 审查了 web UI 重写 PR(#1426,对应 #1420)——方向与原 issue 一致(本阶段只读配置、会话列表基于 export、全局统计+轨迹图齐备),对触碰路径逐项回归清点未发现回归(既有 API 全部不变、三个新路由都在 loopback+origin 门控内、i18n 严格一致性测试通过),代码与测试质量良好;发现 PR 落后 master 6 个提交且双方都改了 server.ts,已 rebase 到最新 master 并推送(新头 f1953efd,本地全套预检绿:typecheck 干净、2823 pass / 0 fail、build 成功,CI 重跑中),另列了 4 条非阻塞小建议,可以合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收尾确认(接上一条完整 review): rebase 后的新头 f1953efd 上 CI 已全部跑完 —— 13/13 checks 全绿(ubuntu/windows 双 Node 版本测试、全部 e2e lane、hermetic registry、build-artifact、version-guard)。最终结论:未发现回归,可以合并;4 条非阻塞小建议已列在上一条,合并由你来操作。

中文摘要: web UI 重写 PR(#1426)审查完毕——方向与原 issue #1420 一致、回归清点无回归、代码与测试质量良好;已 rebase 到最新 master 并推送(f1953efd),本地预检与 CI 全套均绿,可以合并。

ework-agent and others added 19 commits September 27, 2026 20:18
…s-vs-net savings

- drop position:sticky on table headers (they floated off the table mid-scroll)
- context trajectory: start/end timestamps under the seq axis, hover tooltips on
  fold marks (fold n · time · S); fold economics table gains a time column
- untitled sessions fall back to the first compression block's topic/summary lead
- split the savings stat per acp-cache semantics: 'compressed savings
  (cumulative)' = sum(S-sigma)*requestsAfter + legacy estimates; 'net savings'
  subtracts measured re-pay and summary cost (ledger sessions only)
Color each sample's un-cached band (input minus cached) by its most likely
cause — long idle gap with upstream TTL expiry (red), prefix rewritten by a
compaction fold so the cache must be rebuilt (amber), cold start (gray) —
with a per-sample hover tooltip carrying the full breakdown. Heuristics only
need fields every ledger era stores (timestamps, input/cached, fold times),
so older sessions without nc/cr/tr decomposition still get annotations.
…vings notes

- trajectorySvg: first sample now resolves cold/new without touching lines[i-1]
  (resumed sessions start with cached>0 -> p=undefined -> page script died);
  also filter out null/sparse ledger lines defensively
- loadDetail render wrapped in try/catch: a malformed session shows a warning
  card instead of an eternal spinner
- overview: gross-savings card always explains its counting basis (per-fold
  savings x every later request, theoretical upper bound); net-savings card
  notes pre-tagging sessions without samples are excluded
- i18n: ov.gross_note / ov.net_excl (zh+en); drop dead common.tokens
… draw system-prompt baseline, show client origin; fold table capped at 30; untitled blocks titled from summary lead
…ept verbatim in pre, line breaks preserved; chart legend swatches get real colors (TTL now purple)
…ts.tokensSaved is no longer written); add client / cum. input / compression-count columns; per-block copy buttons + blocks copy-markdown action + title copy & hover-full-title
…folds cap 10 w/ scroll panel, structured handoff rendering
…obally and per protocol; add cache hit rate to session usage card
…every session row, the global hit card and session usage; folds table becomes one scroll panel
…t in-card; drop the long footnote (full text moved to hover tooltip)
…mpty stub sessions (count shown), make wide tables scrollable
…r, download, copy path); detail identity links to a session's log lines
…lain routes/compress/passthrough; cache-report md copy+download on session detail; label==id treated as untitled
…wording for HTTP >= 400; single raw config-file editor replaces route/compress JSON boxes; plugin mode marked recommended with full 9-agent list; copy feedback on chip buttons
…ithout label swap; per-client launcher notes as hover tooltips
…ric columns centered; disk/restored badge tooltips; sample-trim note explains SAMPLE_CAP 512
… columns; selection-safe row clicks; negative net-savings tooltips; cache sample cap 512→4096
…itTd); per-protocol nc/cr/tr miss-drop pps in overview payload
…k or middle-click opens the session in a new tab; plain clicks navigate in-page as before
- plugin: webSessionUrl(origin, id) builds '<origin>/__bili/#/session/<id>'
  - status panel gains 'Web UI: <url>' inserted ABOVE PANEL_BOX_FOOTER so the
    strip-anchor (start+end signature) stays intact — zero model tokens
  - tool acp-cache output prefixed with the same line before the report body
  - server passes the real bound origin (0.0.0.0 -> localhost, socket.localPort)
@ranxianglei

Copy link
Copy Markdown
Owner Author

复合回归问题 拉最新

@ranxianglei
ranxianglei merged commit ea40f91 into master Sep 27, 2026
13 checks passed
ranxianglei pushed a commit that referenced this pull request Oct 6, 2026
…2219)

The conflict surfaces told users WHAT happened (two compressors coexisting) plus the generic 'keep exactly one compressor' imperative, but no path to HOW — answering correctly required four separate doc locations, none linked from any surface (#917 board case: repeated unannounced-rewrite warnings, user had no idea what to do).

Add a one-line per-client remediation hint keyed on the client identity already recorded at request time (#1426):
- conflict-watch.ts: conflictClientOf() resolves pluginAgent ('mcp' falls through, #760b) then clientHint (exact scan-client names pass through; codex UA truncations normalize via isCodexClient); conflictRemediation() holds the opencode/claude/codex/pi/omp + generic map mirroring the doc anchors; CONFLICT_DOCS_POINTER. formatConflictSection() gains an optional client param and appends the Fix line + docs pointer; ConflictSummary gains clients[].
- acp_status passes this session's resolved client.
- Web banner: one i18n line per distinct client (capped at 3, unknown -> generic, old payloads without clients[] degrade to generic only); session-detail card shows its own client's hint (new conflictClient field in the detail payload).
- Launcher co-resident-plugin warning gains a 'fix (<client>)' line from the same map.
- i18n zh+en conflict.hint.* keys; tests pin resolution, the map, the section suffix, clients[], i18n parity/drift, and web wiring.

Guidance-only: detection gates/thresholds untouched (#2219 non-goal); no config surface changes.
ranxianglei pushed a commit that referenced this pull request Oct 6, 2026
…2219)

The conflict surfaces told users WHAT happened (two compressors coexisting) plus the generic 'keep exactly one compressor' imperative, but no path to HOW — answering correctly required four separate doc locations, none linked from any surface (#917 board case: repeated unannounced-rewrite warnings, user had no idea what to do).

Add a one-line per-client remediation hint keyed on the client identity already recorded at request time (#1426):
- conflict-watch.ts: conflictClientOf() resolves pluginAgent ('mcp' falls through, #760b) then clientHint (exact scan-client names pass through; codex UA truncations normalize via isCodexClient); conflictRemediation() holds the opencode/claude/codex/pi/omp + generic map mirroring the doc anchors; CONFLICT_DOCS_POINTER. formatConflictSection() gains an optional client param and appends the Fix line + docs pointer; ConflictSummary gains clients[].
- acp_status passes this session's resolved client.
- Web banner: one i18n line per distinct client (capped at 3, unknown -> generic, old payloads without clients[] degrade to generic only); session-detail card shows its own client's hint (new conflictClient field in the detail payload).
- Launcher co-resident-plugin warning gains a 'fix (<client>)' line from the same map.
- i18n zh+en conflict.hint.* keys; tests pin resolution, the map, the section suffix, clients[], i18n parity/drift, and web wiring.

Guidance-only: detection gates/thresholds untouched (#2219 non-goal); no config surface changes.
ranxianglei pushed a commit that referenced this pull request Oct 6, 2026
…2219)

The conflict surfaces told users WHAT happened (two compressors coexisting) plus the generic 'keep exactly one compressor' imperative, but no path to HOW — answering correctly required four separate doc locations, none linked from any surface (#917 board case: repeated unannounced-rewrite warnings, user had no idea what to do).

Add a one-line per-client remediation hint keyed on the client identity already recorded at request time (#1426):
- conflict-watch.ts: conflictClientOf() resolves pluginAgent ('mcp' falls through, #760b) then clientHint (exact scan-client names pass through; codex UA truncations normalize via isCodexClient); conflictRemediation() holds the opencode/claude/codex/pi/omp + generic map mirroring the doc anchors; CONFLICT_DOCS_POINTER. formatConflictSection() gains an optional client param and appends the Fix line + docs pointer; ConflictSummary gains clients[].
- acp_status passes this session's resolved client.
- Web banner: one i18n line per distinct client (capped at 3, unknown -> generic, old payloads without clients[] degrade to generic only); session-detail card shows its own client's hint (new conflictClient field in the detail payload).
- Launcher co-resident-plugin warning gains a 'fix (<client>)' line from the same map.
- i18n zh+en conflict.hint.* keys; tests pin resolution, the map, the section suffix, clients[], i18n parity/drift, and web wiring.

Guidance-only: detection gates/thresholds untouched (#2219 non-goal); no config surface changes.
antclt pushed a commit to antclt/billion-context that referenced this pull request Oct 11, 2026
…ion, one carrier, sticky binding (ranxianglei#1426)

Single-rig proof of the mode-upgrade contract the two compression modes
rely on: a session that grew and folded in proxy mode upgrades to plugin
mode via x-bili-plugin without forking, keeps the proxy-era fold alive
(preflight blocks carry acp_summary in any mode), stops tool injection
exactly at the flip, executes a plugin-era fold through /__bili/plugin/
tool coexisting with the proxy-era block, refuses downgrade when the
header disappears (sticky pluginAgent), lets a different agent header
override the recorded value, and never latches destroy-escalation or
conflict events on any sanctioned flip. Tooth verified: deleting the
sticky-restore line in server/handle.ts fails the sticky phase.
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
@ranxianglei
ranxianglei deleted the wt-1420-ework-daemon branch October 15, 2026 05:33
ranxianglei pushed a commit that referenced this pull request Oct 20, 2026
…3769/#1567)

The fold-gated sweep hid EVERY orphan-fate compress pair at/after the fold's
start ref — including successful echoes whose call id never matched the
server-minted block id. A re-sent pair quoting an ACTIVE block's range is the
plugin lane's summary carrier (KDD#7), so hiding it strands the summary: the
#1999 double-carrier test, the plugin session-lock e2e, #1426 mode-upgrade
proof and #1638 notification pin all went red.

resolveFate's 'orphan' verdict is id-based and cannot see success; the sweep
branch now additionally requires the call to quote NO active block range
(quotesActiveBlock: both arg shapes — content[] entries and flat top-level
startId/endId — mirroring the host stripKernelSummaries carrier recognition).
Genuinely failed records and dead-block pairs (swallowed by a wider fold)
still sweep at the fold boundary, per the approved #3769 design.
Zhishulo pushed a commit to Zhishulo/billion-context that referenced this pull request Oct 20, 2026
…anxianglei#3769/ranxianglei#1567)

The fold-gated sweep hid EVERY orphan-fate compress pair at/after the fold's
start ref — including successful echoes whose call id never matched the
server-minted block id. A re-sent pair quoting an ACTIVE block's range is the
plugin lane's summary carrier (KDD#7), so hiding it strands the summary: the
ranxianglei#1999 double-carrier test, the plugin session-lock e2e, ranxianglei#1426 mode-upgrade
proof and ranxianglei#1638 notification pin all went red.

resolveFate's 'orphan' verdict is id-based and cannot see success; the sweep
branch now additionally requires the call to quote NO active block range
(quotesActiveBlock: both arg shapes — content[] entries and flat top-level
startId/endId — mirroring the host stripKernelSummaries carrier recognition).
Genuinely failed records and dead-block pairs (swallowed by a wider fold)
still sweep at the fold boundary, per the approved ranxianglei#3769 design.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

大幅度改进自带web,提供更好的体验

1 participant