fix(web): passe le nodeId réel à la custom CLI au lieu d'un id fabriqué — #225
This commit is contained in:
@ -113,10 +113,26 @@ describe("WebAgentCell", () => {
|
||||
|
||||
expect(await screen.findByTestId("custom-agent-chat-view")).toBeTruthy();
|
||||
expect(screen.queryByTestId("terminal-key-bar")).toBeNull();
|
||||
await waitFor(() => expect(launchChatSpy).toHaveBeenCalledTimes(1));
|
||||
expect(launchChatSpy.mock.calls[0][2]).toMatchObject({ cwd: "/srv/demo" });
|
||||
expect(launchChatSpy.mock.calls[0][2]).not.toHaveProperty("nodeId");
|
||||
});
|
||||
|
||||
it("propagates the real leaf node id to the mobile custom CLI when provided", async () => {
|
||||
const { agent, profile, agentId } = await seededAgentGateway(structuredProfile);
|
||||
const launchChatSpy = vi.spyOn(agent, "launchAgentChat");
|
||||
const leafNodeId = "1efdd2dd-981d-431b-915c-1dd5e976fdd5";
|
||||
|
||||
renderCell(agent, profile, agentId, {
|
||||
fullHeight: true,
|
||||
nodeId: leafNodeId,
|
||||
});
|
||||
fireEvent.click(await screen.findByRole("button", { name: "CLI custom" }));
|
||||
|
||||
await waitFor(() => expect(launchChatSpy).toHaveBeenCalledTimes(1));
|
||||
expect(launchChatSpy.mock.calls[0][2]).toMatchObject({
|
||||
cwd: "/srv/demo",
|
||||
nodeId: `web-mobile-${agentId}`,
|
||||
nodeId: leafNodeId,
|
||||
});
|
||||
});
|
||||
|
||||
@ -149,10 +165,8 @@ describe("WebAgentCell", () => {
|
||||
|
||||
await waitFor(() => expect(launchChatSpy).toHaveBeenCalledTimes(1));
|
||||
await waitFor(() => expect(reattachChatSpy).toHaveBeenCalledTimes(1));
|
||||
expect(launchChatSpy.mock.calls[0][2]).toMatchObject({
|
||||
cwd: "/srv/demo",
|
||||
nodeId: `web-mobile-${agentId}`,
|
||||
});
|
||||
expect(launchChatSpy.mock.calls[0][2]).toMatchObject({ cwd: "/srv/demo" });
|
||||
expect(launchChatSpy.mock.calls[0][2]).not.toHaveProperty("nodeId");
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "TUI native" }));
|
||||
await waitFor(() => expect(screen.queryByTestId("custom-agent-chat-view")).toBeNull());
|
||||
@ -183,11 +197,11 @@ describe("WebAgentCell", () => {
|
||||
expect(launchChatSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("surfaces a mobile custom CLI launch failure when the runtime cannot find node", async () => {
|
||||
it("surfaces a generic mobile custom CLI launch failure", async () => {
|
||||
const { agent, profile, agentId } = await seededAgentGateway(structuredProfile);
|
||||
const launchChatSpy = vi.spyOn(agent, "launchAgentChat").mockRejectedValueOnce({
|
||||
code: "PROCESS",
|
||||
message: "spawn node ENOENT: node is not installed on this runtime",
|
||||
message: "invalid node id: web-mobile-agent-1",
|
||||
});
|
||||
const reattachChatSpy = vi.spyOn(agent, "reattachAgentChat");
|
||||
|
||||
@ -195,12 +209,12 @@ describe("WebAgentCell", () => {
|
||||
fireEvent.click(await screen.findByRole("button", { name: "CLI custom" }));
|
||||
|
||||
await waitFor(() => expect(launchChatSpy).toHaveBeenCalledTimes(1));
|
||||
expect(launchChatSpy.mock.calls[0][2]).toMatchObject({
|
||||
cwd: "/srv/demo",
|
||||
nodeId: `web-mobile-${agentId}`,
|
||||
});
|
||||
expect(launchChatSpy.mock.calls[0][2]).toMatchObject({ cwd: "/srv/demo" });
|
||||
expect(launchChatSpy.mock.calls[0][2]).not.toHaveProperty("nodeId");
|
||||
expect(reattachChatSpy).not.toHaveBeenCalled();
|
||||
expect((await screen.findByRole("alert")).textContent).toContain("spawn node ENOENT");
|
||||
const alertText = (await screen.findByRole("alert")).textContent ?? "";
|
||||
expect(alertText).toContain("Le CLI custom n'a pas pu démarrer");
|
||||
expect(alertText).not.toContain("invalid node id");
|
||||
});
|
||||
|
||||
it("falls back to native TUI when the mobile agent loses custom CLI support", async () => {
|
||||
|
||||
@ -203,7 +203,7 @@ export function WebAgentCell({
|
||||
agentName={resolvedAgent.name}
|
||||
profile={resolvedProfile}
|
||||
cwd={cwd}
|
||||
nodeId={`web-mobile-${agentId}`}
|
||||
nodeId={nodeId}
|
||||
sessionId={customSessionId}
|
||||
conversationId={customConversationId}
|
||||
draftScope={draftScope}
|
||||
|
||||
Reference in New Issue
Block a user