fix(dashboard/sessions): show the correct Hand agent name in the sessions view (#6156)#6162
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
The sessions view rendered each row's agent name by looking up the session's
agent_idin the result ofuseAgents().useAgents()callsGET /api/agents, and that endpoint excludes hand-spawned agents by default — seecrates/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_idon its row (the list handler atcrates/librefang-api/src/routes/tools_sessions.rs:391returns it verbatim), but because the hand agent was filtered out of the agent map, the lookup atcrates/librefang-api/dashboard/src/pages/SessionsPage.tsxmissed and the row fell back to thesessions.unknown_agentlabel 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 correctagent_idon each session row, so the authoritative fix is to make the sessions view request hand agents.The fix
Pass
{ includeHands: true }touseAgents()inSessionsPage.tsx(the hook already supports this option andlistAgents()already maps it toinclude_hands=true).The agent map then includes hand agents and the
agent_id -> namelookup 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
crates/librefang-api/dashboard/src/pages/SessionsPage.test.tsx(3 cases):requests the agent list with hand agents included— assertsuseAgentsis 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 atSessionsPage.tsx:42is the pre-existingconst agents = agentsQuery.data ?? []react-hooks/exhaustive-depspattern shared by SkillsPage/WorkflowsPage; not introduced here).pnpm build— succeeds.pnpm test— 81 files, 797 tests pass (includes the new SessionsPage tests and the existingsessions-hands.test.tsx).pnpm test:i18n-parity— all locales in parity.Closes #6156