fix(desktop): name the session in the usage activity task column - #4219
Open
liuxiaocs7 wants to merge 1 commit into
Open
fix(desktop): name the session in the usage activity task column#4219liuxiaocs7 wants to merge 1 commit into
liuxiaocs7 wants to merge 1 commit into
Conversation
liuxiaocs7
added a commit
to liuxiaocs7/maka
that referenced
this pull request
Aug 29, 2026
liuxiaocs7
force-pushed
the
liuxiaocs7/usage
branch
from
August 29, 2026 21:27
641b0c8 to
1016c2d
Compare
The Usage Statistics activity log's 任务 (Task) column showed `未命名会话 · <id>` for every row. apache#3833 fixed this by carrying `SessionHeader.name` through the old usage-stats-store.ts pipeline, but apache#3697 moved usage onto the Runtime Host projection and apache#4060 deleted that store — the new pipeline only carried `sessionId`, so `UsageRequestLog.sessionName` was declared but never populated and the UI always hit the untitled fallback. Resolve the title on the Host, where every usage-bearing session is reachable. HostUsagePricingCoordinator takes a session-title reader (sessionStore.readHeaderSnapshot) and, per logs page, resolves the title for each row's sessionId, emitting it as a new bounded `sessionTitle` field on the LLM/tool usage projections. Reading the durable header by id bypasses the catalog's role/preparing/ledger-v0 filters, so reserved-role, coordination, and legacy sessions are named too; an unreadable session is tolerated per-row and simply stays untitled. The desktop layer copies `sessionTitle` onto `sessionName`; the renderer (usageSessionDisplayLabel) already owns the untitled fallback. Bump the Host compatibility epoch (68 → 69): the new projection field is rejected by older Clients, so the same protocol version no longer guarantees safe interoperability. Closes apache#4218 Generated-by: Claude Code (claude-opus-4-8)
liuxiaocs7
force-pushed
the
liuxiaocs7/usage
branch
from
August 29, 2026 21:39
1016c2d to
7dbaf8c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On the Usage Statistics page (使用统计) → Activity records (活动记录), the 任务 (Task) column showed
未命名会话 · <short id>("Untitled session") for every row — even sessions that have a real title.This is a regression. #3833 fixed exactly this column by carrying the session name (
SessionHeader.name) through the oldpackages/storage/src/usage-stats-store.tspipeline. #3697 then moved usage onto the Runtime Host projection and #4060 deleted that store. The new pipeline only carriedsessionId, never the title, soUsageRequestLog.sessionNamewas declared-but-never-populated and the UI'susageSessionDisplayLabelalways fell back to the untitled label.Resolve the title on the Host, where every usage-bearing session is reachable:
HostUsagePricingCoordinatortakes a session-title reader (stores.sessionStore.readHeaderSnapshot). Per logs page it resolves the title for each row'ssessionIdand emits it as a new boundedsessionTitlefield on the LLM/tool usage projections (projectText, ≤1024 bytes).role/preparing/ledger-v0filters (sqliteOrdinarySessionRolePredicateet al.), so reserved-role, coordination (e.g. WorkHub), and legacy sessions are named too — not just ordinary ones.sessionTitle→sessionName; the renderer (usageSessionDisplayLabel) already owns the untitled fallback, so no UI change.Fixes #4218
Review responses
This supersedes the earlier main-process/catalog-join approach. Addressing the review:
readCatalogRecordapplies the samerole/preparing/ledger-v0filters as the list query, so no complete name source is reachable from the desktop process. Fixed at the source — the Host resolves titles from the unfiltered durable header, covering reserved-role/coordination/legacy sessions.readHeaderSnapshot, wrapped per-id, so a single unreadable/unprojectable session can't affect the others. The all-or-nothingclient.listSessions()is no longer used here.loadSessionNames()catch was removed. The title now rides the existingqueryUsageread, which already propagates reconnectable failures throughhandleReconnectableRead.sessionTitle(removing the.trim()guard fails it), alongside a resolved title and a throwing (unreadable) session.Verification
Same Storybook case (
product-settings-pages--usage-long-tail), differing only by whether the title is populated. Named sessions show their real title; genuinely unnamed rows still fall back:Checks run locally:
tscbuild of@maka/runtime-hostandtsc -p tsconfig.main.json(desktop main) — both clean.node --test— 23/23 across the affected suites:usage-pricing-two-client-udsincl. a new case: the LLM/tool logs carry the Host-resolved title, a whitespace-only title is dropped, and an unreadable session is tolerated.usage-pricing-protocolincl.sessionTitleround-trip + over-length rejection.runtime-host-usage-ipc-main:sessionNameis surfaced from the projection'ssessionTitle.biome checkon the changed files — clean.Not run in this environment: the full workspace typecheck / full test suite / e2e / a real Electron window.
@maka/uicurrently has pre-existing@astryxdesign/coretype errors unrelated to this change; the desktop main process and the Host packages don't depend on@maka/ui, and Storybook renders it from source, so the evidence above is unaffected.AI use
Select exactly one:
Tool(s) and scope: Claude Code (claude-opus-4-8) — diagnosis, the fix, the tests, and the before/after evidence. The commit carries a
Generated-bytrailer.Checklist
Does this PR entail a change in behavior?