Commit Β·
fff300b
1
Parent(s): 44be1d7
feat: beautiful research sub-agent UI with inline progress steps
Browse files- ToolCallGroup: renders research sub-steps inline below the tool row
with contextual icons (π finding examples, π reading file, π docs)
and a spinner on the active step
- ActivityStatusBar: shows current research step in the shimmer bar
("Exploring docs(trl)..." instead of generic "Running research...")
- Store: tracks researchSteps per-session, cleared on each new research call
- useAgentChat: routes research tool_log events to both the step list
and activity status
Files changed (4)
16 unmodified lines1718192021222316 unmodified lines hf_inspect_dataset: 'Inspecting dataset', hf_search: 'Searching', plan_tool: 'Planning', research: 'Researching',};
function statusLabel(status: ActivityStatus): string {30 unmodified lines313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104290 unmodified lines39539639739839940040140240340434 unmodified lines439440441442443444445446447448449450331 unmodified lines78278378478578678778878979079179279379430 unmodified lines approveTools: (approvals: Array<{ tool_call_id: string; approved: boolean; feedback?: string | null; edited_script?: string | null }>) => Promise<boolean>;}
// ---------------------------------------------------------------------------// Research sub-steps (inline under the research tool row)// ---------------------------------------------------------------------------
/** Pretty labels for research sub-agent tool calls */function formatResearchStep(step: string): { icon: string; label: string } { if (step === 'Starting research sub-agent...') return { icon: 'π', label: 'Starting research' }; if (step === 'Research complete.') return { icon: 'β', label: 'Research complete' }; if (step.startsWith('github_find_examples')) return { icon: 'π', label: step.replace('github_find_examples', 'Finding examples') }; if (step.startsWith('github_read_file')) { const path = step.match(/\(([^)]+)\)/)?.[1] || ''; const filename = path.split('/').pop() || path; return { icon: 'π', label: `Reading ${filename}` }; } if (step.startsWith('explore_hf_docs')) return { icon: 'π', label: step.replace('explore_hf_docs', 'Exploring docs') }; if (step.startsWith('fetch_hf_docs')) return { icon: 'π', label: step.replace('fetch_hf_docs', 'Fetching docs') }; if (step.startsWith('hf_inspect_dataset')) return { icon: 'ποΈ', label: step.replace('hf_inspect_dataset', 'Inspecting dataset') }; if (step.startsWith('hf_papers')) return { icon: 'π', label: 'Searching papers' }; if (step.startsWith('find_hf_api')) return { icon: 'π', label: 'Finding API endpoints' }; if (step.startsWith('hf_repo_files')) return { icon: 'π', label: 'Reading repo files' }; return { icon: 'β', label: step };}
function ResearchSteps({ steps, isRunning }: { steps: string[]; isRunning: boolean }) { // Filter out the "Starting..." and "complete" meta-steps for the list const toolSteps = steps.filter( s => s !== 'Starting research sub-agent...' && s !== 'Research complete.', ); if (toolSteps.length === 0) return null;
return ( <Box sx={{ pl: 4.5, pr: 1.5, pb: 1, pt: 0.25 }}> {toolSteps.map((step, i) => { const { icon, label } = formatResearchStep(step); const isLast = i === toolSteps.length - 1; return ( <Stack key={i} direction="row" alignItems="center" spacing={0.75} sx={{ py: 0.2 }} > <Typography sx={{ fontSize: '0.65rem', lineHeight: 1, width: 14, textAlign: 'center', flexShrink: 0 }}> {isLast && isRunning ? '' : icon} </Typography> {isLast && isRunning && ( <CircularProgress size={10} thickness={5} sx={{ color: 'var(--accent-yellow)', flexShrink: 0 }} /> )} <Typography sx={{ fontFamily: '"JetBrains Mono", ui-monospace, SFMono-Regular, monospace', fontSize: '0.68rem', color: isLast && isRunning ? 'var(--text)' : 'var(--muted-text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', }} > {label} </Typography> </Stack> ); })} </Box> );}
// ---------------------------------------------------------------------------// Hardware pricing ($/hr) β from HF Spaces & Jobs pricing// ---------------------------------------------------------------------------290 unmodified lines
export default function ToolCallGroup({ tools, approveTools }: ToolCallGroupProps) { const { setPanel, lockPanel, getJobUrl, getEditedScript } = useAgentStore(); const researchSteps = useAgentStore(s => { const activeId = s.activeSessionId; return activeId ? (s.sessionStates[activeId]?.researchSteps ?? []) : []; }); const { setRightPanelOpen, setLeftSidebarOpen } = useLayoutStore();
// ββ Batch approval state ββββββββββββββββββββββββββββββββββββββββββ34 unmodified lines displayMap[id] = 'hf_jobs'; } } // Pretty name for research tool for (const t of tools) { if (t.toolName === 'research') { displayMap[t.toolCallId] = 'research'; } } return { scriptLabelMap: scriptMap, toolDisplayMap: displayMap }; }, [tools]);
331 unmodified lines )} </Stack>
{/* Research sub-agent steps */} {tool.toolName === 'research' && researchSteps.length > 0 && ( <ResearchSteps steps={researchSteps} isRunning={state === 'input-streaming' || state === 'input-available'} /> )}
{/* Per-tool approval: undecided */} {isPending && !localDecision && !isSubmitting && (85 unmodified lines8687888990919293949596979899100101102129 unmodified lines23223323422423523623723823924024124224385 unmodified lines } }, onToolLog: (tool: string, log: string) => { // Research sub-agent: accumulate steps + update activity status if (tool === 'research') { const sessState = useAgentStore.getState().getSessionState(sessionId); const steps = [...sessState.researchSteps, log]; updateSession(sessionId, { researchSteps: steps, activityStatus: { type: 'tool', toolName: 'research', description: log }, }); return; }
const STREAMABLE_TOOLS = new Set(['hf_jobs', 'sandbox', 'bash']); if (!STREAMABLE_TOOLS.has(tool)) return;
129 unmodified lines updateSession(sessionId, { activityStatus: { type: 'streaming' } }); }, onToolRunning: (toolName: string, description?: string) => { updateSession(sessionId, { activityStatus: { type: 'tool', toolName, description } }); const updates: Partial<import('@/store/agentStore').PerSessionState> = { activityStatus: { type: 'tool', toolName, description }, }; // Clear research steps when a new research call starts if (toolName === 'research') updates.researchSteps = []; updateSession(sessionId, updates); }, onInterrupted: () => { /* no-op β handled by stop() caller */ }, }),59 unmodified lines60616263646566673 unmodified lines71727374757677158 unmodified lines23623723823924024124259 unmodified lines panelView: PanelView; panelEditable: boolean; plan: PlanItem[]; /** Steps completed by the research sub-agent (tool_log events). */ researchSteps: string[];}
const defaultSessionState: PerSessionState = {3 unmodified lines panelView: 'script', panelEditable: false, plan: [], researchSteps: [],};
interface AgentStore {158 unmodified lines panelView: state.panelView, panelEditable: state.panelEditable, plan: state.plan, researchSteps: state.sessionStates[state.activeSessionId]?.researchSteps ?? [], }; }
frontend/src/components/Chat/ActivityStatusBar.tsx+1
frontend/src/components/Chat/ToolCallGroup.tsx+85
frontend/src/hooks/useAgentChat.ts+17-1
frontend/src/store/agentStore.ts+4