Push live updates to the UI while agent runs execute

Engine-side writes - hires, delegated tasks, chat messages, run state -
only reached the renderer after a run finished: the queue worker sent
one snapshot-changed at the end, and nothing fired at claim time, so
the window sat frozen for the minutes a CEO run takes unless the user
reloaded by hand. The execution service now takes a notifyDataChanged
callback, the agent loop fires it after every tool-bearing iteration,
and the worker announces the claim itself, so the UI follows the
company working in real time.
This commit is contained in:
ZacharyZhang-NY committed 2026-06-09 21:51:29 -04:00
1 parent 921c5b4456
commit de9e6a9fa3
5 files changed
+33 -10

No files matched your search

@@ -54,6 +54,8 @@ export class TaskExecutionService {
private readonly db: DatabaseSync,
private readonly providers: ProviderService = new ProviderService(db),
private readonly skills: SkillService = new SkillService(db, ""),
/** Invoked whenever a run writes data mid-flight, so the UI can refresh while agents work. */
private readonly notifyDataChanged: () => void = () => undefined,
) {
this.audit = new AuditService(db);
this.organization = new OrganizationService(db);
@@ -118,7 +120,11 @@ export class TaskExecutionService {
};
const chatContext = this.loadChatContext(orgId, isolation);
const result = await runAgentLoop(
{ providers: this.providers, tools: { db: this.db, organization: this.organization, chat: this.chat } },
{
providers: this.providers,
tools: { db: this.db, organization: this.organization, chat: this.chat },
onToolResults: this.notifyDataChanged,
},
{
orgId,
providerId: provider.id,