ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
fix(portal): keep the activity panel calm while the agent keeps working (#8183)
Mike Bradley56c07d4c7bc1
diff --git a/ods/extensions/services/dashboard/src/components/PortalAgentActivity.jsx b/ods/extensions/services/dashboard/src/components/PortalAgentActivity.jsxindex 9b97941bb..96801288d 100644--- a/ods/extensions/services/dashboard/src/components/PortalAgentActivity.jsx+++ b/ods/extensions/services/dashboard/src/components/PortalAgentActivity.jsx@@ -1,7 +1,7 @@// Portal implementation inspired by AI CSS Thinking + Reasoning and beUI// Agent Activity. Uses real public events rather than their demo timelines.import {useEffect, useId, useLayoutEffect, useRef, useState} from 'react'-import {Check, ChevronDown, Circle, FileSearch, FilePenLine, Globe2, Terminal, AlertCircle, Layers, MessageSquare, Wrench} from 'lucide-react'+import {Check, ChevronDown, Circle, FileSearch, FilePenLine, Globe2, Terminal, Layers, MessageSquare, PauseCircle, Wrench} from 'lucide-react'import {parseTaskActivity} from '../lib/pixelTaskActivity'import {activityProgressRows} from '../lib/portalActivityProgress'import PortalActivityChange, {ActivityChangeCounts} from './PortalActivityChange'@@ -15,14 +15,25 @@ export function activityDuration(seconds) {const n=Math.max(0,Math.round(seconds))return n<60?`${n}s`:`${Math.floor(n/60)}m${n%60?` ${n%60}s`:''}`}-function ActivityRow({event,active}) {+// Receipt states are telemetry, not verdicts. A call that returned an error+// ('failed') or that Portal declined before it ran ('blocked') is ordinary+// agent work: the agent is told why and continues, so neither marks a step as+// broken. A call whose end was never recorded ('running' after the response)+// claims no result either way.+function rowState(event,active) {+ if(event.state==='running')return active?'running':'unconfirmed'+ return ['failed','blocked'].includes(event.state)?'tried':event.state+}++function ActivityRow({event,active,later}) {const [expanded,setExpanded]=useState(false)const display=event.display, type=display?.type || 'tool'- const state=event.state==='running' && !active ? 'unconfirmed' : event.state+ const state=rowState(event,active)const rawLabel=display?.label || labels[event.kind]const label=state==='completed'?(completedLabels[rawLabel] || rawLabel):rawLabelconst Icon=type==='trace'?MessageSquare:icons[event.kind] || Wrench- const statusLabel={running:'In progress',completed:'Finished',failed:'Failed',blocked:'Blocked',unconfirmed:'Unconfirmed'}[state]+ // A tried call says so only once a later step shows the agent moved on.+ const statusLabel={running:'In progress',completed:'Finished',tried:later?'Tried another way':null}[state]const seconds=event.finishedAt ? (Date.parse(event.finishedAt)-Date.parse(event.startedAt))/1000 : nullconst change=state==='completed'?display?.change:nullconst expandable=!!change || !!display?.detail@@ -30,24 +41,31 @@ function ActivityRow({event,active}) {<div className="portal-agent-row-heading">{type!=='text' && <Icon size={14} aria-hidden="true"/>}{expandable?<button type="button" className="portal-agent-row-label portal-agent-row-toggle" aria-expanded={expanded} onClick={()=>setExpanded(value=>!value)}><span className="portal-agent-action-label">{label}</span>{(change?.file || display.detail) && <span className="portal-agent-target"> {change?.file || display.detail}</span>}<ActivityChangeCounts change={change}/><ChevronDown size={12} aria-hidden="true"/></button>:<span className="portal-agent-row-label">{label}</span>}- {type!=='text' && <span className="portal-agent-row-meta" title={statusLabel}>- {state==='running'?<span className="portal-agent-dot" aria-label={statusLabel}/>:['failed','blocked','unconfirmed'].includes(state)?<><AlertCircle size={12}/><span>{statusLabel}</span></>:<><Check size={12} aria-label={statusLabel}/>{seconds!==null && <span>{activityDuration(seconds)}</span>}</>}+ {type!=='text' && statusLabel && <span className="portal-agent-row-meta" title={statusLabel}>+ {state==='running'?<span className="portal-agent-dot" aria-label={statusLabel}/>:state==='completed'?<><Check size={12} aria-label={statusLabel}/>{seconds!==null && <span>{activityDuration(seconds)}</span>}</>:<span>{statusLabel}</span>}</span>}</div>- {type==='text' && ['failed','blocked','unconfirmed'].includes(state) && <small>{statusLabel}</small>}{expanded && (change?<PortalActivityChange change={change}/>:<pre className="portal-agent-detail">{display.detail}</pre>)}{!!display?.sources.length && <ul className="portal-agent-sources" aria-label="Sources from this tool">{display.sources.map(source=><li key={source.url}><a href={source.url} target="_blank" rel="noopener noreferrer"><PortalSiteIcon href={source.url}/><span>{source.title}</span><small>{new URL(source.url).hostname}</small></a></li>)}</ul>}- {!!display?.steps.length && <ol className="portal-agent-plan" aria-label="Reported plan steps">{display.steps.map(step=><li key={step.id} data-state={step.status}>{step.status==='completed'?<Check size={13} aria-label="Completed"/>:step.status==='running'?<span className="portal-agent-dot" aria-label="In progress"/>:step.status==='blocked'?<AlertCircle size={13} aria-label="Blocked"/>:<Circle size={12} aria-label="Pending"/>}<span>{step.title}</span></li>)}</ol>}+ {/* A step the agent reported as blocked is paused in this history. The+ Tasks card above shows the current plan and when it needs the owner. */}+ {!!display?.steps.length && <ol className="portal-agent-plan" aria-label="Reported plan steps">{display.steps.map(step=><li key={step.id} data-state={step.status==='blocked'?'paused':step.status}>{step.status==='completed'?<Check size={13} aria-label="Completed"/>:step.status==='running'?<span className="portal-agent-dot" aria-label="In progress"/>:step.status==='blocked'?<PauseCircle size={13} aria-label="Paused"/>:<Circle size={12} aria-label="Pending"/>}<span>{step.title}</span></li>)}</ol>}</li>}export default function PortalAgentActivity({task:raw,active=false,status}) {const task=parseTaskActivity(raw,raw?.runId)const id=useId(), viewport=useRef(null), content=useRef(null), follow=useRef(true), mountedAt=useRef(Date.now())- const failed=status==='error' || task?.state==='failed'+ // Only the response outcome can need the owner. A receipt that recorded a+ // failed run beside a delivered answer is telemetry, and tool calls that did+ // not work never decide it.+ const ended=status==='error'const stopped=status==='stopped'- const [open,setOpen]=useState(active||failed), [now,setNow]=useState(Date.now()), [fade,setFade]=useState({top:false,bottom:false})- const events=task?.events || task?.activities.map((row,i)=>({sequence:i+1,kind:row.kind,state:row.blocked?'blocked':row.failures?'failed':active?'running':'completed',startedAt:task.startedAt,finishedAt:null})) || []+ const [open,setOpen]=useState(active||ended), [now,setNow]=useState(Date.now()), [fade,setFade]=useState({top:false,bottom:false})+ // Receipts without events group calls by kind. A kind is a tried step only+ // when none of its calls worked.+ const events=task?.events || task?.activities.map((row,i)=>({sequence:i+1,kind:row.kind,state:row.failures===row.calls?'failed':active?'running':'completed',startedAt:task.startedAt,finishedAt:null})) || []+ const lastSequence=events.at(-1)?.sequenceconst progressRows=activityProgressRows(events)const start=task?.startedAt?Date.parse(task.startedAt):mountedAt.current// A saved running receipt has no confirmed end, even when its response is@@ -58,14 +76,14 @@ export default function PortalAgentActivity({task:raw,active=false,status}) {const currentType=current?.display?.typeconst progress=[...events].reverse().find(event=>event.display?.type==='text' && event.state==='completed')?.display?.labelconst activeLabel=progress || (currentType==='search' || current?.kind==='browser'?'Searching the web…':currentType==='text' || !current?'Thinking…':currentType==='steps'?'Planning…':'Working…')- const label=active?activeLabel:stopped?'Stopped':failed?'Needs attention':seconds===null?'Activity recorded':`Worked for ${activityDuration(seconds)}`+ const label=active?activeLabel:stopped?'Stopped':ended?'Ended early · you can try again':seconds===null?'Activity recorded':`Worked for ${activityDuration(seconds)}`const refreshFade=()=>{const el=viewport.current;if(el)setFade({top:el.scrollTop>2,bottom:el.scrollTop+el.clientHeight<el.scrollHeight-2})}useEffect(()=>{if(!active)returnconst timer=setInterval(()=>setNow(Date.now()),1000)return ()=>clearInterval(timer)},[active])- useEffect(()=>{setOpen(active||failed||stopped);follow.current=true},[active,failed,stopped,task?.runId])+ useEffect(()=>{setOpen(active||ended||stopped);follow.current=true},[active,ended,stopped,task?.runId])useLayoutEffect(()=>{const el=viewport.currentif(!el)return@@ -86,7 +104,7 @@ export default function PortalAgentActivity({task:raw,active=false,status}) {</button><div id={`${id}-log`} role="region" aria-labelledby={`${id}-trigger`} hidden={!open}><div ref={viewport} className="portal-agent-viewport" tabIndex={events.length?0:undefined} aria-label="Activity history" data-fade-top={fade.top} data-fade-bottom={fade.bottom} onScroll={()=>{const el=viewport.current;follow.current=el.scrollTop+el.clientHeight>=el.scrollHeight-12;refreshFade()}}>- <ol ref={content} className="portal-agent-stream" aria-label="Execution steps">{progressRows.map(row=>row.event?<ActivityRow key={row.event.sequence} event={row.event} active={active}/>:<li key={row.id} className="portal-agent-progress"><p>{row.text}</p></li>)}</ol>+ <ol ref={content} className="portal-agent-stream" aria-label="Execution steps">{progressRows.map(row=>row.event?<ActivityRow key={row.event.sequence} event={row.event} active={active} later={row.event.sequence<lastSequence}/>:<li key={row.id} className="portal-agent-progress"><p>{row.text}</p></li>)}</ol>{!events.length && !active && <p className="portal-agent-empty">No tool activity was recorded for this response.</p>}{task?.calls>events.length && <p className="portal-agent-empty">Showing the latest {events.length} of {task.calls} recorded actions.</p>}</div>diff --git a/ods/extensions/services/dashboard/src/components/PortalAgentActivity.test.jsx b/ods/extensions/services/dashboard/src/components/PortalAgentActivity.test.jsxindex c9365af59..e215f65e7 100644--- a/ods/extensions/services/dashboard/src/components/PortalAgentActivity.test.jsx+++ b/ods/extensions/services/dashboard/src/components/PortalAgentActivity.test.jsx@@ -1,10 +1,17 @@-import {fireEvent,render,screen} from '@testing-library/react'+import {fireEvent,render,screen,within} from '@testing-library/react'import PortalAgentActivity from './PortalAgentActivity'import PortalActivityChange,{activityChangeRows} from './PortalActivityChange'const start='2026-09-15T10:00:00.000Z',end='2026-09-15T10:00:05.000Z'const display=(type,label,extra={})=>({type,label,detail:null,sources:[],steps:[],change:null,...extra})const displays=[display('text','Conferindo a documentação.'),display('search','React reference',{sources:[{title:'Official docs',url:'https://react.dev/reference'}]}),display('tool','Reading a file',{detail:'app.jsx'}),display('steps','Check the result',{steps:[{id:'check',title:'Run checks',status:'completed'}]}),display('trace','Asking for your input')]const task={schemaVersion:3,runId:'chatcmpl_11111111-2222-4333-8444-555555555555',startedAt:start,finishedAt:end,state:'completed',calls:5,failures:0,blocked:0,truncated:false,activities:[{kind:'unknown',calls:5,failures:0,blocked:0}],events:displays.map((display,i)=>({sequence:i+1,kind:'unknown',state:'completed',startedAt:start,finishedAt:end,display})),context:null,goal:null}+const call=(sequence,kind,state,value)=>({sequence,kind,state,startedAt:start,finishedAt:end,display:value})+const row=text=>screen.getByText(text).closest('li')+// No row, plan step or heading reads as broken: no alarm words, no alert icon.+const expectCalm=container=>{+ expect(screen.queryByText(/Failed|Blocked|Unconfirmed|Needs attention/)).toBeNull()+ expect(container.querySelector('.lucide-circle-alert')).toBeNull()+}it('does not invent a completed duration from a persisted running receipt after reload',()=>{vi.useFakeTimers()try {@@ -30,8 +37,9 @@ it('renders an empty file without crashing and distinguishes completed recoveryexpect(activityChangeRows({kind:'patch',before:'',after:'--- old.txt\n+++ new.txt\n@@ -1 +1 @@\n--- heading\n+++ heading'})).toEqual([{type:'remove',text:'-- heading'},{type:'add',text:'++ heading'}]);render(<PortalActivityChange change={{file:'empty.txt',kind:'write',before:'',after:'',truncated:false}}/>);expect(screen.getByLabelText('Changes to empty.txt')).toHaveTextContent('Empty content');- render(<PortalAgentActivity task={{...task,failures:1,activities:[{kind:'unknown',calls:5,failures:1,blocked:0}],events:task.events.map((e,i)=>i===0?{...e,state:'failed'}:e)}}/>);+ const {container}=render(<PortalAgentActivity task={{...task,failures:1,activities:[{kind:'unknown',calls:5,failures:1,blocked:0}],events:task.events.map((e,i)=>i===0?{...e,state:'failed'}:e)}}/>);expect(screen.getByRole('button',{name:'Worked for 5s'})).toHaveAttribute('aria-expanded','false');+ expectCalm(container);});it('shows a compact thinking line immediately with no fake steps or technical placeholder',()=>{render(<PortalAgentActivity active/>);@@ -50,11 +58,59 @@ it('collapses completed work and expands the chronological mixed log with safe sexpect(trigger).toHaveAttribute('aria-expanded','false');expect(screen.queryByRole('link')).toBeNull();fireEvent.click(trigger);expect(screen.getByRole('link')).toBeVisible();});-it('keeps failures visible and never turns unfinished work into a successful step',()=>{+it('ends a reply that failed calmly and never turns unfinished work into a successful step',()=>{const value={...task,state:'failed',failures:1,activities:[{kind:'unknown',calls:5,failures:1,blocked:0}],events:task.events.map((event,i)=>i===4?{...event,state:'failed'}:i===2?{...event,state:'running',finishedAt:null}:event)};- render(<PortalAgentActivity task={value} status="error"/>);- expect(screen.getByRole('button',{name:'Needs attention'})).toHaveAttribute('aria-expanded','true');- expect(screen.getByText('Failed')).toBeVisible();expect(screen.getByText('Unconfirmed')).toBeVisible();+ const {container}=render(<PortalAgentActivity task={value} status="error"/>);+ expect(screen.getByRole('button',{name:'Ended early · you can try again'})).toHaveAttribute('aria-expanded','true');+ // A call with no recorded end claims no result: no check and no duration.+ expect(row('Reading a file')).toHaveAttribute('data-state','unconfirmed');+ expect(row('Reading a file').querySelector('.portal-agent-row-meta')).toBeNull();+ // The last call did not work and nothing followed it, so it shows no status.+ expect(row('Asking for your input')).toHaveAttribute('data-state','tried');+ expect(row('Asking for your input').querySelector('.portal-agent-row-meta')).toBeNull();+ expectCalm(container);+});+it('shows calls that did not work as ordinary steps while the agent keeps going',()=>{+ const events=[call(1,'run','failed',display('tool','Running a command',{detail:'npm test'})),call(2,'unknown','blocked',null),call(3,'edit','failed',display('tool','Editing a file',{detail:'app.js'}))]+ const activities=edits=>[{kind:'run',calls:1,failures:1,blocked:0},{kind:'edit',calls:edits,failures:1,blocked:0},{kind:'unknown',calls:1,failures:1,blocked:1}]+ const working={...task,state:'running',finishedAt:null,calls:3,failures:3,blocked:1,activities:activities(1),events}+ const {container,rerender}=render(<PortalAgentActivity task={working} active/>);+ expect(within(row('npm test')).getByText('Tried another way')).toBeVisible();+ // Portal declined this call before it ran; the agent was told why and continued.+ expect(within(row('Using a tool')).getByText('Tried another way')).toBeVisible();+ // The latest call has no outcome to show while the agent decides what to do next.+ expect(row('app.js').querySelector('.portal-agent-row-meta')).toBeNull();+ expectCalm(container);+ rerender(<PortalAgentActivity task={{...working,calls:4,activities:activities(2),events:[...events,call(4,'edit','completed',display('tool','Editing a file',{detail:'index.js'}))]}} active/>);+ expect(within(row('app.js')).getByText('Tried another way')).toBeVisible();+ expect(within(row('index.js')).getByLabelText('Finished')).toBeInTheDocument();+ expectCalm(container);+});+it('keeps a delivered answer calm when its receipt recorded a failed run',()=>{+ const value={...task,state:'failed'}+ const {rerender}=render(<PortalAgentActivity task={value} status="done"/>);+ expect(screen.getByRole('button',{name:'Worked for 5s'})).toHaveAttribute('aria-expanded','false');+ rerender(<PortalAgentActivity task={value}/>);+ expect(screen.getByRole('button',{name:'Worked for 5s'})).toHaveAttribute('aria-expanded','false');+ expect(screen.queryByText(/Needs attention|Ended early/)).toBeNull();+});+it('pauses a plan step the agent reported as blocked instead of raising an alert',()=>{+ const plan=display('steps','Website plan',{steps:[{id:'build',title:'Build the page',status:'completed'},{id:'key',title:'Get an API key',status:'blocked'},{id:'check',title:'Check the result',status:'pending'}]})+ const value={...task,calls:1,activities:[{kind:'unknown',calls:1,failures:0,blocked:0}],events:[call(1,'unknown','completed',plan)]}+ const {container}=render(<PortalAgentActivity task={value} active/>);+ expect(row('Get an API key')).toHaveAttribute('data-state','paused');+ expect(within(row('Get an API key')).getByLabelText('Paused')).toBeInTheDocument();+ expect(within(row('Check the result')).getByLabelText('Pending')).toBeInTheDocument();+ expect(screen.queryByLabelText('Blocked')).toBeNull();+ expectCalm(container);+});+it('groups older receipts by kind without marking a kind with working calls as failed',()=>{+ const grouped={schemaVersion:1,runId:task.runId,startedAt:start,finishedAt:end,state:'completed',calls:6,failures:3,blocked:1,truncated:false,activities:[{kind:'read',calls:2,failures:2,blocked:1},{kind:'run',calls:4,failures:1,blocked:0}]}+ const {container}=render(<PortalAgentActivity task={grouped} status="done"/>);+ fireEvent.click(screen.getByRole('button',{name:'Worked for 5s'}));+ expect(within(row('Reading files')).getByText('Tried another way')).toBeVisible();+ expect(within(row('Ran')).getByLabelText('Finished')).toBeInTheDocument();+ expectCalm(container);});it('opens actual file edits and command details without claiming failed edits succeeded',()=>{const change={file:'app.js',kind:'edit',before:'const n = 1;\nunchanged',after:'const n = 2;\nunchanged',truncated:false}@@ -66,4 +122,5 @@ it('opens actual file edits and command details without claiming failed edits suexpect(screen.getAllByLabelText('1 lines added, 1 lines removed')).toHaveLength(2);rerender(<PortalAgentActivity task={{...value,events:value.events.map((event,i)=>i===2?{...event,state:'failed'}:event)}} active/>);expect(screen.queryByLabelText('Changes to app.js')).toBeNull();+ expect(within(row('Editing a file')).getByText('Tried another way')).toBeVisible();});diff --git a/ods/extensions/services/dashboard/src/components/portal-agent-activity.css b/ods/extensions/services/dashboard/src/components/portal-agent-activity.cssindex a7f523991..425cf654e 100644--- a/ods/extensions/services/dashboard/src/components/portal-agent-activity.css+++ b/ods/extensions/services/dashboard/src/components/portal-agent-activity.css@@ -17,7 +17,6 @@.portal-agent-row-label { flex:1; min-width:0; overflow-wrap:anywhere; }.portal-agent-row.is-text { padding:3px 0; }.portal-agent-row-meta { display:inline-flex; align-items:center; flex-shrink:0; gap:5px; font-size:10px; font-variant-numeric:tabular-nums; opacity:.75; padding-top:3px; }-.portal-agent-row[data-state=failed],.portal-agent-row[data-state=blocked],.portal-agent-row[data-state=unconfirmed] { color:rgb(var(--theme-text-secondary)); }.portal-agent-detail { margin-left:23px; font-family:ui-monospace,monospace; font-size:11px; overflow-wrap:anywhere; opacity:.85; }.portal-agent-sources { margin:5px 0 3px 18px; }.portal-agent-sources a { display:flex; align-items:center; flex-wrap:wrap; gap:5px 8px; padding:4px 6px; border-radius:6px; color:rgb(var(--theme-text-secondary)); text-decoration:none; }