Files
paseo/packages/app/src/stores/draft-store.lifecycle.test.ts
T
Mohamed Boudra d1bda25a0b fix(app): source composer cwd from agent state, not draft hook
The GitHub picker showed "No results found." for any running agent after
the first message was sent. useAgentInputDraft owned a local cwd state
that clear("sent") wiped to "", so the composer read cwd: "" even though
the agent's real cwd was correct on the wire.

Drop cwd ownership from the hook. Composer takes cwd as a prop sourced
by the parent — agentState.cwd for running agents, composerState.workingDir
for drafts, sourceDirectory for setup flows. The hook now persists only
{text, attachments}. Legacy persisted drafts with a cwd field still
hydrate; tagged COMPAT(draft-cwd) for removal after 2026-11-09.

Also moves attachment pills back inside the composer's bordered surface
via a new attachmentSlot prop on MessageInput, and shrinks pill height
from 48 to 32 — the subagents-track tuck previously had attachments
floating between it and the input.

Adds one Playwright spec asserting the draft-create-agent path submits
the workspace cwd.
2026-05-09 18:32:43 +07:00

73 lines
1.8 KiB
TypeScript

import "@/test/window-local-storage";
import { describe, expect, it } from "vitest";
import { __draftStoreTestUtils } from "./draft-store";
describe("draft-store lifecycle", () => {
it("prunes finalized tombstones after TTL", () => {
const nowMs = 1_000_000;
const drafts = {
oldSent: {
input: { text: "", attachments: [] },
lifecycle: "sent" as const,
updatedAt: 0,
version: 2,
},
recentAbandoned: {
input: { text: "", attachments: [] },
lifecycle: "abandoned" as const,
updatedAt: nowMs + 2 * 60 * 1000,
version: 2,
},
active: {
input: { text: "a", attachments: [] },
lifecycle: "active" as const,
updatedAt: 0,
version: 1,
},
};
const pruned = __draftStoreTestUtils.pruneFinalizedDraftRecords({
drafts,
nowMs: nowMs + 6 * 60 * 1000,
});
expect(pruned.oldSent).toBeUndefined();
expect(pruned.recentAbandoned).toBeDefined();
expect(pruned.active).toBeDefined();
});
it("normalizes clear-with-lifecycle into a tombstone without attachments", () => {
const cleared = __draftStoreTestUtils.applyClearDraftRecord({
record: {
input: {
text: "hello",
attachments: [
{
kind: "image",
metadata: {
id: "att-1",
mimeType: "image/jpeg",
storageType: "web-indexeddb",
storageKey: "att-1",
createdAt: 1,
},
},
],
},
lifecycle: "active",
updatedAt: 1,
version: 1,
},
lifecycle: "sent",
nowMs: 2,
});
expect(cleared).toEqual({
input: { text: "", attachments: [] },
lifecycle: "sent",
updatedAt: 2,
version: 2,
});
});
});