Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Autopilot chat: attach up to four pictures to a message

Bowen Xuee05a6cefb3ca
diff --git a/freevideo_engine/agent/attachments.py b/freevideo_engine/agent/attachments.py
index 2767b45..b6669fc 100644
--- a/freevideo_engine/agent/attachments.py
+++ b/freevideo_engine/agent/attachments.py
@@ -1,4 +1,5 @@
"""Chat images in the retained input assets directory, with server-owned filenames."""
+import filecmp
import json
import os
from pathlib import Path
@@ -48,7 +49,11 @@ def publish(input_root, temporary, name, original_name):
os.replace(pending, metadata)
finally:
pending.unlink(missing_ok=True)
- os.replace(temporary, target)
+ # Identical bytes are already in place; replacing a file the page is reading fails on Windows.
+ if target.is_file() and filecmp.cmp(temporary, target, shallow=False):
+ Path(temporary).unlink(missing_ok=True)
+ else:
+ os.replace(temporary, target)
return json.loads(metadata.read_text(encoding='utf-8'))['original_name']
diff --git a/web/agent_session.js b/web/agent_session.js
index 9eb20b7..d4a4998 100644
--- a/web/agent_session.js
+++ b/web/agent_session.js
@@ -45,6 +45,18 @@ export async function agentSend(api, method, path, body, headers = {}) {
// UI actions retry once, including HTTP refusals. Callers keep the same
// idempotency id/body and show the result where the user clicked.
+// Raw bytes (one picture) with the same page session and one retry after a restart.
+export async function agentUpload(api, path, body, signal) {
+ for (let attempt = 0; ; attempt++) {
+ const response = await api.fetchApi(path, {method: 'POST', credentials: 'same-origin', signal, body,
+ headers: {'Content-Type': 'application/octet-stream', ...await agentHeaders(api)}});
+ if (response.status !== 403 || attempt) return response;
+ const value = await response.clone().json().catch(() => null);
+ if (value?.error?.code !== 'page_session_required') return response;
+ sessions.delete(api);
+ }
+}
+
export async function retryAgentPost(api, path, body, {retry = async () => body, accept = () => true} = {}) {
for (let attempt = 0; attempt < 2; attempt++) {
let response = null;
diff --git a/web/autopilot_chat.css b/web/autopilot_chat.css
index 532c7ac..593ca5b 100644
--- a/web/autopilot_chat.css
+++ b/web/autopilot_chat.css
@@ -128,7 +128,7 @@
@keyframes fv-chat-breathe{0%,100%{opacity:.25}40%{opacity:1}}
.fv-studio .fv-chat-down{position:absolute;right:max(40px,calc(50% - 360px));bottom:96px;width:34px;height:34px;min-height:0;padding:0;border-radius:50%;background:var(--fv-raised);box-shadow:0 6px 18px #0008}
.fv-chat svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round}
-.fv-chat-input{box-sizing:border-box;justify-self:center;width:100%;max-width:720px;min-height:54px;display:grid;grid-template-columns:minmax(0,1fr) auto auto auto;gap:10px;align-items:end;border:1px solid var(--fv-border);background:#0e151e;border-radius:14px;padding:8px 8px 8px 16px;transition:border-color var(--fv-quick),box-shadow var(--fv-quick)}
+.fv-chat-input{box-sizing:border-box;justify-self:center;width:100%;max-width:720px;min-height:54px;display:grid;grid-template-columns:minmax(0,1fr) auto auto auto auto;gap:10px;align-items:end;border:1px solid var(--fv-border);background:#0e151e;border-radius:14px;padding:8px 8px 8px 16px;transition:border-color var(--fv-quick),box-shadow var(--fv-quick)}
.fv-chat-notice-row{justify-self:center;width:100%;max-width:720px;display:flex;align-items:center;flex-wrap:wrap;gap:4px 12px}.fv-chat-notice-row>.fv-issue-button{margin:6px 0}
.fv-chat-notice{flex:0 1 auto;margin:6px 0;font-size:14px;color:var(--fv-ink)}
.fv-chat-preview[data-loading=true] .fv-chat-play::before{border-color:var(--fv-accent);animation:fv-chat-breathe 1s infinite}
@@ -141,11 +141,11 @@
.fv-studio.fv-autopilot .fv-chat-input textarea,.fv-chat-input textarea{box-sizing:border-box;width:100%;height:36px;min-height:36px;max-height:none;padding:7px 0;border:0;border-radius:0;background:none;color:var(--fv-ink);font-size:14.5px;line-height:22px;resize:none;outline:none;overflow-y:auto}
.fv-chat-input textarea::placeholder{color:var(--fv-disabled)}
.fv-chat-input textarea{min-width:0}
-.fv-studio :is(.fv-chat-whitebox,.fv-chat-scenes){height:36px;min-height:36px;padding:0 8px;gap:5px;border:1px solid var(--fv-border);border-radius:9px;background:transparent;color:var(--fv-muted);font-size:12px;white-space:nowrap}
-:is(.fv-chat-whitebox,.fv-chat-scenes) svg{flex:none}
+.fv-studio :is(.fv-chat-whitebox,.fv-chat-scenes,.fv-chat-attach){height:36px;min-height:36px;padding:0 8px;gap:5px;border:1px solid var(--fv-border);border-radius:9px;background:transparent;color:var(--fv-muted);font-size:12px;white-space:nowrap}
+:is(.fv-chat-whitebox,.fv-chat-scenes,.fv-chat-attach) svg{flex:none}
.fv-studio .fv-chat-whitebox[aria-pressed=true]{background:var(--fv-selected);border-color:var(--fv-accent);color:var(--fv-accent)}
-.fv-studio :is(.fv-chat-whitebox,.fv-chat-scenes):disabled{opacity:.45;cursor:not-allowed}
-.fv-studio :is(.fv-chat-whitebox,.fv-chat-scenes):focus-visible{outline:2px solid var(--fv-accent);outline-offset:2px}
+.fv-studio :is(.fv-chat-whitebox,.fv-chat-scenes,.fv-chat-attach):disabled{opacity:.45;cursor:not-allowed}
+.fv-studio :is(.fv-chat-whitebox,.fv-chat-scenes,.fv-chat-attach):focus-visible{outline:2px solid var(--fv-accent);outline-offset:2px}
.fv-studio .fv-chat-send{width:36px;height:36px;min-height:0;padding:0;border:0;border-radius:9px;background:var(--fv-accent);color:var(--fv-bg)}
.fv-studio .fv-chat-send:hover:not(:disabled){background:var(--fv-accent-hover)}
.fv-studio .fv-chat-send:disabled{opacity:1;background:#22344a;color:#9fb3c8}
@@ -163,7 +163,7 @@
.fv-chat[data-chats-open=true] .fv-chat-conversations:not([hidden]){display:flex}
}
@media(max-width:480px){.fv-chat-main{padding:0 14px 14px}.fv-chat-scroll{margin:0 -14px;padding:16px 14px 2px}.fv-chat-hello{padding-top:32px}.fv-chat-job{max-width:none;gap:12px}.fv-chat-confirm{max-width:none}
-@media(max-width:560px){.fv-studio .fv-chat-scenes{width:36px;padding:0;justify-content:center}.fv-chat-scenes>span{display:none}}
+@media(max-width:560px){.fv-studio :is(.fv-chat-scenes,.fv-chat-whitebox){width:36px;padding:0;justify-content:center}:is(.fv-chat-scenes,.fv-chat-whitebox)>span{display:none}}
.fv-chat-preview,.fv-chat-preview[data-shape=wide]{width:98px}.fv-chat-length{display:none}.fv-chat-percent{font-size:22px}.fv-studio.fv-autopilot .fv-chat-input textarea{font-size:16px}.fv-studio .fv-chat-down{right:14px;bottom:84px}}
@media(prefers-reduced-motion:reduce){.fv-chat-water,.fv-chat-percent,.fv-chat-parts>i::after{transition:none}.fv-chat-water::after,.fv-chat-dots>i,.fv-chat-preview>img,.fv-chat-menu{animation:none}}
@@ -184,3 +184,18 @@
.fv-studio .fv-chat-scene-item:focus-visible{outline:2px solid var(--fv-accent);outline-offset:-2px}
.fv-chat-main > .fv-request-assets{font-size:12px;line-height:1.5;margin:0 0 6px;padding:0 4px}
.fv-chat-main > .fv-request-assets[hidden]{display:none}
+
+.fv-studio .fv-chat-attach{width:36px;padding:0;justify-content:center}
+.fv-chat-attached{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:8px;margin:0 0 2px;padding:0;list-style:none}
+.fv-chat-attached[hidden]{display:none}
+.fv-chat-attached>li{position:relative;width:52px;height:52px;border-radius:9px;overflow:hidden;border:1px solid var(--fv-border);transition:opacity var(--fv-quick)}
+.fv-chat-attached>li[data-state=uploading]{opacity:.55}
+.fv-chat-attached>li[data-state=failed]{border:2px solid var(--fv-danger);cursor:pointer}
+.fv-chat-attached>li:focus-visible{outline:2px solid var(--fv-accent);outline-offset:2px}
+.fv-chat-thumb{display:grid;place-items:center;width:100%;height:100%;background:var(--fv-hover)}
+.fv-chat-thumb img{display:block;width:100%;height:100%;object-fit:cover}
+.fv-chat-thumb[data-broken] svg{display:block;width:24px;height:24px;fill:none;stroke:var(--fv-muted);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
+.fv-studio .fv-chat-attached .fv-chat-attached-x{position:absolute;top:2px;right:2px;width:20px;height:20px;min-height:0;padding:0;border:1px solid rgba(255,255,255,.22);border-radius:50%;background:rgba(8,12,18,.9)!important;color:var(--fv-ink);font-size:14px;line-height:1}
+.fv-chat-refs{width:max-content;max-width:100%;display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;margin:0 0 6px auto;padding:0;list-style:none}
+.fv-chat-refs>li{width:96px;height:96px;border-radius:10px;overflow:hidden}
+@media(max-width:560px){.fv-chat-refs>li{width:64px;height:64px}}
diff --git a/web/autopilot_chat.js b/web/autopilot_chat.js
index 6308a9a..a1fdeca 100644
--- a/web/autopilot_chat.js
+++ b/web/autopilot_chat.js
@@ -1,10 +1,11 @@
// The conversation with the connected agent: what the user says, what the agent answers, and the agent's jobs as
// cards at the place they happened. Reads and sends use the page session; the agent's token never enters the page.
import {agentGet, agentPost, retryAgentPost} from './agent_session.js';
+import {ATTACH, attachmentURL, pickPictures, thumbnail, uploadPicture} from './chat_attachments.js';
import {SCENE_TEXT, sceneList, startScene, watchScene} from './whitebox_scenes.js';
import {chatData, chatDelay, chatReadRequest, emptyChat, chatMerge, chatEntries, canSend, newId, SEND_ATTEMPTS, WAIT_FOR_AGENT, sendRefused, sendError} from './chat_data.js';
export {emptyChat, chatMerge, chatEntries, canSend} from './chat_data.js';
-import {isolateDialogKeys, routeDialogKey} from './dialog_keys.js';
+import {isolateDialogKeys, listenDialogKey, routeDialogKey} from './dialog_keys.js';
import {closeDialog} from './motion.js';
import { estimatedFraction, remainingAbove, remainingShown, createDiagnosticReportControl } from './generation_progress.js';
import {createErrorReport} from './error_panel.js';
@@ -259,7 +260,7 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
sendButton.classList.toggle('fv-chat-halt', stopMode);
sendButton.setAttribute('aria-label', label); sendButton.title = stopMode ? label : '';
sendButton.querySelector('path').setAttribute('d', stopMode ? STOP_GLYPH : SEND_GLYPH);
- sendButton.disabled = stopMode ? false : !composeAllowed() || draftSending() || !input.value.trim();
+ sendButton.disabled = stopMode ? false : !composeAllowed() || draftSending() || !readyPictures().length && !input.value.trim() || stagedList().some(item => !item.attachment);
}
async function abandon() {
const session = state.session;
@@ -319,7 +320,72 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
}
} catch (failure) { sceneWaiting = false; say(t(...SCENE_TEXT.failed) + reason(failure)); }
}
- form.append(input, scenesButton, whiteboxButton, sendButton); scroller.append(log); main.append(scroller, down, sceneMenu, form); element.append(main);
+ // Pictures waiting to be sent, per conversation draft: {key, url, attachment|null}. A picture is uploaded the moment it is added.
+ const attachButton = press('fv-chat-attach', null, () => fileInput.click()), fileInput = el('input'), strip = el('ul', 'fv-chat-attached');
+ attachButton.append(glyph(ATTACH.icon)); attachButton.title = t(...ATTACH.add); attachButton.setAttribute('aria-label', attachButton.title);
+ fileInput.type = 'file'; fileInput.accept = ATTACH.types.join(','); fileInput.multiple = true; fileInput.hidden = true;
+ strip.hidden = true; strip.setAttribute('aria-label', t('Attached pictures', '已添加的图片'));
+ const staged = new Map(), uploads = new Set();
+ const stagedList = (session = draftSession) => { if (!staged.has(session)) staged.set(session, []); return staged.get(session); };
+ const readyPictures = () => stagedList().filter(item => item.attachment).map(item => ({...item.attachment, preview: item.url}));
+ function renderStrip() {
+ const list = stagedList();
+ strip.hidden = !list.length;
+ strip.replaceChildren(...list.map(item => {
+ const li = el('li'), drop = press('fv-chat-attached-x', '×', () => removePicture(item));
+ li.dataset.state = item.failed ? 'failed' : item.attachment ? 'ready' : 'uploading';
+ drop.title = t(...ATTACH.remove); drop.setAttribute('aria-label', drop.title);
+ li.append(thumbnail(item.url), drop);
+ // A picture that did not upload is tried again by clicking it.
+ if (item.failed === 'failed') {
+ li.tabIndex = 0; li.setAttribute('role', 'button'); li.title = t(...ATTACH.retry); li.setAttribute('aria-label', li.title);
+ li.addEventListener('click', event => { if (event.target === drop) return; void upload(item, list); });
+ li.addEventListener('keydown', event => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); void upload(item, list); } });
+ }
+ return li;
+ }));
+ grow();
+ }
+ function removePicture(item) {
+ item.controller?.abort();
+ for (const list of staged.values()) { const at = list.indexOf(item); if (at >= 0) list.splice(at, 1); }
+ URL.revokeObjectURL?.(item.url); renderStrip(); input.focus();
+ }
+ async function upload(item, list, session = draftSession) {
+ item.controller = new AbortController(); item.failed = null; uploads.add(item); renderStrip();
+ try {
+ item.attachment = await uploadPicture(api, item.file, item.controller.signal);
+ // The same picture twice is one stored picture; the copy is dropped.
+ if (list.some(other => other !== item && other.attachment?.name === item.attachment.name)) removePicture(item);
+ } catch (failure) {
+ if (!failure?.problem) return;
+ // Unreadable pictures are taken out; an upload that failed stays, marked, to be tried again.
+ if (failure.problem === 'unreadable') { const at = list.indexOf(item); if (at >= 0) list.splice(at, 1); URL.revokeObjectURL?.(item.url); }
+ else item.failed = 'failed';
+ if (session === draftSession) say(t(...ATTACH[failure.problem]));
+ } finally { uploads.delete(item); if (!stopped && session === draftSession) renderStrip(); }
+ }
+ function addPictures(files) {
+ files = [...files || []];
+ if (!files.length || !composeAllowed()) return;
+ const session = draftSession, list = stagedList(session), {accepted, problem} = pickPictures(files, ATTACH.count - list.length);
+ say(problem ? t(...ATTACH[problem]) : '');
+ for (const file of accepted) {
+ const item = {name: file.name, file, url: URL.createObjectURL(file), attachment: null, failed: null, controller: null};
+ list.push(item); void upload(item, list, session);
+ }
+ renderStrip();
+ }
+ fileInput.addEventListener('change', () => { addPictures(fileInput.files); fileInput.value = ''; });
+ listenDialogKey(input, 'paste', event => {
+ const files = [...event.clipboardData?.files || []].filter(file => file.type.startsWith('image/'));
+ if (files.length) { event.preventDefault(); addPictures(files); }
+ });
+ for (const type of ['dragover', 'drop']) main.addEventListener(type, event => {
+ if (![...event.dataTransfer?.types || []].includes('Files')) return;
+ event.preventDefault(); if (type === 'drop') addPictures(event.dataTransfer.files);
+ });
+ form.append(strip, input, attachButton, scenesButton, whiteboxButton, sendButton, fileInput); scroller.append(log); main.append(scroller, down, sceneMenu, form); element.append(main);
const notice = el('p', 'fv-chat-notice'); notice.hidden = true; notice.setAttribute('role', 'status');
const noticeRow = el('div', 'fv-chat-notice-row'); noticeRow.append(notice); main.insertBefore(noticeRow, form);
// What the next video would download first, the studio's line, above the box the request is typed in.
@@ -364,7 +430,7 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
saveDraft(); grow(); return;
}
if (draftSession === session) return;
- saveDraft(); draftSession = session; input.value = drafts.get(session)?.text || ''; grow();
+ saveDraft(); draftSession = session; input.value = drafts.get(session)?.text || ''; renderStrip();
}
const reason = error => error?.message || t('Connection lost. Try again.', '连接中断,请重试。');
async function requestError(response) {
@@ -711,9 +777,18 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
// ---- one entry of the conversation each ----
function message(role) {
const item = el('li', role === 'user' ? 'fv-chat-me' : 'fv-chat-ai'), text = el('p'); item.append(text);
- let status = null, error = null, retry = null, report = null;
+ let status = null, error = null, retry = null, report = null, shown = '';
return {element: item, update(entry) {
- text.textContent = entry.text;
+ text.textContent = entry.text; text.hidden = !entry.text && !!entry.attachments?.length;
+ const names = (entry.attachments || []).map(picture => picture.name).join('|');
+ if (names !== shown) {
+ shown = names; item.querySelector('.fv-chat-refs')?.remove();
+ if (names) {
+ const row = el('ul', 'fv-chat-refs');
+ for (const picture of entry.attachments) { const li = el('li'); li.append(thumbnail(picture.preview || attachmentURL(api, picture.name))); row.append(li); }
+ item.prepend(row);
+ }
+ }
if (role !== 'user') return;
item.dataset.taken = String(entry.taken !== false);
item.dataset.failed = String(!!entry.error);
@@ -1159,19 +1234,24 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
drafts.delete(entry.session);
if (draftSession === entry.session) { input.value = ''; grow(); }
}
+ if (entry.attachments?.length) {
+ const list = stagedList(entry.session), sent = new Set(entry.attachments.map(item => item.name));
+ staged.set(entry.session, list.filter(item => !sent.has(item.attachment?.name)));
+ if (draftSession === entry.session) renderStrip();
+ }
}
const waitingNotice = code => (code ? code === 'not_listening' : state.agent.connected === true)
? t('Will send when Agent is back', '等 Agent 回来后自动发送')
: t('Will send when Agent connects', '等 Agent 连上后自动发送');
- async function send(text, original = null, draft = null, automatic = false) {
+ async function send(text, original = null, draft = null, automatic = false, attachments = null) {
text = String(text).trim();
original ||= pending.find(entry => entry.session === (state.session ?? null) && entry.text === text && (entry.error || entry.sending || entry.automatic));
- if (!text || original?.sending || original && original.session !== state.session) return false;
+ if (!text && !(original?.attachments || attachments)?.length || original?.sending || original && original.session !== state.session) return false;
if (!inSelectedChat()) {
say(creating ? t('Creating a new chat…', '正在新建对话…') : t('Loading this chat. Please send again shortly.', '正在读取对话,请稍后再发一次'));
return false;
}
- const entry = original || {id: newId(), text, session: state.session ?? null, draft, whiteboxPreview: whiteboxPreview && state.agent?.builtin !== true};
+ const entry = original || {id: newId(), text, attachments: attachments || [], session: state.session ?? null, draft, whiteboxPreview: whiteboxPreview && state.agent?.builtin !== true};
if (draft) entry.draft = draft;
if (!original) pending.push(entry);
if (!automatic) entry.attempts = 0;
@@ -1243,9 +1323,10 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
if (stopMode) { void abandon(); return; }
const text = input.value;
const draft = saveDraft();
- if (!text.trim() || !composeAllowed() || draftSending()) return;
+ const pictures = readyPictures();
+ if (!text.trim() && !pictures.length || !composeAllowed() || draftSending() || stagedList().some(item => !item.attachment)) return;
const failed = pending.find(entry => entry.session === state.session && entry.draft === draft && entry.error);
- void send(text, failed, draft);
+ void send(text, failed, draft, false, pictures);
});
// Both a server-side session change and a list selection reset the same reader. Job clocks stay keyed by job id.
diff --git a/web/chat_attachments.js b/web/chat_attachments.js
new file mode 100644
index 0000000..68a1375
--- /dev/null
+++ b/web/chat_attachments.js
@@ -0,0 +1,54 @@
+// Pictures attached to a chat message: limits, checks, upload and thumbnail address.
+import {agentUpload} from './agent_session.js';
+
+export const ATTACH = {
+ count: 4, bytes: 10 * 1024 * 1024, types: ['image/png', 'image/jpeg', 'image/webp'],
+ add: ['Add pictures', '添加图片'], remove: ['Remove', '移除'],
+ tooMany: ['Up to 4 pictures per message.', '一条消息最多 4 张图片。'],
+ tooLarge: ['Each picture must be under 10 MB.', '每张图片不能超过 10 MB。'],
+ notPicture: ['Only pictures can be added.', '只能添加图片。'],
+ unreadable: ['Could not read this picture. Please choose another one.', '无法读取这张图片,请换一张。'],
+ failed: ['Could not upload the picture. Click it to try again.', '图片上传失败,请点击该图片重试。'],
+ retry: ['Upload again', '重新上传'],
+ icon: 'M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zM4 16l4-4 4 4 3-3 5 5M15 9h.01',
+};
+
+// Splits files into the ones that fit and the first reason for leaving one out: {accepted, problem}.
+export function pickPictures(files, room) {
+ const accepted = []; let problem = null;
+ for (const file of files) {
+ if (!ATTACH.types.includes(file.type)) problem ||= 'notPicture';
+ else if (file.size > ATTACH.bytes) problem ||= 'tooLarge';
+ else if (accepted.length >= room) problem ||= 'tooMany';
+ else accepted.push(file);
+ }
+ return {accepted, problem};
+}
+
+export const attachmentURL = (api, name) => {
+ const path = '/freevideo/agent/chat/attachment?' + new URLSearchParams({name});
+ return api.apiURL?.(path) || path;
+};
+
+// Resolves to the attachment object; rejects with {problem} naming a key of ATTACH.
+export async function uploadPicture(api, file, signal) {
+ let response;
+ try { response = await agentUpload(api, '/freevideo/agent/chat/attach?' + new URLSearchParams({name: file.name || 'picture'}), file, signal); }
+ catch (error) { if (signal?.aborted) throw {problem: null}; throw {problem: 'failed'}; }
+ if (response.status === 201 || response.ok) {
+ const value = await response.json().catch(() => null);
+ if (value?.name) return value;
+ throw {problem: 'failed'};
+ }
+ const code = (await response.json().catch(() => null))?.error?.code;
+ throw {problem: code === 'too_large' ? 'tooLarge' : code === 'invalid_media' ? 'unreadable' : 'failed', code};
+}
+
+// A thumbnail that turns into a grey cell with the picture glyph when the picture cannot be shown.
+export function thumbnail(src) {
+ const cell = document.createElement('span'), image = document.createElement('img');
+ cell.className = 'fv-chat-thumb'; image.alt = ''; image.draggable = false;
+ image.addEventListener('error', () => { cell.dataset.broken = 'true'; image.remove(); cell.innerHTML = `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${ATTACH.icon}"/></svg>`; });
+ image.src = src; cell.append(image);
+ return cell;
+}
diff --git a/web/chat_data.js b/web/chat_data.js
index 592c74a..a5bb9f9 100644
--- a/web/chat_data.js
+++ b/web/chat_data.js
@@ -63,6 +63,7 @@ export async function previewUnsupported(response, field) {
}
export async function sendChatMessage(api, entry, {sessionSupported = true, stopped = () => false, previewField = null} = {}) {
const body = {id: entry.id, text: entry.text};
+ if (entry.attachments?.length) body.attachments = entry.attachments.map(({preview, ...rest}) => rest);
if (sessionSupported && entry.session) body.session = entry.session;
if (entry.whiteboxPreview && previewField) body[previewField] = true;
entry.attempts = (entry.attempts || 0) + 1;
diff --git a/web/health.js b/web/health.js
index e206293..ad011fe 100644
--- a/web/health.js
+++ b/web/health.js
@@ -13,7 +13,7 @@ const t = (en, zh) => cn ? zh : en;
// launcher.js removes this flag during setup; read it before that.
const launchVisit = query.get('freevideo') === 'launch';
// Every script this folder ships; a test keeps the list in step with web/*.js.
-export const MODULES = ['chat_data.js', 'phone_model.js', 'phone.js', 'lan_access.js', 'qrcodegen.js', 'agent_activity.js', 'agent_connect.js', 'agent_session.js', 'autopilot.js', 'autopilot_chat.js', 'autopilot_conversations.js', 'browser_extension.js', 'caret_rect.js', 'chain_support.js', 'capability_view.js', 'cast_generate.js', 'cast_mention.js', 'cast_overlay.js', 'cast_source.js', 'compatibility.js', 'entry_showcase.js', 'error_panel.js', 'first_run_guide.js', 'fonts.js', 'freevideo.js', 'generation_progress.js',
+export const MODULES = ['chat_data.js', 'phone_model.js', 'phone.js', 'lan_access.js', 'qrcodegen.js', 'agent_activity.js', 'agent_connect.js', 'agent_session.js', 'autopilot.js', 'autopilot_chat.js', 'chat_attachments.js', 'autopilot_conversations.js', 'browser_extension.js', 'caret_rect.js', 'chain_support.js', 'capability_view.js', 'cast_generate.js', 'cast_mention.js', 'cast_overlay.js', 'cast_source.js', 'compatibility.js', 'entry_showcase.js', 'error_panel.js', 'first_run_guide.js', 'fonts.js', 'freevideo.js', 'generation_progress.js',
'editor.js', 'editor_actions.js', 'editor_lifecycle.js', 'editor_adjust.js', 'editor_adjust_picture.js', 'editor_picture_fields.js', 'editor_picture_session.js', 'editor_preview_picture.js', 'editor_entry.js', 'editor_expand.js', 'editor_export_dialog.js', 'editor_first_frame.js', 'editor_media_references.js', 'editor_references.js', 'editor_genbar.js', 'editor_geometry.js', 'editor_library.js', 'editor_menu.js', 'editor_model.js', 'editor_frame.js', 'editor_player.js', 'editor_room.js', 'editor_select.js', 'editor_state.js', 'editor_store.js', 'editor_tracks.js', 'editor_generation.js', 'editor_transport.js', 'editor_transport_model.js', 'editor_audio.js', 'editor_audio_model.js', 'editor_audio_notes.js', 'editor_audio_replace.js', 'editor_audio_rules.js', 'editor_speed.js', 'editor_speed_model.js', 'editor_failure.js', 'editor_header_fit.js',
'editor_loader.js', 'editor_text_coverage.js', 'editor_text.js', 'editor_toolbar_more.js', 'editor_text_model.js', 'editor_text_layout.js', 'editor_notes.js', 'editor_icons.js', 'dialog_keys.js', 'done_notify.js', 'failure_issue.js', 'feedback.js', 'frame_sizes.js', 'health.js', 'image_commands.js', 'image_editor.js', 'image_editor_engine.js', 'image_generation.js', 'launch_visit.js', 'launcher.js', 'length_plan.js', 'lora_triggers.js', 'lora_check.js', 'library.js', 'motion.js', 'native_errors.js', 'translate_guard.js', 'output_download.js', 'port_notice.js', 'preview_scene.js',
'progress_connection.js', 'prompt_draft.js', 'prompt_enhance.js', 'prompt_references.js', 'prompt_terms.js', 'request_assets.js', 'repair_hint.js', 'report_issue.js', 'issue_button.js', 'studio_recent.js',