Skip to content

fix(usage,tui): sidebar attribution in Resolve domain + View segment meter - #2541

Closed
topcheer wants to merge 1 commit into
mainfrom
fix/sidebar-usage-attribution
Closed

topcheer wants to merge 1 commit into
mainfrom
fix/sidebar-usage-attribution

Conversation

@topcheer

Copy link
Copy Markdown
Owner

用户报告

侧栏 llm 套餐 usage 显示不正确;启动 freeze 依旧(ring buffer 已抓到 slow view render: 10.008s)。

根因(ring buffer+代码链路)

usage 侧栏永不更新handleUsageInfoUpdated 把探针返回的 vendor(svc.Resolve(baseURL) 的 URL 域 id,如 openrouter/zai)与配置里的 vendor 名(用户可自由命名,如 ai-gateway)比较——名字不同的配置永不相等,侧栏静默空白。现统一在 Resolve 域比较,端点不可解析时才回退名字比较。

freeze 追踪(延续 #2538/#2540 的仪表策略)

  • 22:00 实例 ring buffer:slow view render: 10.008s(首帧)+ mcpServersMsg handler 1.463s → drain 迟到 11.5s
  • 10s 整点高度疑似超时等待而非渲染;chat.List 级 bench(1946 条+1.4MB checkpoint summary+follow)实测 0ms,排除虚拟滚动本身
  • 本 PR 给 View() 加分段计时(header/statusBar/composer/contextPanel/conversation,>100ms 各自记日志)——下次复现 ring buffer 直接给出段名,一次定位

验证:go test ./internal/tui/ ./internal/chat/ 全绿。

Co-Authored-By: ggcode noreply@ggcode.dev

…meter

Sidebar usage attribution compared msg.vendor (svc.Resolve's URL-id:
'openrouter', 'zai'...) against the CONFIG vendor NAME (users name
vendors freely, e.g. 'ai-gateway' for an openrouter base) - mismatched
names never compared equal and the sidebar silently never updated.
Both sides now compare in the Resolve domain, falling back to the old
name comparison only when the endpoint cannot be resolved.

Also extends the View() meter (#2540) with per-section timers: the
22:00:29 reproduction logged 'slow view render: 10.008s' as a single
blob; the next reproduction names the offending section directly
(header/statusBar/composer/contextPanel/conversation). chat.List bench
(1946 items + 1.4MB checkpoint summary, follow mode) pins the virtual
scroll itself at ~0ms, ruling the chat viewport out.

Co-Authored-By: ggcode <noreply@ggcode.dev>
@topcheer

Copy link
Copy Markdown
Owner Author

Superseded by #2542: the attribution approach here (RESOLVED probe-id domain matching) was rejected in review in favor of #2542's final design - full-URL probe matching with no attribution layer at all (probes fire only for the session's current endpoint, results render directly). The View segment meter portion (segmentTimers in view.go) is valuable but orthogonal - please rebase it onto main as its own PR without the update_usage.go attribution hunk.

@topcheer topcheer closed this Sep 18, 2026
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