Skip to content

perf(console): cut first-screen payload and request stats scans - #573

Open
guyu233 wants to merge 2 commits into
caigee-cmd:mainfrom
guyu233:feat/console-lazy-shell
Open

guyu233 wants to merge 2 commits into
caigee-cmd:mainfrom
guyu233:feat/console-lazy-shell

Conversation

@guyu233

@guyu233 guyu233 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

上线前确认(必读)

必须由主仓维护者确认本次修复没有问题后,才能合并、上线或发布。
在获得主仓明确确认前,请保持 PR 为待审核状态,不要直接合并到 main 或进入 release。

Summary

  • 控制台页面全部改为路由级懒加载,登录页也独立成 chunk;首屏不再加载 HeroUI 共享运行时。
  • 顶栏、侧栏改用无依赖的原生 ShellControls;移动抽屉改为原生实现,补齐 Escape、背板点击、滚动锁和 1024px 断点关闭。版本更新弹窗改为点击后懒加载。
  • 概览资源面板改为 30s 采样并在页面隐藏时暂停;账号倒计时共用单个 timer;运行日志隐藏时暂停轮询;实时卡片展开态轮询 400ms → 800ms,深度图仅展开时加载,60s sparkline 改手绘 SVG。
  • 请求统计改为单次 SELECT 后在 Go 内聚合,删除原先的多轮扫描。
  • 附带 Windows 全量测试的最后几处跨平台修正(仅测试代码;Unix CI 行为不变)。

Payload result

Before After
Entry 461 kB 421.97 kB / 134.79 kB gzip
Preload entry + SkeletonBlock 239 kB + useToggleState 94 kB + shim 13 kB + gsap 93 kB entry + jsx-runtime 12.04 kB + gsap 93.38 kB
HeroUI shared preload yes no

The generated internal/webui/static is rebuilt and committed, so the embedded console matches frontend/dist.

Request stats

20k-row local benchmark:

  • legacy multi-scan: ~227 ms/call
  • single-pass: ~57 ms/call (~4x)

SummarizeRequestLogsWith now reads the window once and accumulates totals, status buckets, model/account/provider buckets, series and optional p50/p95 in Go.

Verification

On the final PR head:

  • cd frontend && npm run lint — 0 errors (62 pre-existing warnings)
  • cd frontend && npm run build + node scripts/sync-static.mjs — pass
  • go test ./... -count=1 -timeout 300s — pass
  • go vet ./... — pass
  • python scripts/release-notes.py validate — pass
  • Built the server, served the final embedded bundle on 127.0.0.1:3011, and checked in the in-app browser: /system, /, /usage, /accounts, /providers, /access, /logs, /keys, login page, dark/light mode, language switch, version dialog, and the 967px mobile drawer (open/Escape/backdrop/nav close/scroll-lock). No console errors.

Risk / rollout

  • The shell and mobile drawer are the highest-risk UI surface; the breakpoint behavior was explicitly tested at 967px.
  • Resource polling is slower by design (30s, aligned with the backend snapshot tick). Stats values are unchanged; only the scan strategy changed.
  • No database migration and no provider behavior change in this PR.
  • Keep this behind the main-repo confirmation above before merging or releasing.

Follow-up

A second stacked PR (#574) will add key-level cross-provider model aggregation on top of this branch. It must not be merged before this PR lands.

Lazy-load every console page, replace the shell's HeroUI controls with dependency-free primitives, load the update dialog on demand, and poll resources/live data less often. The embedded console now preloads only the entry, jsx-runtime and GSAP instead of the HeroUI shared chunk.

Also summarize request logs with one SELECT and aggregate in Go; the 20k-row local benchmark drops from ~227 ms to ~57 ms per call.
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.

1 participant