refactor: implement async agent creation flow with loading states

- Add loading states and request tracking to agent creation modal
- Move agent creation logic from parent to modal component
- Add automatic navigation to agent page after creation
- Implement requestId-based response matching for agent_created events
- Add audio output handling in session context
- Improve modal UX with disabled states during creation
```
This commit is contained in:
Mohamed Boudra
2025-10-23 12:04:12 +02:00
parent 542707ecdd
commit 41be2d4096
5 changed files with 144 additions and 23 deletions
+2
View File
@@ -63,6 +63,7 @@ export const CreateAgentRequestMessageSchema = z.object({
type: z.literal("create_agent_request"),
cwd: z.string(),
initialMode: z.string().optional(),
requestId: z.string().optional(),
});
export const SetAgentModeMessageSchema = z.object({
@@ -188,6 +189,7 @@ export const AgentCreatedMessageSchema = z.object({
})).optional(),
title: z.string().optional(),
cwd: z.string(),
requestId: z.string().optional(),
}),
});
+4 -2
View File
@@ -466,7 +466,7 @@ export class Session {
break;
case "create_agent_request":
await this.handleCreateAgentRequest(msg.cwd, msg.initialMode);
await this.handleCreateAgentRequest(msg.cwd, msg.initialMode, msg.requestId);
break;
case "set_agent_mode":
@@ -697,7 +697,8 @@ export class Session {
*/
private async handleCreateAgentRequest(
cwd: string,
initialMode?: string
initialMode?: string,
requestId?: string
): Promise<void> {
console.log(
`[Session ${this.clientId}] Creating agent in ${cwd} with mode ${
@@ -736,6 +737,7 @@ export class Session {
availableModes: agentInfo?.availableModes ?? undefined,
title: agentInfo?.title ?? undefined,
cwd: agentInfo?.cwd || cwd,
requestId,
},
});
console.log(