feat: add agent activity events

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-21 12:48:27 +01:00
co-authored by Copilot
parent b9e9662f6e
commit c5979d07bd
14 changed files with 754 additions and 33 deletions
+15 -1
View File
@@ -3,7 +3,7 @@ import { basename } from 'node:path';
import { dialog } from 'electron';
import type { TurnDeltaEvent } from '@shared/contracts/sidecar';
import type { AgentActivityEvent, TurnDeltaEvent } from '@shared/contracts/sidecar';
import { buildSessionTitle, validatePatternDefinition, type PatternDefinition } from '@shared/domain/pattern';
import type { ProjectRecord } from '@shared/domain/project';
import type { SessionEventRecord } from '@shared/domain/event';
@@ -199,6 +199,9 @@ export class KopayaAppService extends EventEmitter<AppServiceEvents> {
async (event) => {
await this.applyTurnDelta(workspace, session.id, event);
},
(event) => {
this.emitAgentActivity(event);
},
);
this.finalizeTurn(workspace, session.id, responseMessages);
@@ -301,6 +304,17 @@ export class KopayaAppService extends EventEmitter<AppServiceEvents> {
});
}
private emitAgentActivity(event: AgentActivityEvent): void {
this.emitSessionEvent({
sessionId: event.sessionId,
kind: 'agent-activity',
occurredAt: nowIso(),
activityType: event.activityType,
agentName: event.agentName,
toolName: event.toolName,
});
}
private finalizeTurn(workspace: WorkspaceState, sessionId: string, messages: ChatMessageRecord[]): void {
const session = this.requireSession(workspace, sessionId);
const incomingIds = new Set(messages.map((message) => message.id));