fix(cli): address codex review for background-agent UI

- AgentChatContent now owns the InteractiveAgent reads (status,
  shellPids, executionStartTimes) and the embedded-shell focus state.
  Previously AgentChatView snapshotted these at render and passed them
  down, but only AgentChatContent subscribed to agent events, so the
  spinner and Ctrl+F shell focus could stick on stale values until an
  unrelated ancestor re-rendered.
- AgentTabBar and InputPrompt now gate the Down-arrow handoff to the
  background-tasks pill on running entries, not total entries. The
  pill only renders for running tasks; focusing it from an agent tab
  after all tasks had terminated left focus on an invisible surface.
- BackgroundTasksDialog's list mode now windows entries around the
  selected index with "+N more above/below" affordances, so long
  registries stay navigable and the hint footer isn't pushed off-screen.
This commit is contained in:
tanzhenxin 2026-04-22 23:19:45 +08:00
parent efa009dec1
commit 5b13645a40
5 changed files with 119 additions and 101 deletions

View file

@ -135,7 +135,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
} = useBackgroundAgentViewState();
const { setPillFocused: setBgPillFocused } = useBackgroundAgentViewActions();
const hasAgents = agents.size > 0;
const hasBgAgents = bgEntries.length > 0;
const hasRunningBgAgents = bgEntries.some((e) => e.status === 'running');
const [justNavigatedHistory, setJustNavigatedHistory] = useState(false);
const [escPressCount, setEscPressCount] = useState(0);
const [showEscapePrompt, setShowEscapePrompt] = useState(false);
@ -928,7 +928,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
setAgentTabBarFocused(true);
return true;
}
if (hasBgAgents) {
if (hasRunningBgAgents) {
setBgPillFocused(true);
return true;
}
@ -1098,7 +1098,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
bgDialogOpen,
bgPillFocused,
hasAgents,
hasBgAgents,
hasRunningBgAgents,
setAgentTabBarFocused,
setBgPillFocused,
followup,