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.

Image generation history and size tiers

Bowen Xuebc0b2152bbf0
diff --git a/freevideo_engine/image_gen/service.py b/freevideo_engine/image_gen/service.py
index 852cfaa..a0b2808 100644
--- a/freevideo_engine/image_gen/service.py
+++ b/freevideo_engine/image_gen/service.py
@@ -23,6 +23,11 @@ BODY_LIMIT = 64 * 1024
CANCEL_GRACE = 5.
MAX_IMAGES = 4
REPORT_LIMIT = 16
+HISTORY_NAME = re.compile(r'image-\d{8}-\d{6}-\d{2}\.png')
+LEGACY_NAME = re.compile(r'[0-9a-f]{32}\.png')
+HISTORY_LIMIT = 500
+# The 高清 size is offered from this much card memory; smaller cards keep one size.
+HIGH_SIZE_MIN_TOTAL = 6 * 1024 ** 3
INFERENCE_TIMEOUT = 600.
QUEUE_TIMEOUT = 600.
QUEUE_POLL = .1
@@ -147,12 +152,32 @@ class Service:
checking=not ready and image_pack.checking(machine['model_root']),
downloading=not ready and image_pack.downloading(machine['model_root'], engine_root),
bytes=sum(row['bytes'] for row in spec['groups']['image']), busy=self.busy(),
- max_images=MAX_IMAGES, install=self.pack_state(ready),
+ max_images=MAX_IMAGES, sizes=self.size_tiers(machine), install=self.pack_state(ready),
segment=dict(ready=image_pack.ready(machine['model_root'], group='segment'),
max_points=16, device='cpu',
install=self.segment_installer.state() if self.segment_installer else None),
bytes_per_second=None if ready else observed_speed(engine_root))
+ def size_tiers(self, machine):
+ """The sizes this card offers: the standard one always, the high one only with enough card memory."""
+ total = None
+ if machine.get('device_backend', 'cuda') == 'cuda':
+ from ..background_room import Gpu
+ from ..gpu_budget import open_bounded
+
+ def read():
+ gpu = Gpu(machine.get('gpu_uuid'))
+ try:
+ memory = gpu.memory()
+ return memory[1] if memory else None
+ finally:
+ gpu.close()
+ try:
+ total = open_bounded(read, .5)
+ except (OSError, RuntimeError, AttributeError, ValueError):
+ total = None
+ return ['standard', 'high'] if total and total >= HIGH_SIZE_MIN_TOTAL else ['standard']
+
def pack_state(self, ready):
"""Progress of the download this page started, in both languages for a failure."""
installer = self.pack_installer
@@ -200,13 +225,72 @@ class Service:
raise ValueError('invalid_media')
return str(path)
- def output_path(self):
+ def output_directory(self):
directory = Path(self.input_directory()).resolve()
output = directory / 'freevideo-image'
if output.is_symlink() or output.resolve().parent != directory:
raise ValueError('invalid_media')
output.mkdir(exist_ok=True)
- return str(output / (uuid.uuid4().hex + '.png'))
+ return output
+
+ def output_path(self, named=False):
+ """A new picture's path. Generated pictures get a readable name that the history lists."""
+ output = self.output_directory()
+ if not named:
+ return str(output / (uuid.uuid4().hex + '.png'))
+ stamp = time.strftime('image-%Y%m%d-%H%M%S')
+ for number in range(1, 100):
+ path = output / ('%s-%02d.png' % (stamp, number))
+ if not path.exists():
+ return str(path)
+ raise ValueError('invalid_media')
+
+ def legacy_picture(self, path):
+ """A picture from before generated names: a bare random name whose PNG is colour, since masks are grey."""
+ if not LEGACY_NAME.fullmatch(path.name) or path.is_symlink() or not path.is_file():
+ return False
+ try:
+ with path.open('rb') as handle:
+ head = handle.read(26)
+ except OSError:
+ return False
+ return head[:8] == b'\x89PNG\r\n\x1a\n' and head[25] in (2, 6)
+
+ def history(self):
+ """Every picture generated here, newest first; the folder is the record, so it outlives sessions."""
+ output = self.output_directory()
+ named, older = [], []
+ for entry in output.iterdir():
+ if HISTORY_NAME.fullmatch(entry.name) and entry.is_file() and not entry.is_symlink():
+ named.append(entry.name)
+ elif self.legacy_picture(entry):
+ try:
+ older.append((entry.stat().st_mtime, entry.name))
+ except OSError:
+ pass
+ names = sorted(named, reverse=True) + [name for _, name in sorted(older, reverse=True)]
+ return dict(items=[dict(file='freevideo-image/' + name, name=name) for name in names[:HISTORY_LIMIT]])
+
+ def history_delete(self, name):
+ leaf = name.rpartition('/')[2] if isinstance(name, str) else ''
+ if not (HISTORY_NAME.fullmatch(leaf) or LEGACY_NAME.fullmatch(leaf)) or name != 'freevideo-image/' + leaf:
+ raise ValueError('invalid_media')
+ path = self.output_directory() / leaf
+ if path.is_symlink() or not path.is_file() or (LEGACY_NAME.fullmatch(leaf) and not self.legacy_picture(path)):
+ raise ValueError('invalid_media')
+ path.unlink()
+ return self.history()
+
+ def history_open(self):
+ """Show the folder in the file manager of this machine."""
+ folder = str(self.output_directory())
+ if os.name == 'nt':
+ os.startfile(folder)
+ else:
+ from .. import processes
+ processes.popen(['xdg-open', folder], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL, start_new_session=True)
+ return dict(opened=True)
def close_segment_worker(self):
from .. import processes
@@ -350,7 +434,7 @@ class Service:
raise ValueError('invalid_media') from None
return dict(prompt=prompt, width=dimensions[0] // 32 * 32, height=dimensions[1] // 32 * 32,
steps=8, seed=seed, images=paths, **(dict(mask=mask_path) if mask_path else {}),
- path=self.output_path())
+ path=self.output_path(named=True))
def start(self, action, value):
if action not in ('generate', 'compose'):
@@ -1065,6 +1149,14 @@ def register():
result = service.pack_action(name.split('-')[1], group='segment')
elif name == 'segment':
result = await asyncio.to_thread(service.segment, value)
+ elif name == 'history':
+ result = service.history()
+ elif name == 'history-delete':
+ result = service.history_delete(value.get('file'))
+ elif name == 'history-open':
+ if request.remote not in ('127.0.0.1', '::1'):
+ raise ValueError('invalid_request')
+ result = service.history_open()
else:
result = service.start(name, value)
return web.json_response(result)
diff --git a/web/image_editor.css b/web/image_editor.css
index 013cf4e..6f4c949 100644
--- a/web/image_editor.css
+++ b/web/image_editor.css
@@ -78,7 +78,22 @@ button.fv-ie-size:hover{background:var(--fv-hover);color:var(--fv-ink)}
.fv-ie-gen-ref-add .fv-ie-menu-list{top:calc(100% + 6px);right:auto;bottom:auto;left:0}
.fv-ie-options.fv-ie-generation[data-empty=true]{grid-template-columns:auto auto minmax(60px,1fr) auto auto}
.fv-ie-generation[data-empty=true]>.fv-ie-button{grid-column:5}
-.fv-ie-generation>#fv-ie-gen-ratio{min-height:32px}
+.fv-ie-gen-shape{display:flex;gap:8px}
+.fv-ie-gen-shape[hidden]{display:none}
+.fv-ie-gen-shape>.fv-ie-select{min-height:32px}
+.fv-ie-gen-shape>.fv-ie-select[hidden],.fv-ie-gen-shape>.fv-ie-seg[hidden]{display:none}
+.fv-ie-gen-history{flex:none}
+.fv-ie-gen-history summary{width:32px;height:32px;display:flex;align-items:center;justify-content:center;border:1px solid var(--fv-border);border-radius:6px}
+.fv-ie-gen-history .fv-ie-menu-list{top:calc(100% + 6px);right:0;bottom:auto;left:auto;width:min(320px,calc(100vw - 16px));max-height:min(420px,70vh)}
+.fv-ie-gen-history .fv-ie-menu-list.fv-ie-gen-history-up{top:auto;bottom:calc(100% + 6px)}
+.fv-ie-gen-history-confirm{opacity:1!important;width:auto!important;padding:0 6px;background:#c0392b!important;color:#fff!important;font-size:var(--fv-micro)}
+.fv-ie-gen-history-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:6px}
+.fv-ie-gen-history-tile{position:relative}
+.fv-ie-gen-history-pick{display:block;width:100%;padding:0;border:0;background:none;cursor:pointer}
+.fv-ie-gen-history-pick img{display:block;width:100%;aspect-ratio:1;object-fit:cover;border-radius:6px;background:var(--fv-raised)}
+.fv-ie-gen-history-use{position:absolute;top:4px;left:4px;width:20px;height:20px;padding:0;border:0;border-radius:10px;background:rgba(0,0,0,.7);color:#fff;font-size:16px;line-height:18px;opacity:0;cursor:pointer}
+.fv-ie-gen-history-tile:hover>.fv-ie-gen-history-use,.fv-ie-gen-history-tile:hover>.fv-ie-gen-history-delete,.fv-ie-gen-history-use:focus-visible,.fv-ie-gen-history-delete:focus-visible{opacity:1}
+.fv-ie-gen-history-delete{opacity:0;top:4px;right:4px;width:20px;height:20px;border-radius:10px;font-size:16px;line-height:18px;background:rgba(0,0,0,.7);color:#fff}
.fv-image-editor .fv-ie-gen-prompt{position:absolute;inset:0 0 auto;width:100%;height:32px;min-height:32px;max-height:80px;resize:none;padding:3px 9px;border:1px solid var(--fv-border);border-radius:var(--fv-r-sm);background:var(--fv-raised);line-height:24px;overflow-y:auto}
.fv-ie-gen-prompt:disabled{opacity:.5}
.fv-ie-gen-note{align-self:center;min-width:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
@@ -261,7 +276,7 @@ button.fv-ie-size:hover{background:var(--fv-hover);color:var(--fv-ink)}
.fv-ie-generation>.fv-ie-seg{grid-column:1/-1;justify-self:start}
.fv-ie-gen-field{grid-column:1;grid-row:2;flex-wrap:wrap;height:auto}
.fv-ie-gen-refs{flex:0 0 100%;overflow-x:auto;height:36px;padding:4px 5px 0}
- .fv-ie-gen-box{flex:1 0 100%}
+ .fv-ie-gen-box{flex:1 0 calc(100% - 40px)}
.fv-image-editor .fv-ie-gen-prompt{font-size:16px}
.fv-ie-generation>.fv-ie-button{grid-column:2;grid-row:2;align-self:end}
.fv-ie-gen-note{grid-column:1/-1;grid-row:3}
@@ -273,7 +288,7 @@ button.fv-ie-size:hover{background:var(--fv-hover);color:var(--fv-ink)}
.fv-ie-generation[data-pack=true]>.fv-ie-gen-note{text-align:right}
.fv-ie-options.fv-ie-generation[data-empty=true]{grid-template-columns:minmax(0,1fr) auto}
.fv-ie-generation[data-empty=true]>.fv-ie-seg{grid-column:1;grid-row:1}
- .fv-ie-generation[data-empty=true]>#fv-ie-gen-ratio{grid-column:2;grid-row:1}
+ .fv-ie-generation[data-empty=true]>.fv-ie-gen-shape{grid-column:2;grid-row:1}
.fv-ie-generation[data-empty=true]>.fv-ie-button{grid-column:2;grid-row:2}
.fv-ie-generation[data-empty=true]>.fv-ie-gen-note{grid-column:1/-1;grid-row:3}
.fv-ie-generation[data-failed=true]>.fv-ie-gen-note{grid-row:3}
diff --git a/web/image_editor.js b/web/image_editor.js
index c15efc3..f13ffaf 100644
--- a/web/image_editor.js
+++ b/web/image_editor.js
@@ -52,6 +52,7 @@ export const ICONS = {
link: '<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>',
unlink: '<path d="m18.84 12.25 1.72-1.71h-.02a5 5 0 0 0-.12-7.07 5 5 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.75-1.71 1.71a5 5 0 0 0 .12 7.07 5 5 0 0 0 6.95 0l1.71-1.71"/><path d="M8 2v3M2 8h3M16 19v3M19 16h3"/>',
plus: '<path d="M12 5v14M5 12h14"/>',
+ history: '<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l3 2"/>',
image: '<rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="2"/><path d="m21 16-5-5L5 20"/>',
copy: '<rect x="8" y="8" width="13" height="13" rx="2"/><path d="M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3"/>',
trash: '<path d="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"/>',
@@ -134,7 +135,7 @@ export async function openImageEditor({source = null, name = source || '', targe
const baseImage = hasOriginal ? await loadImage(resolve(source)) : null;
const renderer = new Renderer(resolve);
const fresh = !edit;
- const blankSizeForRatio = ratio => blankCanvasSize(ratio, null);
+ const blankSizeForRatio = (ratio, tier = 'standard') => blankCanvasSize(ratio, null, tier);
const blankSize = edit || (target?.width > 0 && target?.height > 0 ? target : blankSizeForRatio('16:9'));
const original = () => {
if (!hasOriginal) return blankDocument(blankSize, edit?.ratio || blankCanvasRatio(target));
@@ -229,7 +230,7 @@ export async function openImageEditor({source = null, name = source || '', targe
const genClient = imageGenClient || createImageGenClient(api.fetchApi.bind(api));
const generation = createImageGeneration({client: genClient,
renderer, t, getDoc: () => doc, getSelection: () => selection, commit: commitInserted, el, button, segmented,
- library, resolve, icon, onRatioChange: setBlankCanvasRatio, productVersion, fetchApi: (path, options) => api.fetchApi(path, options),
+ library, resolve, icon, onRatioChange: setBlankCanvasRatio, onPlace: (file, label) => addImageLayer(file, label), productVersion, fetchApi: (path, options) => api.fetchApi(path, options),
resumeKey: `${role}|${source || ''}|${name}`});
// ----- tools ----------------------------------------------------------------
@@ -956,9 +957,9 @@ export async function openImageEditor({source = null, name = source || '', targe
}
// ----- canvas: shape, orientation, size ----------------------------------------------
- function setBlankCanvasRatio(ratio, resumed = false) {
+ function setBlankCanvasRatio(ratio, tier = 'standard', resumed = false) {
if (doc.layers.length || (!resumed && generation.state().running)) return;
- const next = blankDocument(blankSizeForRatio(ratio), ratio);
+ const next = blankDocument(blankSizeForRatio(ratio, tier), ratio);
followSize(doc, next); deselectQuiet(); commit(next);
}
function aspectOf(id, r = rect()) {
diff --git a/web/image_generation.js b/web/image_generation.js
index 811f534..b6da368 100644
--- a/web/image_generation.js
+++ b/web/image_generation.js
@@ -26,14 +26,17 @@ export function blankCanvasRatio(target) {
return target?.width > 0 && target?.height > 0 && target.width * h === target.height * w;
}) || BLANK_CANVAS_RATIOS[0];
}
-export function blankCanvasSize(ratio, sizes = null) {
+// 高清 is a square side of 1280 against 1024 (about 1.6 times the pixels).
+export const BLANK_CANVAS_AREAS = Object.freeze({standard: 1024, high: 1280});
+export function blankCanvasSize(ratio, sizes = null, tier = 'standard') {
if (!BLANK_CANVAS_RATIOS.includes(ratio)) ratio = BLANK_CANVAS_RATIOS[0];
if (sizes?.[ratio]) {
const [width, height] = sizes[ratio];
return {width, height};
}
const [w, h] = ratio.split(':').map(Number);
- const units = Math.floor(Math.sqrt(1024 ** 2 / (w * h * 32 ** 2)));
+ const side = BLANK_CANVAS_AREAS[tier] || BLANK_CANVAS_AREAS.standard;
+ const units = Math.floor(Math.sqrt(side ** 2 / (w * h * 32 ** 2)));
return {width: w * units * 32, height: h * units * 32};
}
const failure = (code, info = {}) => Object.assign(new Error(code || 'generation_failed'), {
@@ -91,6 +94,10 @@ export function createImageGenClient(fetchImpl = globalThis.fetch.bind(globalThi
async segment({image, points}) { return post('segment', {image, points}); },
segmentInstall: () => post('segment-install', {}),
segmentCancel: () => post('segment-cancel', {}),
+ // Every picture generated on this machine, newest first; the engine keeps them in a folder.
+ async history() { return (await post('history', {})).items || []; },
+ async historyDelete(file) { return (await post('history-delete', {file})).items || []; },
+ historyOpen: () => post('history-open', {}),
// The prompts and sizes of a new character's five pictures (the Agent's cards use the same ones).
castViews: async description => (await post('cast-views', {description})).views,
async upload(file) {
@@ -517,8 +524,8 @@ export function imageJobStore(key, storage = globalThis.sessionStorage, now = Da
}
export function createImageGeneration({client, renderer, t, getDoc, getSelection, commit, el, button, segmented,
- library = [], resolve = file => file, icon = () => '', onRatioChange, productVersion, fetchApi, resumeKey = null}) {
- let mode = 'edit', prompt = '', mounted = null, references = [];
+ library = [], resolve = file => file, icon = () => '', onRatioChange, onPlace, productVersion, fetchApi, resumeKey = null}) {
+ let mode = 'edit', prompt = '', mounted = null, references = [], tier = 'standard', past = [];
let promptRequired = false, attentionTimer = null;
const copies = new Map();
// A reference is sent no larger than the largest picture the service makes.
@@ -616,9 +623,62 @@ export function createImageGeneration({client, renderer, t, getDoc, getSelection
}
menu.append(summary, choices); refs.append(menu);
}
+ // Every picture made on this machine: place one on the canvas, use it as a reference, delete it,
+ // or show the folder that holds them.
+ function historyMenu() {
+ const menu = el('details', null, 'fv-ie-menu fv-ie-gen-history');
+ const summary = el('summary'); summary.innerHTML = icon('history', 16);
+ summary.title = t('History', '历史'); summary.setAttribute('aria-label', summary.title);
+ const list = el('div', null, 'fv-ie-menu-list');
+ menu.append(summary, list);
+ const draw = () => {
+ list.replaceChildren();
+ if (!past.length) { list.append(el('div', t('No images generated yet', '还没有生成过图片'), 'fv-ie-menu-label')); return; }
+ const grid = el('div', null, 'fv-ie-gen-history-grid');
+ for (const item of past) {
+ const tile = el('div', null, 'fv-ie-gen-history-tile');
+ const place = button('', item.name, () => { menu.open = false; onPlace?.(item.file, item.name); }, 'fv-ie-gen-history-pick');
+ const picture = el('img'); picture.src = resolve(item.file); picture.alt = item.name; picture.loading = 'lazy';
+ place.append(picture); tile.append(place);
+ if (mode === 'edit' && getDoc().layers.length && limit() > 1) {
+ const use = button('+', t('Use as reference', '用作参考图'), () => {
+ references = addReference(references, {file: item.file, label: item.name}, limit()); menu.open = false; update();
+ }, 'fv-ie-gen-history-use');
+ use.setAttribute('aria-label', use.title); tile.append(use);
+ }
+ let armed = null;
+ const remove = button('×', t('Delete', '删除'), async () => {
+ if (!armed) {
+ remove.textContent = t('Delete', '删除'); remove.classList.add('fv-ie-gen-history-confirm');
+ armed = setTimeout(() => { armed = null; remove.textContent = '×'; remove.classList.remove('fv-ie-gen-history-confirm'); }, 3000);
+ return;
+ }
+ clearTimeout(armed);
+ try { past = await client.historyDelete(item.file); } catch { return; }
+ draw();
+ }, 'fv-ie-gen-ref-remove fv-ie-gen-history-delete');
+ remove.setAttribute('aria-label', remove.title); tile.append(remove);
+ grid.append(tile);
+ }
+ list.append(grid);
+ if (['localhost', '127.0.0.1', '[::1]'].includes(location.hostname))
+ list.append(button(t('Open folder', '打开文件夹'), null, () => { void client.historyOpen().catch(() => {}); }, 'fv-ie-menu-item'));
+ };
+ menu.ontoggle = async () => {
+ if (!menu.open) return;
+ try { past = await client.history(); } catch { past = []; }
+ draw();
+ // Open upward when the list does not fit below, and keep it inside the window.
+ list.classList.remove('fv-ie-gen-history-up'); list.style.right = '';
+ const box = list.getBoundingClientRect();
+ if (box.bottom > innerHeight - 8 && menu.getBoundingClientRect().top > box.height) list.classList.add('fv-ie-gen-history-up');
+ if (box.left < 8) list.style.right = (box.left - 8) + 'px';
+ };
+ return menu;
+ }
function update() {
if (!mounted?.bar.isConnected) return;
- const {input, action, note, meter, fill, group, bar, refs, ratio} = mounted, state = session.state();
+ const {input, action, note, meter, fill, group, bar, refs, ratio, size} = mounted, state = session.state();
const missing = !state.running && state.info && !state.info.installed;
const disabled = state.running || state.checking || !state.info?.installed;
const empty = !getDoc().layers.length;
@@ -627,6 +687,10 @@ export function createImageGeneration({client, renderer, t, getDoc, getSelection
if (ratio) {
ratio.hidden = !empty; ratio.disabled = state.running;
ratio.value = BLANK_CANVAS_RATIOS.includes(getDoc().ratio) ? getDoc().ratio : blankCanvasRatio(getDoc());
+ const tiers = state.info?.sizes?.includes('high') ? ['standard', 'high'] : ['standard'];
+ if (!tiers.includes(tier)) tier = 'standard';
+ size.hidden = !empty || tiers.length < 2; size.set(tier);
+ size.querySelectorAll('button').forEach(b => { b.disabled = state.running; });
}
group.querySelectorAll('button').forEach(b => {
b.disabled = disabled || (empty && b.dataset.value === 'edit');
@@ -673,24 +737,30 @@ export function createImageGeneration({client, renderer, t, getDoc, getSelection
bar.classList.add('fv-ie-generation');
const group = segmented([['edit', t('Edit this', '改这张')], ['new', t('New image', '生成一张')]], mode,
value => { mode = value; update(); }, t('Generate with AI', 'AI 生成')).group;
- let ratio = null;
+ let ratio = null, size = null, shape = null;
if (!getDoc().layers.length) {
+ shape = el('div', null, 'fv-ie-gen-shape');
ratio = el('select', null, 'fv-ie-select'); ratio.id = 'fv-ie-gen-ratio';
ratio.setAttribute('aria-label', t('Shape', '比例'));
for (const value of BLANK_CANVAS_RATIOS) {
const option = el('option', value); option.value = value; ratio.append(option);
}
- ratio.onchange = () => {
- if (!getDoc().layers.length && !session.state().running) onRatioChange?.(ratio.value);
+ const seg = segmented([['standard', t('Standard', '标准')], ['high', t('HD', '高清')]], tier,
+ value => { tier = value; changed(); }, t('Size', '尺寸'));
+ size = seg.group; size.id = 'fv-ie-gen-size'; size.set = seg.set;
+ const changed = () => {
+ if (!getDoc().layers.length && !session.state().running) onRatioChange?.(ratio.value, tier);
update();
};
+ ratio.onchange = changed;
+ shape.append(ratio, size);
}
const field = el('div', null, 'fv-ie-gen-field');
const refs = el('div', null, 'fv-ie-gen-refs'); refs.setAttribute('role', 'list');
refs.setAttribute('aria-label', t('Reference images', '参考图'));
const box = el('div', null, 'fv-ie-gen-box');
const input = el('textarea', null, 'fv-ie-gen-prompt'); input.rows = 1; input.maxLength = 2000; input.value = prompt;
- box.append(input); field.append(refs, box);
+ box.append(input); field.append(refs, box, historyMenu());
const note = el('div', '', 'fv-ie-opt-note fv-ie-gen-note'); note.setAttribute('role', 'status');
const action = button(t('Generate', '生成'), null, () => {
const now = session.state(), pack = !now.running && now.info && !now.info.installed ? packView(now.info, t) : null;
@@ -701,9 +771,9 @@ export function createImageGeneration({client, renderer, t, getDoc, getSelection
meter.setAttribute('role', 'progressbar'); meter.setAttribute('aria-label', t('Generate with AI', 'AI 生成'));
meter.setAttribute('aria-valuemin', '0'); meter.setAttribute('aria-valuemax', '100');
bar.append(group);
- if (ratio) bar.append(ratio);
+ if (shape) bar.append(shape);
bar.append(field, note, action, meter);
- mounted = {bar, input, action, note, meter, fill, group, refs, ratio};
+ mounted = {bar, input, action, note, meter, fill, group, refs, ratio, size};
const grow = () => {
input.style.height = '0px';
input.style.height = (prompt.trim() ? Math.min(80, Math.max(32, input.scrollHeight + 2)) : 32) + 'px';