Skip to content

feat(ui): show sessions_spawn label instead of agentId#28

Draft
JimmyBlanquet wants to merge 1 commit intoWW-AI-Lab:mainfrom
JimmyBlanquet:feature/show-spawn-labels
Draft

feat(ui): show sessions_spawn label instead of agentId#28
JimmyBlanquet wants to merge 1 commit intoWW-AI-Lab:mainfrom
JimmyBlanquet:feature/show-spawn-labels

Conversation

@JimmyBlanquet
Copy link
Copy Markdown

Summary

Make the UI prefer the human-readable label field passed via sessions_spawn over the technical agentId / sessionKey UUID. Falls back gracefully if label is missing.

The OpenClaw gateway already accepts and stores a label field in sessions_spawn (e.g. "Analyste de portefeuille") and exposes it via sessions.list. The UI was reading it in chat-dock-store.normalizeSession and on the chat page list, but a few prominent UI surfaces still showed only the technical session key. This made multi-agent demos hard to follow because every spawned session appeared as agent:main:subagent:5533959a-... instead of its human name.

Files changed

  • src/components/chat/SessionSwitcher.tsx — the dropdown items and the active session display name now use session.label first via a new formatSessionDisplay helper. Previously it only called formatSessionName(session.key).
  • src/components/pages/ChatPage.tsxformatSessionTitle (used in the chat page header) now accepts a sessionLabel arg and prefers it over the agent-name lookup. The single call site passes the active session's label from the sorted list.
  • src/hooks/useSubAgentPoller.ts — harden toSubAgentInfoList against empty/whitespace label values (s.label?.trim() || ...), keeping the existing fallback chain (Sub-<uuid>agentId) for backwards compatibility with the test suite.
  • src/store/office-store.ts — in processAgentEvent's two pending-sub-agent branches, use the actual agentId as the temporary label instead of Sub-<8-char slice>. The sessions.list poller still overwrites this with the real gateway label as soon as it arrives, but the visible-during-race string is now meaningful.

Behavior

  • When sessions_spawn is called with label: "Analyste de portefeuille", both the SessionSwitcher dropdown and the chat page header now display Analyste de portefeuille… (truncated at 24/32 chars) instead of subagent:5533959a-1a5e-….
  • When no label is provided, the existing behavior is preserved (agent name for agent:foo:main, formatted suffix otherwise).

Test plan

  • npm run typecheck — passes (no new TS errors)
  • npm test — 475/475 tests pass, including the existing useSubAgentPoller label fallback tests
  • npm run build — passes (vite build produces all expected chunks)
  • Manual: run with a real gateway, call sessions_spawn with a label, observe the SessionSwitcher and chat page header show the label
  • Manual: spawn without a label, observe fallback to formatted session key (no regression)

Notes

  • I did not touch src/i18n/locales/ (concurrent FR translation work in another branch).
  • The fallback chain in useSubAgentPoller was deliberately kept as label → Sub-<uuid> → agentId rather than label → agentId → Sub-<uuid> because the parent agent's agentId (e.g. "main") shouldn't be displayed as the sub-agent's identity, which an existing test (subagent-poller.test.ts:124) explicitly enforces.

🤖 Generated with Claude Code

…play

The OpenClaw gateway accepts a 'label' field in sessions_spawn
(e.g. 'Analyste de portefeuille') for human-readable session names.
Previously the UI ignored this and showed agentId or session UUID,
making multi-agent demos hard to follow.

This change makes the UI prefer the label, falling back to agentId
then sessionKey suffix if absent.

Patches:
- SessionSwitcher.tsx: use session.label for both the dropdown items
  and the active session display name (was using session.key only).
- ChatPage.tsx: formatSessionTitle now accepts a sessionLabel param
  and prefers it over the technical session key when present.
- useSubAgentPoller.ts: harden label fallback against empty/whitespace
  labels (existing UUID-based fallback retained for compatibility).
- office-store.ts: in processAgentEvent's pending sub-agent path, use
  the actual agentId as the temporary label (the sessions.list poller
  later overwrites it with the real label from the gateway).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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