Repository navigation
fix(cli): refresh agent console list after rename #374
Description
Summary
Renaming an agent from ai-devkit agent console reports success, but the agent list keeps showing the old name instead of updating immediately.
This became especially visible after the daemon event stream was added: once the console subscribes successfully, its normal 3-second poll is replaced by a 60-second fallback poll. A rename only updates the local registry and does not emit a daemon lifecycle event, so there is nothing to trigger an immediate list refresh.
Reproduction
- Start an agent and open
ai-devkit agent consolewhiledevkitdis available. - Select the agent and press
r. - Change its name and submit.
- Observe the success message and return to the preview pane.
Actual behavior
- The success message says the agent was renamed.
- The left-hand agent list continues to show the old name.
- The list may remain stale until the 60-second safety-net poll runs.
- When the refresh eventually arrives, selection can fall back because
selectedNamestill contains the old name.
Expected behavior
After a successful rename, the console should immediately refresh the agent list and keep the renamed agent selected under its new name.
Root cause
packages/cli/src/tui/console/hooks/useRenameAgentPane.ts handles a successful rename by closing the pane and showing a transient message, but it does not receive or call the console's refresh() function and does not update selection.
packages/cli/src/tui/console/hooks/useAgentList.ts changes the polling interval from LIST_POLL_INTERVAL_MS (3 seconds) to LIST_FALLBACK_INTERVAL_MS (60 seconds) after the daemon subscription succeeds. The child process used by runAction({ type: "rename" }) writes the SQLite registry directly; that registry-only mutation does not produce a daemon event.
The start-agent flow already demonstrates the intended pattern in useStartAgentPane.ts: after success it awaits refresh() and then selects the newly created agent.
This is a regression in perceived responsiveness exposed by the daemon subscription change in #352. The original rename implementation deliberately relied on the next poll, but that poll is no longer frequent when the daemon is connected.
Suggested fix
Pass refresh and a selection callback into useRenameAgentPane. On successful rename:
- Close the rename pane and show the success message.
await refresh().- Select
values.newNameso the preview remains attached to the same agent.
The order can mirror useStartAgentPane.
Acceptance criteria
- A successful console rename refreshes the visible list without waiting for a poll or daemon event.
- The renamed agent remains selected under the new name.
- A failed rename does not refresh or change selection and keeps the inline error behavior.
- Add hook/integration coverage proving
refresh()and selection happen only after a successful rename. - Behavior works both with and without an active daemon subscription.
Environment
- Branch:
main - Revision investigated:
de852a64 - Package version:
0.70.0 - Node.js:
v26.7.0 - Platform: macOS
Activity
fix(console): refresh agent list and reselect after rename
fix(console): refresh agent list and reselect after rename (#375)