fix(cli): keep terminal background agents reachable from the dialog

The view hook used to filter the registry snapshot to running entries
only, so once the last background agent finished the pill disappeared
and the dialog became unreachable — final stats, prompt, and errors
were stranded for the rest of the session even though the registry
still held them. Expose every entry from the hook and let surfaces
that only care about live work do their own filtering. The pill stays
mounted whenever any entry exists and switches to a quieter "done"
label after the last agent terminates, so users can still open the
dialog to inspect final state.
This commit is contained in:
愚远 2026-04-26 14:12:31 +08:00
parent 36cb2e2dab
commit 40a8d27163
6 changed files with 67 additions and 40 deletions

View file

@ -135,7 +135,9 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
} = useBackgroundAgentViewState();
const { setPillFocused: setBgPillFocused } = useBackgroundAgentViewActions();
const hasAgents = agents.size > 0;
const hasRunningBgAgents = bgEntries.some((e) => e.status === 'running');
// Includes terminal entries — the pill stays open so users can reopen
// the dialog to inspect final state after the last agent finishes.
const hasBgAgents = bgEntries.length > 0;
const [justNavigatedHistory, setJustNavigatedHistory] = useState(false);
const [escPressCount, setEscPressCount] = useState(0);
const [showEscapePrompt, setShowEscapePrompt] = useState(false);
@ -947,7 +949,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
setAgentTabBarFocused(true);
return true;
}
if (hasRunningBgAgents) {
if (hasBgAgents) {
setBgPillFocused(true);
return true;
}
@ -1117,7 +1119,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
bgDialogOpen,
bgPillFocused,
hasAgents,
hasRunningBgAgents,
hasBgAgents,
setAgentTabBarFocused,
setBgPillFocused,
followup,