Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

feat(switchdash): emit agent:updated on the agent lifecycle hooks (CHOO-1423)

Christian McDermott6a3325cc3afb
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/agent-events.ts b/dash/apps/switchdash-desktop/src/main/core/agents/agent-events.ts
index aec60f174..50f6389d8 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/agent-events.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/agent-events.ts
@@ -4,6 +4,7 @@ import type { Agent } from '@shared/core/agents/agents';
export type AgentCrudHooks = {
'agent:created': (agent: Agent) => void | Promise<void>;
+ 'agent:updated': (agent: Agent) => void | Promise<void>;
'agent:deleted': (agentId: string) => void | Promise<void>;
};
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/renameAgent.ts b/dash/apps/switchdash-desktop/src/main/core/agents/renameAgent.ts
index 2623c354e..6bb1650f8 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/renameAgent.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/renameAgent.ts
@@ -9,6 +9,7 @@ import { db } from '@main/db/client';
import { agents } from '@main/db/schema';
import { log } from '@main/lib/logger';
import type { Agent, RenameAgentParams } from '@shared/core/agents/agents';
+import { agentEvents } from './agent-events';
import { getAgentLocation, getRemoteAgentLocation } from './agent-location';
import { agentNameTaken } from './agent-name-taken';
import { resolveWorkspaceFsFor } from './agent-workspace-fs';
@@ -139,5 +140,6 @@ export async function renameAgent(
await moveProvisionedFiles(previous, renamed);
await moveSidecarToNewName(previous, renamed);
}
+ agentEvents._emit('agent:updated', renamed);
return ok(renamed);
}
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/updateAgent.ts b/dash/apps/switchdash-desktop/src/main/core/agents/updateAgent.ts
index a7d4bc59d..db2fe0b3f 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/updateAgent.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/updateAgent.ts
@@ -2,6 +2,7 @@ import { eq, sql } from 'drizzle-orm';
import { db } from '@main/db/client';
import { agents } from '@main/db/schema';
import type { Agent } from '@shared/core/agents/agents';
+import { agentEvents } from './agent-events';
import { mapAgentRowToAgent } from './utils';
export type UpdateAgentParams = {
@@ -25,5 +26,7 @@ export async function updateAgent(params: UpdateAgentParams): Promise<Agent | un
const [row] = await db.update(agents).set(set).where(eq(agents.id, params.agentId)).returning();
if (!row) return undefined;
- return mapAgentRowToAgent(row);
+ const agent = mapAgentRowToAgent(row);
+ agentEvents._emit('agent:updated', agent);
+ return agent;
}