Skip to content

fix(dashboard/sessions): show the correct Hand agent name in the sessions view (#6156)#6162

Merged
houko merged 2 commits into
mainfrom
fix/session-hands-agent-name
Jun 17, 2026
Merged

fix(dashboard/sessions): show the correct Hand agent name in the sessions view (#6156)#6162
houko merged 2 commits into
mainfrom
fix/session-hands-agent-name

Conversation

@houko

@houko houko commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Root cause

The sessions view rendered each row's agent name by looking up the session's agent_id in the result of useAgents().

useAgents() calls GET /api/agents, and that endpoint excludes hand-spawned agents by default — see crates/librefang-api/src/routes/agents/lifecycle.rs:617-619 (if !params.include_hands.unwrap_or(false) { agents.retain(|e| !e.is_hand); }).

A session owned by a Hand agent carries that hand agent's agent_id on its row (the list handler at crates/librefang-api/src/routes/tools_sessions.rs:391 returns it verbatim), but because the hand agent was filtered out of the agent map, the lookup at crates/librefang-api/dashboard/src/pages/SessionsPage.tsx missed and the row fell back to the sessions.unknown_agent label instead of showing the Hand agent's real name.

The wrong layer was the frontend lookup: the backend already returns the hand agent (with its correct name) when asked via ?include_hands=true, and it already emits the correct agent_id on each session row, so the authoritative fix is to make the sessions view request hand agents.

The fix

Pass { includeHands: true } to useAgents() in SessionsPage.tsx (the hook already supports this option and listAgents() already maps it to include_hands=true).
The agent map then includes hand agents and the agent_id -> name lookup resolves correctly.
No backend route or payload change, so no Rust integration test is needed; no new user-visible strings, so no locale changes.

Verification

  • New crates/librefang-api/dashboard/src/pages/SessionsPage.test.tsx (3 cases):
    • requests the agent list with hand agents included — asserts useAgents is called with { includeHands: true }.
    • renders the hand agent's real name for a hand-owned session — a hand-owned session row shows the Hand agent name, not the unknown fallback.
    • falls back to the unknown-agent label when the agent is missing — regression guard for the pre-fix behaviour.
  • pnpm typecheck — clean.
  • pnpm lint — 0 errors (the one warning at SessionsPage.tsx:42 is the pre-existing const agents = agentsQuery.data ?? [] react-hooks/exhaustive-deps pattern shared by SkillsPage/WorkflowsPage; not introduced here).
  • pnpm build — succeeds.
  • pnpm test — 81 files, 797 tests pass (includes the new SessionsPage tests and the existing sessions-hands.test.tsx).
  • pnpm test:i18n-parity — all locales in parity.

Closes #6156

…ions view (#6156)

The sessions view resolved each row's display name by looking up the
session's agent_id in the result of useAgents(), but useAgents() (which
hits GET /api/agents) excludes hand-spawned agents by default. A session
owned by a Hand agent therefore missed the lookup and rendered the
'unknown agent' fallback instead of the Hand agent's real name.

Pass { includeHands: true } to useAgents() in SessionsPage so the agent
map includes hand agents and the agent_id -> name lookup succeeds. The
backend already returns the hand agent (via ?include_hands=true) with its
correct name and emits the hand agent's agent_id on each session row, so
the authoritative fix is at the frontend lookup layer.

Closes #6156
@github-actions github-actions Bot added no-rust-required This task does not require Rust knowledge size/M 50-249 lines changed labels Jun 17, 2026
@houko
houko merged commit 3c92e21 into main Jun 17, 2026
33 checks passed
@houko
houko deleted the fix/session-hands-agent-name branch June 17, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-rust-required This task does not require Rust knowledge size/M 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

会话 正确展示Hands的智能体名称

2 participants