feat(desktop): show each agent's latest tool call in the sidebar agents card

KI
2mo ago
+1111-25

What

The sidebar agents hover card gains one line per agent: the agent's latest tool call, e.g. Edit · src/a.ts · 3s ago, Run · bun test · 40s ago. Before, the card only showed the coarse status word.

How

  • Hook script (notify-hook.template.sh, marker bumped to v10): for Claude-schema agents, extracts tool_name and the first of file_path / command / pattern / url / description from tool_input, unescapes, strips control chars, caps at 400 chars, and sends it as activity: { tool, detail }. Events without a tool send no activity.
  • Host (notifications.hook → TerminalAgentStore): normalizes the activity (worktree root and home dir shortened, display caps), and keeps it in an in-memory map beside the bindings, overlaid on every read path. A bare Start clears it; Stop / Failed / PermissionRequest keep it; session change or binding end drops it. Never persisted.
  • Desktop: DashboardSidebarAgentHoverRow renders the line with a coarse verb (Edit / Read / Run / Search / Fetch / Subagent, raw tool name otherwise) and a ticking compact relative time that stays visible when the detail truncates.

Scope

First of three PRs from the activity-line spec. Not in this PR: automation run outcomes, mobile rows, and PreToolUse (which would make the line "doing" rather than "last did" at the cost of an extra blocking hook per tool call).

Note: the agents chip only renders when a workspace has two or more live agents (existing behavior in DashboardSidebarWorkspaceChips), so a single-agent workspace never shows this line today. Worth revisiting in the next PR.

Verification

  • bun test in host-service (store + router) and agent-setup (hook script against a fake host), plus the new desktop unit test.
  • Typecheck passes for host-service, agent-setup, and desktop.
  • End-to-end over CDP against the dev app from this branch (renderer :4845, dev host-service): launched three Claude sessions in this worktree's workspace through agents.run, each prompted to use one tool. The real v10 hook posted activity to the dev host, the binding carried it (Run · ls packages, Read · packages/i18n/README.md, Run · bun --version mid-turn with status Working), and hovering the agents chip with real mouse input showed the lines with elapsed time. Screenshots captured; zero renderer exceptions.

https://claude.ai/code/session_01M2Z9wLHVRNWM31CjWbAK9H

Summary by CodeRabbit

  • New Features

    • Dashboard sidebar agent hover rows now display the agent’s latest activity, including localized action labels, relevant details, and elapsed time.
    • Activity details update automatically while the hover row remains open.
    • Tool activity is captured and shown for supported agent actions, with readable file paths, commands, searches, and URLs.
  • Bug Fixes

    • Improved formatting and truncation keep activity details readable without disrupting the sidebar layout.