fix(cli): restaure la conversation au retour de layout via cache conversationId+sessionId — #217
This commit is contained in:
@ -266,6 +266,71 @@ describe("LayoutGrid custom agent CLI (#147)", () => {
|
||||
expect(screen.queryByText(/déjà actif dans une autre cellule/)).toBeNull();
|
||||
});
|
||||
|
||||
it("restores a custom CLI transcript when returning with a conversation id but no session (#217)", async () => {
|
||||
const layout = new MockLayoutGateway();
|
||||
const agent = new MockAgentGateway();
|
||||
const profileGateway = new MockProfileGateway();
|
||||
const terminal = new MockTerminalGateway();
|
||||
const system = new MockSystemGateway();
|
||||
await profileGateway.configureProfiles([structuredProfile]);
|
||||
const created = await agent.createAgent("p1", {
|
||||
name: "Worker",
|
||||
profileId: structuredProfile.id,
|
||||
});
|
||||
const tree = await layout.loadLayout("p1");
|
||||
const leafId = leaves(tree)[0].id;
|
||||
await layout.mutateLayout("p1", {
|
||||
type: "setCellAgent",
|
||||
target: leafId,
|
||||
agent: created.id,
|
||||
});
|
||||
await layout.mutateLayout("p1", {
|
||||
type: "setCellConversation",
|
||||
target: leafId,
|
||||
conversationId: "conversation-known",
|
||||
});
|
||||
window.localStorage.setItem(`idea.agent-cell-mode.p1.${leafId}`, "custom");
|
||||
const launchChat = vi.spyOn(agent, "launchAgentChat").mockResolvedValue({
|
||||
sessionId: "chat-resumed",
|
||||
cellKind: "chat" as const,
|
||||
});
|
||||
const reattachChat = vi.spyOn(agent, "reattachAgentChat").mockResolvedValue({
|
||||
sessionId: "chat-resumed",
|
||||
scrollback: [
|
||||
{ kind: "userPrompt", text: "known prompt" },
|
||||
{ kind: "final", content: "known answer" },
|
||||
],
|
||||
});
|
||||
|
||||
renderGrid({
|
||||
layout,
|
||||
agent,
|
||||
profile: profileGateway,
|
||||
terminal,
|
||||
system,
|
||||
} as unknown as Gateways);
|
||||
|
||||
expect(await screen.findByText("known answer")).toBeTruthy();
|
||||
expect(screen.getByText("known prompt")).toBeTruthy();
|
||||
expect(launchChat).toHaveBeenCalledWith(
|
||||
"p1",
|
||||
created.id,
|
||||
expect.objectContaining({
|
||||
nodeId: leafId,
|
||||
conversationId: "conversation-known",
|
||||
}),
|
||||
);
|
||||
expect(reattachChat).toHaveBeenCalledWith("chat-resumed", expect.any(Function));
|
||||
await waitFor(async () => {
|
||||
const updated = await layout.loadLayout("p1");
|
||||
const leaf = leaves(updated)[0];
|
||||
expect(leaf.conversationId).toBe("conversation-known");
|
||||
expect(leaf.session).toBe("chat-resumed");
|
||||
});
|
||||
expect(screen.queryByText("Envoyez un message pour démarrer la conversation structurée."))
|
||||
.toBeNull();
|
||||
});
|
||||
|
||||
it("relaunches a stopped custom CLI agent from scratch (#197)", async () => {
|
||||
const layout = new MockLayoutGateway();
|
||||
const agent = new MockAgentGateway();
|
||||
|
||||
Reference in New Issue
Block a user