The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Assist: a "Remember this?" card says Saved only once the person said yes
Claude576b8e3e11dc
diff --git a/src/components/assist/transcript.tsx b/src/components/assist/transcript.tsxindex 3229de9c..a9eee534 100644--- a/src/components/assist/transcript.tsx+++ b/src/components/assist/transcript.tsx@@ -7,7 +7,7 @@ import { toast } from "sonner";import { Button } from "@/components/ui/button";import { FailedTile, MediaThumb, PendingTile, tileRatio } from "@/components/studio/feed";import { useCreateGeneration } from "@/lib/api";-import { planRunnable, type AssistItem, type AssistThread, type SkillSummary } from "@/lib/assist";+import { memoryCardLine, planRunnable, type AssistItem, type AssistThread, type SkillSummary } from "@/lib/assist";import type { Generation } from "@/lib/catalog/types";import { formatCost } from "@/lib/format";import { cn } from "@/lib/utils";@@ -46,7 +46,7 @@ export function ApprovalCard({ item, live, onAnswer }: { item: Extract<AssistIteconst memoryOnly = item.jobs.length > 0 && item.jobs.every((j) => j.op === "memory");const allDemo = item.jobs.every((j) => j.demo || j.error || j.op === "memory");const total = memoryOnly- ? "Saved to memory for future chats"+ ? memoryCardLine(item.status): !runnable && item.status === "pending"? "Can't run yet — fix what's marked above, or tell Assist what to change": allDemodiff --git a/src/lib/assist.ts b/src/lib/assist.tsindex 3386ee87..75d846ce 100644--- a/src/lib/assist.ts+++ b/src/lib/assist.ts@@ -34,6 +34,10 @@ export interface PlannedJob {/** Whether an approval card's plan can run: something to run, and no pipeline with a broken step. */export const planRunnable = (jobs: PlannedJob[]): boolean => jobs.some((j) => !j.error) && !jobs.some((j) => j.atomic && j.error);+/** The line under a "Remember this?" card: nothing is saved until the person says yes, and nothing when they don't. */+export const memoryCardLine = (status: "pending" | "approved" | "declined"): string =>+ status === "approved" ? "Saved to memory for future chats" : status === "declined" ? "Not saved to memory" : "Saves to memory for future chats";+export type AssistItem =| { id: string; role: "user"; text: string; attachments?: string[]; skills?: string[] }| { id: string; role: "assistant"; text: string }diff --git a/tests/assist-context.test.ts b/tests/assist-context.test.tsindex 272fcf60..1020de55 100644--- a/tests/assist-context.test.ts+++ b/tests/assist-context.test.ts@@ -4,6 +4,7 @@ import path from "node:path";import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";import { claudeStream } from "./fixtures/claude-sse";import type Anthropic from "@anthropic-ai/sdk";+import type { AssistItem } from "@/lib/assist";vi.setConfig({ testTimeout: 60_000 });const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-assist-ctx-"));@@ -19,7 +20,7 @@ const memory = await import("@/server/assist/memory");const projects = await import("@/server/assist/projects");const { handleMcp } = await import("@/server/mcp");const { db } = await import("@/server/db");-const { planRunnable } = await import("@/lib/assist");+const { memoryCardLine, planRunnable } = await import("@/lib/assist");type Msg = Anthropic.Beta.BetaMessage;type Block = Anthropic.Beta.BetaContentBlock;@@ -131,13 +132,31 @@ describe("a chat's context", () => {await agent.run(t.id, m.call);let v = agent.getThread(t.id)!;expect(v.thread.status).toBe("waiting");- expect(v.thread.items.find((i) => i.role === "approval")).toMatchObject({ summary: "Remember this?", jobs: [{ tool: "remember", op: "memory", prompt: "Logo always bottom right.", note: "This project" }] });+ const card = () => v.thread.items.find((i) => i.role === "approval") as Extract<AssistItem, { role: "approval" }>;+ expect(card()).toMatchObject({ summary: "Remember this?", status: "pending", jobs: [{ tool: "remember", op: "memory", prompt: "Logo always bottom right.", note: "This project" }] });+ // The card's line doesn't say it's saved before the person says yes.+ expect(memoryCardLine(card().status)).toBe("Saves to memory for future chats");expect(memory.listMemories({ scope: "project", projectId: p.id })).toHaveLength(0);await agent.answerApproval(t.id, true);await agent.run(t.id, m.call);v = agent.getThread(t.id)!;expect(memory.listMemories({ scope: "project", projectId: p.id }).map((x) => [x.text, x.source])).toEqual([["Logo always bottom right.", "agent"]]);expect(v.thread.items.some((i) => i.role === "tool" && /Remembered/.test(i.text))).toBe(true);+ expect(card().status).toBe("approved");+ expect(memoryCardLine(card().status)).toBe("Saved to memory for future chats");+ });++ it("a memory declined with Not now isn't saved, and its card says so", async () => {+ const t = agent.createThread({ engine: "cloud", agent: "offline" });+ agent.addMessage(t.id, "Remember that captions are always yellow");+ const m = scripted(reply([use("toolu_n", "remember", { text: "Captions are always yellow.", category: "Style" })], "tool_use"), reply([text("Okay.")], "end_turn"));+ await agent.run(t.id, m.call);+ await agent.answerApproval(t.id, false);+ await agent.run(t.id, m.call);+ const card = agent.getThread(t.id)!.thread.items.find((i) => i.role === "approval") as Extract<AssistItem, { role: "approval" }>;+ expect(card.status).toBe("declined");+ expect(memoryCardLine(card.status)).toBe("Not saved to memory");+ expect(memory.listMemories({ scope: "all" }).some((x) => x.text === "Captions are always yellow.")).toBe(false);});it("gives project chats the instructions and sources, and read_source the full text", async () => {diff --git a/tests/e2e/assist-flows.mjs b/tests/e2e/assist-flows.mjsindex 63ef144e..3a2449cb 100644--- a/tests/e2e/assist-flows.mjs+++ b/tests/e2e/assist-flows.mjs@@ -3,7 +3,8 @@//// 1. `/` opens the skill menu; picking Product Photographer shows its chip; sending starts a chat// with the skill loaded and an approval card that runs demo generations.-// 2. "Remember that …" asks first, then the memory is on the Memory page.+// 2. "Remember that …" asks first (the card doesn't say it's saved until Remember), then the card and the+// assistant say it's saved, and the memory is on the Memory page.// 3. A project with instructions and a note source; a chat started there carries the project.// 4. A skill uploaded as a .zip shows up in My skills, opens, and can be deleted.// 5. Free / Smart / Manual: the mode picker offers Manual's models and effort.@@ -112,9 +113,14 @@ await step("remember asks first, then shows on the Memory page", async () => {await box.fill("Remember that I always want vertical 9:16 videos");await box.press("Enter");await page.getByText("Remember this?").waitFor({ timeout: 30_000 });+ // Asked first: before the yes, the card says what Remember does, not that it's done.+ await page.getByText("Saves to memory for future chats", { exact: true }).waitFor({ timeout: 10_000 });await shot(page, "flow-remember");await page.getByRole("button", { name: "Remember", exact: true }).click();- await page.getByText(/Saved to memory/).waitFor({ timeout: 30_000 });+ // Then the card says it's saved and the assistant says so too: two lines that both start "Saved to memory", so each+ // is waited for by its own words (one pattern for both matches one or two of them, depending on how fast the reply is).+ await page.getByText("Saved to memory for future chats", { exact: true }).waitFor({ timeout: 30_000 });+ await page.getByText(/^Saved to memory — every chat will follow it/).waitFor({ timeout: 30_000 });await openRoute(page, `${app}/assist/memory`);await page.getByText("I always want vertical 9:16 videos.").waitFor({ timeout: 15_000 });await shot(page, "flow-memory");