fix(webui): keep automation creation intent in runtime context
This commit is contained in:
1 parent
037438e7d1
commit
458b925f86
21 files changed
+149
-20
No files matched your search
@@ -490,9 +490,9 @@ describe("Automation task list and detail sheet", () => {
|
||||
await user.click(screen.getByRole("button", { name: "Send message" }));
|
||||
|
||||
expect(onStartChat).toHaveBeenCalledWith(
|
||||
"Create an automation for this request:\n\nEvery weekday at 9, summarize my open pull requests",
|
||||
undefined,
|
||||
"Every weekday at 9, summarize my open pull requests",
|
||||
undefined,
|
||||
{ intent: "create_automation" },
|
||||
"fast",
|
||||
);
|
||||
await waitFor(() => expect(composer).toHaveValue(""));
|
||||
@@ -512,9 +512,9 @@ describe("Automation task list and detail sheet", () => {
|
||||
await user.type(composer, "Run a deep weekly review");
|
||||
await user.click(screen.getByRole("button", { name: "Send message" }));
|
||||
expect(onStartChat).toHaveBeenCalledWith(
|
||||
"Create an automation for this request:\n\nRun a deep weekly review",
|
||||
undefined,
|
||||
"Run a deep weekly review",
|
||||
undefined,
|
||||
{ intent: "create_automation" },
|
||||
"deep",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1974,6 +1974,30 @@ describe("NanobotClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("sends automation intent separately from the user's text", () => {
|
||||
const client = new NanobotClient({
|
||||
url: "ws://test",
|
||||
reconnect: false,
|
||||
socketFactory: (url) => new FakeSocket(url) as unknown as WebSocket,
|
||||
});
|
||||
client.connect();
|
||||
lastSocket().fakeOpen();
|
||||
|
||||
client.sendMessage("chat-x", "每天八点提醒我喝水", undefined, {
|
||||
intent: "create_automation",
|
||||
});
|
||||
expect(JSON.parse(lastSocket().sent.at(-1) as string)).toEqual({
|
||||
type: "message",
|
||||
chat_id: "chat-x",
|
||||
content: "每天八点提醒我喝水",
|
||||
intent: "create_automation",
|
||||
webui: true,
|
||||
});
|
||||
|
||||
client.sendMessage("chat-x", "Thanks");
|
||||
expect(JSON.parse(lastSocket().sent.at(-1) as string)).not.toHaveProperty("intent");
|
||||
});
|
||||
|
||||
it("includes CLI app attachments in outbound messages", () => {
|
||||
const client = new NanobotClient({
|
||||
url: "ws://test",
|
||||
|
||||
@@ -1608,6 +1608,7 @@ describe("ThreadShell", () => {
|
||||
id: "automation-first-message",
|
||||
chatId: "chat-new",
|
||||
content: "Every weekday at 9, summarize open pull requests",
|
||||
options: { intent: "create_automation" as const },
|
||||
};
|
||||
|
||||
render(
|
||||
@@ -1633,6 +1634,12 @@ describe("ThreadShell", () => {
|
||||
expect(client.sendMessage).toHaveBeenCalledTimes(1);
|
||||
expect(consumed).toHaveBeenCalledOnce();
|
||||
expect(consumed).toHaveBeenCalledWith(pendingFirstMessage.id);
|
||||
expect(client.sendMessage).toHaveBeenCalledWith(
|
||||
"chat-new",
|
||||
pendingFirstMessage.content,
|
||||
undefined,
|
||||
expect.objectContaining({ intent: "create_automation" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps the first landing message when new chat history is still empty", async () => {
|
||||
|
||||
@@ -2711,6 +2711,24 @@ describe("useNanobotStream", () => {
|
||||
expect(outbound[3]).not.toHaveProperty("quotedContext");
|
||||
});
|
||||
|
||||
it("keeps automation intent out of the optimistic user message", () => {
|
||||
const fake = fakeClient();
|
||||
const { result } = renderHook(() => useNanobotStream("chat-automation", EMPTY_MESSAGES), {
|
||||
wrapper: wrap(fake.client),
|
||||
});
|
||||
act(() => {
|
||||
result.current.send("每天八点提醒我喝水", undefined, { intent: "create_automation" });
|
||||
});
|
||||
expect(result.current.messages[0].content).toBe("每天八点提醒我喝水");
|
||||
expect(result.current.messages[0]).not.toHaveProperty("intent");
|
||||
expect(fake.client.sendMessage).toHaveBeenCalledWith(
|
||||
"chat-automation",
|
||||
"每天八点提醒我喝水",
|
||||
undefined,
|
||||
expect.objectContaining({ intent: "create_automation", turnId: expect.any(String) }),
|
||||
);
|
||||
});
|
||||
|
||||
it("attaches assistant media_urls to complete messages", () => {
|
||||
const fake = fakeClient();
|
||||
const { result } = renderHook(() => useNanobotStream("chat-m", EMPTY_MESSAGES), {
|
||||
|
||||
Reference in new issue
Block a user