feat(attachments): support local files and video attachments (#6321)
* feat(attachments): support local files and video attachments Share gateway inspection and send validation for borrowed local paths while preserving binary uploads, original-file ownership, and existing limits. Related to NAN-284. Native provider video input remains outside this change. * test: make cross-platform verification fixtures self-contained * test(webui): align typed fixtures with runtime contracts * fix(webui): preserve uploaded video playback during history sync * test(tui): preserve local attachment drafts across resizes * perf(attachments): preserve upload caches and release video previews * docs(webui): keep attachment guidance user-focused * chore: remove redundant dependency comment * test(providers): make stream idle renewal timing deterministic * fix(attachments): keep upload byte limits out of local references Validate common format/count rules separately from upload byte budgets. Keep local inspection and send-time checks metadata-only, and exclude local references from composer and pending-upload totals. Explain upload size rejections with actual size and maximum in all ten locales. Related to NAN-284. * fix(attachments): retain image references and draft order * fix(attachments): close local reference UX and authorization gaps * fix(attachments): preserve focus during asynchronous path confirmation
This commit is contained in:
1 parent
7dfeff9ddf
commit
254f94b068
65 files changed
+1816
-292
No files matched your search
@@ -665,6 +665,33 @@ describe("ThreadShell", () => {
|
||||
expect(client.sendMessage).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("restores the landing attachment draft in its created topic after a gateway rejection", async () => {
|
||||
const client = { ...makeClient(), sendAttachments: vi.fn().mockRejectedValue(new Error("file not found")) };
|
||||
const store = new ComposerDraftStore();
|
||||
store.set("new:chat", {
|
||||
text: "keep the first draft", sessionMentions: [], quotedContext: null,
|
||||
attachments: [{ path: "/project/video.mp4", name: "video.mp4", size: 8, mime: "video/mp4", kind: "video", url: "" }],
|
||||
});
|
||||
const onCreateChat = vi.fn().mockResolvedValue("created");
|
||||
const shell = (id: string | null) => wrap(client, <ThreadShell session={id ? session(id) : null}
|
||||
title="First attachment" draftStore={store} onToggleSidebar={() => {}} onCreateChat={onCreateChat} />);
|
||||
const view = render(shell(null));
|
||||
await screen.findByTestId("composer-chip");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
await waitFor(() => expect(onCreateChat).toHaveBeenCalledTimes(1));
|
||||
view.rerender(shell("created"));
|
||||
await waitFor(() => expect(screen.getByRole("textbox")).toHaveValue("keep the first draft"));
|
||||
expect(await screen.findByTestId("composer-chip")).toHaveTextContent("video.mp4");
|
||||
expect(screen.getByRole("alert")).toHaveTextContent("file not found");
|
||||
expect(store.get("websocket:created")?.attachments).toHaveLength(1);
|
||||
expect(store.has("new:chat")).toBe(false);
|
||||
client.sendAttachments.mockResolvedValue(undefined);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
await waitFor(() => expect(screen.queryByTestId("composer-chip")).not.toBeInTheDocument());
|
||||
expect(screen.getByRole("textbox")).toHaveValue("");
|
||||
expect(client.sendAttachments).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("clears the welcome draft after a delayed new-chat send and an unchanged round-trip", async () => {
|
||||
const client = makeClient();
|
||||
const store = new ComposerDraftStore();
|
||||
@@ -694,7 +721,7 @@ describe("ThreadShell", () => {
|
||||
const client = makeClient();
|
||||
let draftStore = new ComposerDraftStore();
|
||||
draftStore.set("websocket:reload-draft", {
|
||||
text: "original", files: [], sessionMentions: [], quotedContext: "quoted answer",
|
||||
text: "original", attachments: [], sessionMentions: [], quotedContext: "quoted answer",
|
||||
});
|
||||
const shell = () => wrap(client, (
|
||||
<ThreadShell session={session("reload-draft")} title="Reload test" temporary={temporary}
|
||||
@@ -740,8 +767,8 @@ describe("ThreadShell", () => {
|
||||
it.each([false, true])("keeps text and quote drafts scoped to the session (temporary=%s)", async (temporary) => {
|
||||
const client = makeClient();
|
||||
const draftStore: ComposerDraftStore = new Map([
|
||||
["websocket:draft-a", { text: "draft A", files: [], sessionMentions: [], quotedContext: "quote A" }],
|
||||
["websocket:draft-b", { text: "draft B", files: [], sessionMentions: [], quotedContext: "quote B" }],
|
||||
["websocket:draft-a", { text: "draft A", attachments: [], sessionMentions: [], quotedContext: "quote A" }],
|
||||
["websocket:draft-b", { text: "draft B", attachments: [], sessionMentions: [], quotedContext: "quote B" }],
|
||||
]);
|
||||
const shell = (chatId: string) => wrap(client, (
|
||||
<ThreadShell session={session(chatId)} title="Draft test" temporary={temporary}
|
||||
|
||||
Reference in new issue
Block a user