Repository navigation
fix(ui): disambiguate multi-account session labels - #124228
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs changes before merge. Reviewed August 15, 2026, 7:31 PM ET / 23:31 UTC. ClawSweeper reviewWhat this changesThe PR makes Control UI session labels distinguish non-default channel accounts and legacy direct-message keys, while keeping sidebar rename dialogs bound to stored user labels. Merge readinessThe PR’s core Gateway-row-based label repair is sound, but it mislabels configured named default accounts and needs one focused correction before merge. Priority: P2 Review scores
Verification
How this fits togetherGateway session rows carry routing facts into the Control UI display resolver, which produces labels for sidebars and chat panes. Rename actions then persist only user-owned labels back through the Gateway session mutation flow. flowchart LR
A[Channel account configuration] --> B[Gateway session row]
C[Session routing key] --> B
B --> D[Control UI display resolver]
D --> E[Sidebar and chat titles]
E --> F[Rename action]
F --> G[Stored user label]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +52, Tests +212. Total +264 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Project an additive Gateway default-account fact through the existing generic channel-plugin resolver, retain raw Do we have a high-confidence way to reproduce the issue? Yes—source establishes that a configured Is this the best way to solve the issue? No—the UI cannot determine configured-default identity from Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5014839937b9. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
|
Pushed a follow-up commit that changes behavior beyond the previously reviewed head, so this needs a fresh look rather than a carry-over. What changed since
Both rank-up moves from the last review are addressed. The closing reference is narrowed to the session-label portion, so #123112 stays open for the outbound-history path it also reports. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Suffix detection no longer reads rendered text. The account is appended from the recorded value alone; the Channel classification is held to canonical shapes. An account segment is accepted only before I did not take the "consume the Gateway classification fact" option, and I want to flag why rather than have it read as an oversight. Rows do carry a canonical Tests now prove the projection is authoritative. Previously every fixture duplicated an account the key already carried, so ignoring On the closing reference: @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Parse the optional account segment on per-account-channel-peer DM and group keys so Control UI no longer falls through to the raw routing key. Append a non-default account as " · accountId" on label, displayName, and fallback so two Alice rows from different Telegram accounts stay distinguishable. Signed-off-by: Sebastien Tardif <[email protected]>
The display resolver was reading the account out of the session key and inferring it from label text. That missed the shipped `dm` spelling of direct keys, invented an account-qualified group shape no key builder emits, and treated any name ending in "(<account>)" as already disambiguated. The Gateway already projects the canonical `accountId` onto every session row from the delivery route, so display consumes that and parses the key only for panes rendered before their row arrives. Key parsing now covers both `direct` and the pre-openclaw#11881 `dm` spelling, group keys go back to their canonical account-less shape, and the account suffix is applied at a single point instead of five. `resolveChannelSessionInfo` classifies `dm` keys as channel sessions and no longer reads a peer kind sitting in the channel slot as a channel.
Three related text-inference defects in the same display neighborhood: The account suffix was skipped when the resolved name already ended in " · <account>". That reads rendered output as if it were a fact, and it cannot tell an account apart from a user label that happens to look like one. The suffix is now appended from the recorded account alone. The string it was defending against came from the sidebar rename dialog, which pre-filled with the resolved display name. Submitting persisted a derived string as a real user label, which then outranked every later derivation. Sidebar rows now carry the stored label alongside the resolved one, and rename edits that, matching the Sessions page. Channel classification accepted an account segment before any peer kind, so `agent:<x>:<channel>:<account>:group:<id>` was filed under a channel even though accounts qualify direct chats only and the canonical route parser rejects the shape. The grammar now allows an account only before `direct`/`dm`. Resolver tests now prove the row projection is authoritative rather than duplicating an account the key already carries: one case where only the projection supplies it, and one where the two disagree.
7384f4c to
0c4288a
Compare
Signed-off-by: Sebastien Tardif <[email protected]>
The existing sidebar rename coverage uses a row that already has a stored label, so it passes whether rename pre-fills the stored label or the resolved display name. It could not catch the round-trip this branch repaired. Adds a browser case on a displayName-only row with a projected account: the sidebar shows "Alice · cards" and the rename field opens blank. On the parent commit the field opens holding "Alice · cards", which is the string that used to become a real user label on submit.
|
Good catch — the existing rename coverage used a row that already had a stored label, so it passed whether the field pre-filled the stored label or the resolved display name. It could not have caught the round-trip this branch repairs. Added the case you asked for to the account-label E2E: a On the parent commit that field opens holding One note on the branch state: it was rebased onto current @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
A persisted label that already ends in " · accountId" must stay as-is so "Alice · cards" does not become "Alice · cards · cards". Signed-off-by: Sebastien Tardif <[email protected]>
|
@clawsweeper re-review
Pushed af73ff7: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
The comment above withAccountDisambiguator claimed the rendered name is never inspected, which the suffix check contradicts. State the real contract instead: the account itself still comes only from the recorded value, and the endsWith check is idempotence against the chat pane's inline rename, which seeds its input with the rendered title and persists a partial edit verbatim.
|
Thanks for pushing My starting position was that the guard defended a state the product cannot produce. The suffix ships in this PR, and the rename work in this same PR moved both the sidebar dialog and the Sessions page onto the stored label, so neither of those can persist a derived That reading was wrong, and the surface I missed is the chat pane's inline title rename. I confirmed that end to end against this head rather than reading it off the diff: driving So the guard is earning its place, and it is idempotence rather than inference — the account still comes only from the recorded The deeper fix belongs at the producer: an editable field should be seeded with the stored label, or at most with the undecorated name, so presentation never becomes persisted data. That is a change to a deliberate affordance from #121452 and wants its own discussion, so I have recorded it as a follow-up in the PR body instead of widening this one. Landing the idempotence guard now keeps the reachable flow rendering correctly in the meantime. Nice catch, and thanks for your patience through the review rounds. Landing this once exact-head CI finishes. #123112 stays open for the outbound-history half, as your description already says. |
|
Merged via squash.
|
* fix(ui): disambiguate multi-account session labels Parse the optional account segment on per-account-channel-peer DM and group keys so Control UI no longer falls through to the raw routing key. Append a non-default account as " · accountId" on label, displayName, and fallback so two Alice rows from different Telegram accounts stay distinguishable. Signed-off-by: Sebastien Tardif <[email protected]> * fix(ui): take the session account from the gateway row The display resolver was reading the account out of the session key and inferring it from label text. That missed the shipped `dm` spelling of direct keys, invented an account-qualified group shape no key builder emits, and treated any name ending in "(<account>)" as already disambiguated. The Gateway already projects the canonical `accountId` onto every session row from the delivery route, so display consumes that and parses the key only for panes rendered before their row arrives. Key parsing now covers both `direct` and the pre-openclaw#11881 `dm` spelling, group keys go back to their canonical account-less shape, and the account suffix is applied at a single point instead of five. `resolveChannelSessionInfo` classifies `dm` keys as channel sessions and no longer reads a peer kind sitting in the channel slot as a channel. * fix(ui): stop inferring session identity from rendered text Three related text-inference defects in the same display neighborhood: The account suffix was skipped when the resolved name already ended in " · <account>". That reads rendered output as if it were a fact, and it cannot tell an account apart from a user label that happens to look like one. The suffix is now appended from the recorded account alone. The string it was defending against came from the sidebar rename dialog, which pre-filled with the resolved display name. Submitting persisted a derived string as a real user label, which then outranked every later derivation. Sidebar rows now carry the stored label alongside the resolved one, and rename edits that, matching the Sessions page. Channel classification accepted an account segment before any peer kind, so `agent:<x>:<channel>:<account>:group:<id>` was filed under a channel even though accounts qualify direct chats only and the canonical route parser rejects the shape. The grammar now allows an account only before `direct`/`dm`. Resolver tests now prove the row projection is authoritative rather than duplicating an account the key already carries: one case where only the projection supplies it, and one where the two disagree. * ci: retrigger after check-lint shard cancel Signed-off-by: Sebastien Tardif <[email protected]> * test(ui): prove rename opens on the stored label The existing sidebar rename coverage uses a row that already has a stored label, so it passes whether rename pre-fills the stored label or the resolved display name. It could not catch the round-trip this branch repaired. Adds a browser case on a displayName-only row with a projected account: the sidebar shows "Alice · cards" and the rename field opens blank. On the parent commit the field opens holding "Alice · cards", which is the string that used to become a real user label on submit. * fix(ui): do not double-append a stored account suffix A persisted label that already ends in " · accountId" must stay as-is so "Alice · cards" does not become "Alice · cards · cards". Signed-off-by: Sebastien Tardif <[email protected]> * docs(ui): name the producer the account suffix check defends The comment above withAccountDisambiguator claimed the rendered name is never inspected, which the suffix check contradicts. State the real contract instead: the account itself still comes only from the recorded value, and the endsWith check is idempotence against the chat pane's inline rename, which seeds its input with the rendered title and persists a partial edit verbatim. --------- Signed-off-by: Sebastien Tardif <[email protected]> Co-authored-by: vyctorbrzezowski <[email protected]>
What Problem This Solves
With more than one account on a channel, session keys namespace the account
(
agent:main:telegram:direct:<chatId>vsagent:main:telegram:cards:direct:<chatId>).The Control UI display resolver only understood the account-less shape, so the
cardssession fell through to a raw key (
telegram:cards:direct:42) while the default sessionrendered as
Telegram · 42. When both rows already carried a GatewaydisplayNamesuchas
Alice, the two rows were indistinguishable in the sidebar.The same resolver had a second gap: session keys written before #11881 spell direct chats
dm. The canonical parser still accepts both spellings (src/sessions/session-key-utils.ts),but the display resolver recognized neither the
dmshape nor its account segment, sothose rows leaked their raw key and were dropped from the sidebar's channel sections.
Addresses the session-label portion of #123112. That issue also reports that outbound
sends through a non-default account leave the target session's history empty. This change
does not implement or test that path, so the issue stays open.
Why This Change Was Made
Display should not have to recover the account from the key. The Gateway already parses
the canonical delivery route and records
accountIdon every session row(
src/gateway/session-classification.ts,packages/gateway-protocol/src/schema/sessions-row.ts).The resolver now consumes that recorded fact and parses the key only as a fallback, for
panes rendered before their row arrives. The account suffix is applied at one point rather
than on each naming branch, so a future branch cannot silently skip it.
Which account to show is taken from the recorded value alone — never read out of the
rendered name, and never out of a
(<accountId>)in a label — so a user label that happensto read like an account cannot suppress or fake the discriminator. The rendered name is
consulted for exactly one thing: whether the suffix is already on the end.
That check is idempotence rather than inference, and it earns its place because the chat
pane's inline title rename is a live producer of suffixed labels.
beginHeaderRenameseedsits input with
customLabel ?? paneTitle, andpaneTitleis the resolved display name,which this PR teaches to carry the account.
commitHeaderRenameskips the write only whenthe derived title comes back completely untouched, so a partial edit persists verbatim:
opening the rename on an unlabeled
cardssession and typing a word in front ofAlice · cardsstoresVIP Alice · cards. Appending unconditionally would then renderVIP Alice · cards · cards.The sidebar dialog is no longer such a producer. It pre-filled with the resolved display
name, so submitting it persisted a derived string as a real user label, which then
outranked every later derivation. Sidebar rows now carry the stored label alongside the
resolved one and rename edits that, matching what the Sessions page already did.
Follow-up, not fixed here: an editable field should be seeded from the stored label, or at
most from the undecorated name, so presentation never becomes persisted data. Fixing it in
the chat pane changes a deliberate affordance from #121452 and wants its own discussion, so
this PR keeps the idempotence check and leaves the producer alone.
Key grammar is held to shapes producers actually emit.
buildAgentPeerSessionKeyscopesaccounts to direct sessions only (
src/routing/session-key.ts), so an account segment isaccepted only before
direct/dm. Both display and channel classification enforce that;previously
agent:<agent>:<channel>:<account>:group:<id>was filed under a channel eventhough the canonical route parser rejects it.
User Impact
Sidebar rows, command palette entries, chat pane titles, recent chats, and dashboard rows
show the account for any session on a non-default account:
Alicefor the default account,Alice · cardsfor thecardsaccount. Thedefaultaccount adds no suffix andaccount-less keys are unchanged. Sessions whose keys still use the pre-#11881
dmspellingstop leaking their raw key and are grouped under their channel again.
Evidence
Control UI sidebar, isolated Gateway fixture, real Control UI under Playwright Chromium.
Two Telegram direct chats that both resolve to the name
Alice:agent:main:telegram:direct:42rendersAliceagent:main:telegram:cards:direct:42rendersAlice · cardsThe browser fixture now builds ordinary Gateway rows: an origin-derived
displayName, nouser label, and the
accountIdthe Gateway projects from the canonical route. Without bothtraits the scenario would exercise the label-precedence branch instead of the shipped one.
Resolver regressions in
ui/src/lib/session-display.test.ts:direct,displayName: AliceAlicedirect,accountId: cards,displayName: AliceAlice · cardsdm,accountId: cards,displayName: AliceAlice · cardsdmTelegram · …567890 · cardsaccountId: defaultaccountId: work, labelAlice (work)Alice (work) · workaccountId: cards, labelAlice · cardsAlice · cards, not doubledTelegram Group, unchangedagent:main:dm:account:group:roomaccountId: cardson the row onlyAlice · cardscards, row saysopsAlice · ops, the projection winsresolveChannelSessionInfoon admkeytelegramresolveChannelSessionInfoon<channel>:<account>:group:<id>Commands:
Prior attempt #123186 parsed the key into the unnamed fallback only and closed unmerged:
named
displayNamerows still collided. Surface: production +81/-32 across four files(net +49), of which 34 added lines are comments and 14 are an unchanged block re-indented
into a helper; tests +213/-1.
Related:
per-account-channel-peerind499b148423dmtodirectrename: refactor: unify peer kind to ChatType, rename dm to direct #11881