feat(workstate): UI des actions contrôlées (Lot D frontend)
Câble les actions contrôlées dans ProjectWorkStatePanel : port et adaptateur agent étendus aux nouvelles commandes, adaptateur mock aligné. Tests verts : workstate + projects (25), agent (8), singletonAgent + agentAlreadyRunning (9), tsc --noEmit OK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -61,13 +61,34 @@ describe("TauriAgentGateway invoke payloads", () => {
|
||||
});
|
||||
|
||||
it("attach_live_agent wraps project, agent and target node in the request DTO", async () => {
|
||||
invoke.mockResolvedValueOnce([
|
||||
{ agentId: "agent-2", nodeId: "node-3", sessionId: "session-4" },
|
||||
]);
|
||||
await new TauriAgentGateway().attachLiveAgent("proj-1", "agent-2", "node-3");
|
||||
invoke.mockResolvedValueOnce({
|
||||
agentId: "agent-2",
|
||||
nodeId: "node-3",
|
||||
sessionId: "session-4",
|
||||
kind: "pty",
|
||||
});
|
||||
const out = await new TauriAgentGateway().attachLiveAgent(
|
||||
"proj-1",
|
||||
"agent-2",
|
||||
"node-3",
|
||||
);
|
||||
expect(invoke).toHaveBeenCalledWith("attach_live_agent", {
|
||||
request: { projectId: "proj-1", agentId: "agent-2", nodeId: "node-3" },
|
||||
});
|
||||
expect(out.sessionId).toBe("session-4");
|
||||
});
|
||||
|
||||
it("stop_live_agent wraps project and agent in the request DTO", async () => {
|
||||
invoke.mockResolvedValueOnce({
|
||||
agentId: "agent-2",
|
||||
sessionId: "session-4",
|
||||
kind: "pty",
|
||||
});
|
||||
const out = await new TauriAgentGateway().stopLiveAgent("proj-1", "agent-2");
|
||||
expect(invoke).toHaveBeenCalledWith("stop_live_agent", {
|
||||
request: { projectId: "proj-1", agentId: "agent-2" },
|
||||
});
|
||||
expect(out.sessionId).toBe("session-4");
|
||||
});
|
||||
|
||||
it("change_agent_profile wraps all five fields in the request DTO (camelCase)", async () => {
|
||||
|
||||
@ -26,6 +26,7 @@ import type {
|
||||
LiveAgent,
|
||||
OpenTerminalOptions,
|
||||
ReattachResult,
|
||||
StoppedLiveAgent,
|
||||
TerminalHandle,
|
||||
} from "@/ports";
|
||||
import { makeTerminalHandle } from "./terminal";
|
||||
@ -63,14 +64,14 @@ export class TauriAgentGateway implements AgentGateway {
|
||||
agentId: string,
|
||||
nodeId: string,
|
||||
): Promise<LiveAgent> {
|
||||
return invoke<LiveAgent[]>("attach_live_agent", {
|
||||
return invoke<LiveAgent>("attach_live_agent", {
|
||||
request: { projectId, agentId, nodeId },
|
||||
}).then((list) => {
|
||||
const attached = list[0];
|
||||
if (!attached) {
|
||||
throw new Error(`running session for agent ${agentId} was not returned`);
|
||||
}
|
||||
return attached;
|
||||
});
|
||||
}
|
||||
|
||||
stopLiveAgent(projectId: string, agentId: string): Promise<StoppedLiveAgent> {
|
||||
return invoke<StoppedLiveAgent>("stop_live_agent", {
|
||||
request: { projectId, agentId },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -61,6 +61,7 @@ import type {
|
||||
ReattachResult,
|
||||
RemoteGateway,
|
||||
SkillGateway,
|
||||
StoppedLiveAgent,
|
||||
SystemGateway,
|
||||
TemplateGateway,
|
||||
TerminalGateway,
|
||||
@ -215,7 +216,8 @@ export class MockAgentGateway implements AgentGateway {
|
||||
.map(([agentId, nodeId]) => ({
|
||||
agentId,
|
||||
nodeId,
|
||||
sessionId: this.liveSessionByAgent.get(agentId),
|
||||
sessionId: this.liveSessionByAgent.get(agentId)!,
|
||||
kind: "pty" as const,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -256,7 +258,32 @@ export class MockAgentGateway implements AgentGateway {
|
||||
throw err;
|
||||
}
|
||||
this.liveByAgent.set(agentId, nodeId);
|
||||
return { agentId, nodeId, sessionId };
|
||||
return { agentId, nodeId, sessionId, kind: "pty" };
|
||||
}
|
||||
|
||||
async stopLiveAgent(projectId: string, agentId: string): Promise<StoppedLiveAgent> {
|
||||
const list = this.getAgents(projectId);
|
||||
if (!list.some((a) => a.id === agentId)) {
|
||||
const err: GatewayError = {
|
||||
code: "NOT_FOUND",
|
||||
message: `agent ${agentId} not found in project ${projectId}`,
|
||||
};
|
||||
throw err;
|
||||
}
|
||||
const sessionId = this.liveSessionByAgent.get(agentId);
|
||||
if (!sessionId) {
|
||||
const err: GatewayError = {
|
||||
code: "NOT_FOUND",
|
||||
message: `agent ${agentId} has no live session`,
|
||||
};
|
||||
throw err;
|
||||
}
|
||||
const session = this.sessions.get(sessionId);
|
||||
if (session) session.closed = true;
|
||||
this.sessions.delete(sessionId);
|
||||
this.liveSessionByAgent.delete(agentId);
|
||||
this.liveByAgent.delete(agentId);
|
||||
return { agentId, sessionId, kind: "pty" };
|
||||
}
|
||||
|
||||
async createAgent(projectId: string, input: CreateAgentInput): Promise<Agent> {
|
||||
|
||||
Reference in New Issue
Block a user