Skip to content

fix(ui): surface non-default account in channel session labels (#123112) - #123186

Closed
licheer-zte wants to merge 2 commits into
openclaw:mainfrom
licheer-zte:fix/telegram-session-label-123112
Closed

licheer-zte wants to merge 2 commits into
openclaw:mainfrom
licheer-zte:fix/telegram-session-label-123112

Conversation

@licheer-zte

@licheer-zte licheer-zte commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

With channels.telegram.accounts.<default, cards> configured, the default-account DM session key is agent:main:telegram:direct:<chatId> while a session reached through the cards account is agent:main:telegram:cards:direct:<chatId>. The Control UI's session display only understands the account-less shape, so the account-qualified key falls through parseSessionKey to the raw-key fallback and renders the full routing key (telegram:cards:direct:42) instead of a friendly label — while the default-account session renders Telegram · 42. Multi-account sessions are indistinguishable at a glance in the sidebar/session list, and the raw key structure leaks into the UI (exactly what the shortenPeerId design is meant to prevent). The same fall-through affects account-qualified group keys (agent:main:telegram:cards:group:<id>).

Why

ui/src/lib/session-display.ts parseSessionKey matches direct DMs with /^agent:[^:]+:([^:]+):direct:(.+)$/ and groups with /^agent:[^:]+:([^:]+):group:(.+)$/. The per-account-channel-peer DM scope (used for non-default accounts) inserts a normalized account segment between channel and kind: agent:<agent>:<channel>:<accountId>:direct:<peerId> (src/routing/session-key.ts:238-242). Neither regex accepts the optional account segment, so those keys skip the friendly direct/group branches entirely and fall through to the generic agent:<x>: branch (session-display.ts:191-195), which returns the raw remainder of the key. The channel grouping regex (CHANNEL_SESSION_KEY_RE) already tolerates the optional account segment — only the label path is broken.

User Impact

  • Non-default-account Telegram (and any other channel) sessions now render as Telegram (cards) · 42 instead of the raw telegram:cards:direct:42, so sidebar/session-list rows are distinguishable at a glance and opaque routing keys stay out of the UI.
  • The account id is surfaced only when it is not the default account; account-less keys and explicit :default: segments render exactly as before (Telegram · 42), so default setups see zero change.
  • Group sessions get the same treatment (Telegram (cards) Group); account-less groups are unchanged.
  • Behavior is limited to the display fallback path — labels, displayNames and derived titles set by the gateway still take precedence unchanged.

Evidence

Pre-fix behavior, captured on main with the account-qualified key (raw key leaks; default session gets the friendly label):

default: "Telegram · 42"
cards: "telegram:cards:direct:42"
cards channel info: {"channel":"telegram","channelSession":true}

Post-fix regression tests (ui/src/lib/session-display.test.ts, includes new cases for DM/group account labels, :default: suppression, and peer-id shortening with an account):

✓  unit  src/lib/session-display.test.ts (17 tests) 13ms
 Test Files  1 passed (1)
      Tests  17 passed (17)

Related grouping suite unaffected:

Test Files  1 passed (1)
      Tests  26 passed (26)

UI typecheck clean:

$ pnpm tsgo:ui
EXIT=0 (0 "error TS" lines)

[AI-assisted] Implementation and evidence generated with agent tooling.

@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 13, 2026
@SebTardif

Copy link
Copy Markdown
Contributor

@licheer-zte Nice catch on the multi-account key shape. The fallback path fix looks right, and suppressing the literal default account keeps single-bot installs unchanged.

One gap relative to the issue report: once the gateway supplies a shared peer displayName / origin label (very common for the same human chat on two bots), resolveSessionDisplayName still returns that name alone, so both sessions can still collide as Alice in the sidebar. Your PR body calls this out as intentional precedence, but issue #123112 is specifically about multi-account rows that are hard to tell apart at a glance, and that case still fails when titles exist.

Suggested small follow-up in the same file:

  1. Have parseSessionKey return the non-default accountId (when present).
  2. After resolving label / displayName / derivedTitle, append · ${accountId} when the account is non-default and the name does not already contain it.

Sketch:

const withAccountDisambiguator = (rawName: string): string => {
  if (!accountId) return rawName;
  if (rawName.toLowerCase().includes(accountId.toLowerCase())) return rawName;
  return `${rawName} · ${accountId}`;
};

// on label / displayName / derivedTitle returns:
return withAccountDisambiguator(applyTypedPrefix(name));
// fallbackName can keep building the account into the string as you already do

Regression cases worth adding:

expect(
  resolveSessionDisplayName("agent:main:telegram:cards:direct:42", {
    displayName: "Alice",
  }),
).toBe("Alice · cards");

expect(
  resolveSessionDisplayName("agent:main:telegram:direct:42", {
    displayName: "Alice",
  }),
).toBe("Alice");

expect(
  resolveSessionDisplayName("agent:main:telegram:cards:direct:42", {
    displayName: "Alice · cards",
  }),
).toBe("Alice · cards"); // no double-append

Also, CI PR context and evidence is red on this head. OpenClaw's context gate wants the exact headings ## What Problem This Solves and ## Evidence (not ## What Problem). Renaming that section usually clears the check without a code change.

Happy to leave the implementation to you; thanks for landing the key-parse fix quickly.

@licheer-zte
licheer-zte force-pushed the fix/telegram-session-label-123112 branch from 51c4001 to ba32195 Compare August 13, 2026 12:39
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 13, 2026
@licheer-zte licheer-zte reopened this Aug 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 13, 2026
@clawsweeper

clawsweeper Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 15, 2026, 2:53 AM ET / 06:53 UTC.

ClawSweeper review

What this changes

The PR makes fallback labels for account-qualified direct and group session keys include a non-default account identifier.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 6 items remain

Keep open: the fallback-label repair is useful, but named sessions still discard the non-default account and can remain indistinguishable; the prior P1 finding is unchanged. The PR also needs real Control UI proof before merge.

Priority: P2
Reviewed head: ed9c02e5e64fc4e968795c3060f1c3bb585d38da

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has a clear partial repair, but an unchanged P1 behavior gap and mock-only proof keep it from merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The body shows focused unit-test and typecheck output, but no after-fix running Control UI evidence; add a redacted sidebar or session-list screenshot/video showing default and non-default accounts. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The body shows focused unit-test and typecheck output, but no after-fix running Control UI evidence; add a redacted sidebar or session-list screenshot/video showing default and non-default accounts. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Canonical key producer: The routing owner inserts accountId only for per-account direct-message keys, establishing the account-qualified key shape the UI must interpret.
Named labels bypass the fix: On the PR head, the account suffix is confined to fallbackName, while label and displayName return before fallbackName is used; named rows therefore still omit the account.
Regression coverage gap: The added tests exercise only unnamed fallback labels and do not cover label, displayName, or derivedTitle for a non-default account.
Findings 1 actionable finding [P1] Disambiguate gateway-provided session names too
Security None None.

How this fits together

Gateway routing encodes a channel account in direct-session keys, then the Control UI turns session rows into names for the sidebar, palette, and chat surfaces. Explicit gateway-provided names take precedence over fallback names.

flowchart LR
  A[Inbound channel route] --> B[Account-qualified session key]
  B --> C[Gateway session row]
  C --> D[Control UI name resolver]
  D --> E{Named field present?}
  E -->|Yes| F[Sidebar and palette label]
  E -->|No| G[Account-aware fallback label]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The body shows focused unit-test and typecheck output, but no after-fix running Control UI evidence; add a redacted sidebar or session-list screenshot/video showing default and non-default accounts. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Disambiguate gateway-provided session names too (P1) - The account suffix only exists in fallbackName, but label and displayName return first. Thus two account-qualified rows with the same gateway name, such as Alice, still collide—the reported multi-account UI failure. Carry the parsed non-default account into those precedence paths and add regressions.
  • Resolve merge risk (P1) - Merging leaves account-qualified sessions with gateway label, displayName, or derivedTitle values indistinguishable, which is the common session-row path.
  • Resolve merge risk (P1) - The added group-account parsing has no matching current producer evidence; current routing adds the account segment only for direct peers.
  • Resolve merge risk (P1) - The PR body supplies unit-test and typecheck output, but no after-fix Control UI evidence of the visible label change.
  • Complete next step (P2) - A focused resolver repair can address the remaining named-label collision, while the contributor separately supplies real Control UI proof.

Findings

  • [P1] Disambiguate gateway-provided session names too — ui/src/lib/session-display.ts:169
Agent review details

Security

None.

PR surface

Source +12, Tests +30. Total +42 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 20 8 +12
Tests 1 30 0 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 50 8 +42

Review metrics

Metric Value Why it matters
Production versus tests production +12 (20 added, 8 removed); tests +30 The direct fallback repair justifies some source growth, but the added group-account branch lacks a matching current producer and named-label handling remains incomplete.

Stored data model

Persistent data-model change detected: serialized state: ui/src/lib/session-display.test.ts, unknown-data-model-change: ui/src/lib/session-display.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #123112
Summary: This PR is a candidate repair for the session-label portion of the canonical report; the canonical issue also tracks a distinct empty-history behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Preserve account identity for named sessions (recommended)
    Return the non-default account from parsing, apply it idempotently to named display paths, and prove the resulting sidebar label before merge.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Carry the parsed non-default account through named session-label precedence paths, append it exactly once while preserving default-account output, add focused regressions, and attach sanitized before/after Control UI proof.

Technical review

Best possible solution:

Carry the parsed non-default account through the resolver and append it exactly once to every named precedence path, retain default-account output, remove or source-prove the group form, and attach sanitized before/after Control UI proof.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: resolving an account-qualified key with displayName: "Alice" returns Alice because named fields bypass the account-bearing fallback. A focused resolver regression test can reproduce it without channel credentials.

Is this the best way to solve the issue?

No. The fallback regex is the right owner surface, but it does not carry account identity into the higher-precedence names users normally see.

Full review comments:

  • [P1] Disambiguate gateway-provided session names too — ui/src/lib/session-display.ts:169
    The account suffix only exists in fallbackName, but label and displayName return first. Thus two account-qualified rows with the same gateway name, such as Alice, still collide—the reported multi-account UI failure. Carry the parsed non-default account into those precedence paths and add regressions.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7bb3909e4b5a.

Labels

Label justifications:

  • P2: This is a bounded Control UI session-label defect affecting multi-account operators without breaking message delivery.
  • merge-risk: 🚨 other: The patch can merge while leaving gateway-named non-default-account sessions visually ambiguous, despite claiming to resolve account disambiguation.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body shows focused unit-test and typecheck output, but no after-fix running Control UI evidence; add a redacted sidebar or session-list screenshot/video showing default and non-default accounts. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs ui/src/lib/session-display.test.ts.
  • [P1] pnpm tsgo:ui.
  • [P1] Capture sanitized before/after Control UI session-list proof for default and non-default accounts.

What I checked:

  • Canonical key producer: The routing owner inserts accountId only for per-account direct-message keys, establishing the account-qualified key shape the UI must interpret. (src/routing/session-key.ts:238, 7bb3909e4b5a)
  • Named labels bypass the fix: On the PR head, the account suffix is confined to fallbackName, while label and displayName return before fallbackName is used; named rows therefore still omit the account. (ui/src/lib/session-display.ts:241, ed9c02e5e64f)
  • Regression coverage gap: The added tests exercise only unnamed fallback labels and do not cover label, displayName, or derivedTitle for a non-default account. (ui/src/lib/session-display.test.ts:41, ed9c02e5e64f)
  • Prior finding remains on this head: The prior ClawSweeper review requested carrying account identity into named labels; the current head is the same reviewed code revision for this file. (ui/src/lib/session-display.ts:241, ed9c02e5e64f)
  • Current-area provenance: Current-main blame attributes the display resolver and session-key producer lines to the recent area snapshot; history available in this checkout is otherwise limited for these paths. (ui/src/lib/session-display.ts:229, a32a7ae9af96)

Likely related people:

  • steipete: Current-main blame on the session display resolver and session-key producer points to Peter Steinberger's recent area snapshot. (role: recent current-main area contributor; confidence: medium; commits: a32a7ae9af96; files: ui/src/lib/session-display.ts, src/routing/session-key.ts)
  • SebTardif: Reviewed the concrete named-label collision and supplied the required precedence-path regression cases. (role: reviewer; confidence: high; files: ui/src/lib/session-display.ts, ui/src/lib/session-display.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Apply account disambiguation to label, displayName, and derivedTitle precedence paths with focused regressions.
  • Add sanitized before/after Control UI proof; updating the PR body should trigger a fresh review, or a maintainer can comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-13T14:06:23.502Z sha ed9c02e :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T04:24:43.227Z sha ed9c02e :: needs real behavior proof before merge. :: [P1] Carry account identity into named labels

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(ui): surface non-default account in channel session labels (#123112) This is item 1/1 in the current shard. Shard 17/22.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@licheer-zte

Copy link
Copy Markdown
Contributor Author

按合入模式(2026-08-10 定稿)关闭:ClawSweeper 最新 review(2026-08-15,head ed9c02e)评级 🦪 silver shellfish (2/6),1 个 actionable finding 未修 + 未变的 P1 行为缺口,blocker 是真实 Control UI 运行截图/录像。本环境无法产出 UI 运行证据,关闭释放产能。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants