Skip to content

feat: use Claude session name for the agent label - #367

Open
neruad wants to merge 1 commit into
pixel-agents-hq:mainfrom
neruad:feat/session-name-label
Open

feat: use Claude session name for the agent label#367
neruad wants to merge 1 commit into
pixel-agents-hq:mainfrom
neruad:feat/session-name-label

Conversation

@neruad

@neruad neruad commented Jul 28, 2026

Copy link
Copy Markdown

Description

The agent label's secondary line now shows the Claude session name (e.g. pixel-agents-1a) when it can be resolved, falling back to the workspace folder name as before.

folderName is deliberately left intact: it also keys the Areas folder→seat mapping (findFreeSeat / areaMappings), so it can't be overloaded with the session name. A separate sessionName field carries the title.

How it works

  • Session names come from Claude's per-session registry ~/.claude/sessions/<pid>.json ({ sessionId, name, ... }), read via a new optional HookProvider.getSessionName(sessionId). All Claude specifics stay behind the provider boundary; a short-lived cache reuses one directory scan across agents.
  • AgentRuntime re-resolves names on a periodic timer (a few seconds) and broadcasts a new agentSessionNameChanged message, so sessions that get named after they start — and live /rename — surface without a reload. Teammates are skipped (they share the lead's session id).
  • The label prefers sessionName over folderName in ToolOverlay.

Type of change

  • New feature (non-breaking change which adds functionality)

The protocol change is additive/optional (new message + optional fields), so existing clients keep working.

Protocol contract

core/asyncapi.yaml (single source of truth) gains:

  • new agentSessionNameChanged ServerMessage,
  • optional sessionName on AgentCreated,
  • optional sessionNames map on ExistingAgents.

core/src/messages.ts is regenerated from the contract (npm run asyncapi:generate); the CI drift check passes.

Screenshots / GIFs

No screenshot attached — the change is a text swap on the existing overlay's secondary line (session name in place of folder name); no new UI surface or layout change. Verified by manual smoke in the Extension Development Host.

Test plan

  • npm run check-types — clean
  • npm run lint — clean (only the pre-existing App.tsx exhaustive-deps warning)
  • npm run test:server — 280/280
  • npm run test:webview — 41/41
  • Manual (F5 Extension Development Host): spawned an agent, set a session name via /rename, watched the label update live to the session name; with no name it falls back to the folder name.

E2E coverage

Added e2e/tests/claude/hooks-on/labels.spec.ts (@area:labels): seeds the session registry for a spawned agent's real session id and asserts the character's resolved sessionName via the getAgentSeats test hook. New area documented in e2e/README.md ("What this suite covers" + regenerated inventory) and mapped in helpers/allure-labels.ts.

Note: the local VS Code Electron e2e harness would not launch on my machine (a known-good existing spec fails identically at the fixture launch step), so the new spec was verified statically — it mirrors the accepted getAgentSeats/cast pattern used by the Areas specs — and will run in CI across Linux/macOS/Windows.

🤖 Generated with Claude Code

The agent label's secondary line now shows the Claude session name (e.g.
"pixel-agents-1a") when it can be resolved, falling back to the workspace
folder name as before. folderName is left intact because it also keys the
Areas folder->seat mapping and must not be overloaded.

Resolution reads Claude's per-session registry
(~/.claude/sessions/<pid>.json -> { sessionId, name }) via a new optional
HookProvider.getSessionName, kept behind the provider boundary. The runtime
re-resolves every few seconds and broadcasts a new agentSessionNameChanged
message so late-named sessions and live renames surface without a reload;
teammates are skipped since they share the lead's session id.

Protocol (core/asyncapi.yaml): new agentSessionNameChanged ServerMessage,
optional sessionName on AgentCreated, and a sessionNames map on
ExistingAgents. messages.ts is regenerated from the contract.

Tests: server unit tests for the refresh/broadcast (including the teammate
skip); an e2e spec seeding the session registry and asserting the label
resolves via the getAgentSeats hook.
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.

2 participants