diff --git a/freevideo_engine/engine_exit.py b/freevideo_engine/engine_exit.py index cc48ae12..c3d21ad6 100644 --- a/freevideo_engine/engine_exit.py +++ b/freevideo_engine/engine_exit.py @@ -13,7 +13,7 @@ import time from pathlib import Path -from .exit_diagnostics import clean_reading, exit_reading, memory_sample +from .exit_diagnostics import clean_reading, exit_reading, memory_sample, stderr_kinds from .long_paths import io_path from .monitoring import save from .system import windows @@ -78,6 +78,10 @@ def build(code, log=None, *, now=None, system=None): # The computer's memory when the exit was seen; the readings of this process are not the engine's. record['memory'] = {key: value for key, value in memory_sample().items() if not key.startswith('process_')} record['log_tail'] = log_tail(log) if log else [] + # What the engine's last lines complained about, as fixed words: the lines stay on this computer, the words may leave it. + kinds = stderr_kinds('\n'.join(record['log_tail'])) + if kinds: + record['stderr_kinds'] = kinds return record diff --git a/freevideo_engine/launcher_issue.py b/freevideo_engine/launcher_issue.py index b7314f6f..4c7926a9 100644 --- a/freevideo_engine/launcher_issue.py +++ b/freevideo_engine/launcher_issue.py @@ -3,15 +3,28 @@ Only the sentence the failure card shows travels. It has gone through the launcher's redaction already; paths and long tokens are removed once more here, and the end of a long log gives way to fit the address. """ +import re from urllib.parse import urlencode from .feedback import scrub +from .long_paths import io_path ISSUE_FORM = 'https://github.com/FlashML-org/FreeVideo/issues/new' # GitHub refuses very long addresses. MAX_ADDRESS = 7000 MAX_PROBLEM = 600 MAX_REPORT = 2500 +# The update failure card: the report page carries the last lines of the per-source failure log. +UPDATE_TITLES = ('Update', '更新') +UPDATE_SOURCE_LINES = 5 +UPDATE_SOURCE_LINE_CHARS = 240 +# IPv4 first (so ::ffff:192.0.2.1 leaves no part of the address), then IPv6 in the full form (four groups or more, +# so a time such as 23:00:00 stays) and in the compressed form (::). +_IPV4 = re.compile(r'\b\d{1,3}(?:\.\d{1,3}){3}\b') +_IPV6 = re.compile(r'(?', _IPV4.sub('', scrub(line))).split())[:UPDATE_SOURCE_LINE_CHARS] + for line in text.splitlines() if line.strip()] + # A heading and a list: the report page strips each line, so the entries start with "- ", not with spaces. + return ['Update sources:'] + ['- ' + line for line in lines[-count:]] if lines else [] + except Exception: + return [] + + +def update_report_lines(title): + """The diagnostic lines for the report page of an update failure; [] for any other failure or when anything goes wrong.""" + try: + if str(title).strip() not in UPDATE_TITLES: + return [] + from .desktop_runtime import launcher_root + return update_source_lines(launcher_root()) + except Exception: + return [] + + def issue_url(error, version=None, title=None, zh=False, environment='', diagnostics=()): lines = _lines(error) # A successful download-tool check can open the text (its Sysnative "not found" is normal); the cause is not that line. @@ -77,11 +120,6 @@ def issue_url(error, version=None, title=None, zh=False, environment='', diagnos # only the error text gives way to fit the address. # The diagnostic lines (adapter model) come first and are kept whole, whatever the error is. notes = [scrub(line).strip() for line in diagnostics if str(line).strip()] - head = '\n'.join(([('Environment: ' + scrub(environment).strip())] if str(environment).strip() else []) + notes) - head += '\n\n' if head else '' - - def fit(limit): - return head + (report if len(report) <= limit else report[:limit // 3] + '\n...\n' + report[-(limit - limit // 3 - 5):]) def build(body): params = {'template': 'bug_launcher.yml', 'title': f'[{place}] ' + (str(title).strip() if title else place), @@ -90,7 +128,31 @@ def build(body): params['version'] = 'v' + str(version).lstrip('v') return ISSUE_FORM + '?' + urlencode(params) - limit = MAX_REPORT - while len(build(fit(limit))) > MAX_ADDRESS and limit > 50: - limit = int(limit * 0.8) - return build(fit(limit)) + def attempt(lines, floor): + head = '\n'.join(([('Environment: ' + scrub(environment).strip())] if str(environment).strip() else []) + lines) + head += '\n\n' if head else '' + + def fit(limit): + return head + (report if len(report) <= limit else report[:limit // 3] + '\n...\n' + report[-(limit - limit // 3 - 5):]) + + limit = MAX_REPORT + while len(build(fit(limit))) > MAX_ADDRESS and limit > floor: + limit = int(limit * 0.8) + return build(fit(limit)) + + # The log lines (a heading, then "- " entries) are the first to give way: a long line, or one in Chinese, whose + # address form is nine times as long, must not make the address too long for GitHub. Oldest entries go first. + if 'Update sources:' in notes: + heading = notes.index('Update sources:') + count = 0 + while heading + 1 + count < len(notes) and notes[heading + 1 + count].startswith('- '): + count += 1 + before, after = notes[:heading], notes[heading + 1 + count:] + entries = notes[heading + 1:heading + 1 + count] + for dropped in range(count + 1): + kept = before + (['Update sources:'] + entries[dropped:] if dropped < count else []) + after + url = attempt(kept, MIN_REPORT_WITH_LOG) + if len(url) <= MAX_ADDRESS: + return url + notes = before + after + return attempt(notes, 50) diff --git a/freevideo_engine/modern_launcher.py b/freevideo_engine/modern_launcher.py index 23f0ff3a..9653202f 100644 --- a/freevideo_engine/modern_launcher.py +++ b/freevideo_engine/modern_launcher.py @@ -425,14 +425,14 @@ def reportProblem(self, error, title): def openReport(self, error, title): from . import __version__ - from .launcher_issue import adapter_line, environment_line, issue_url, machine_hardware, product_version + from .launcher_issue import adapter_line, environment_line, issue_url, machine_hardware, product_version, update_report_lines from .windows_ux import open_browser # The release (0.4.x) is named, not the build number; only fields that carry no path or user name travel. version = session.installed_product_version() or product_version(__version__) engine = session.installation_engine() url = issue_url(error, version, title, zh=session.language.startswith('zh'), environment=environment_line(version, machine_hardware(engine) if engine else {}), - diagnostics=[adapter_line()]) + diagnostics=[adapter_line()] + update_report_lines(title)) self.invoke(open_browser, url) @Slot() diff --git a/freevideo_engine/release_notes.json b/freevideo_engine/release_notes.json index 3c7d8d77..9463e8cc 100644 --- a/freevideo_engine/release_notes.json +++ b/freevideo_engine/release_notes.json @@ -1,41 +1,60 @@ { "schema": 1, - "product_version": "0.6.9", + "product_version": "0.6.10", "en": { - "summary": "0.6.9 improves canceling, track display and continuation in the Edit view; has the launcher restore missing program files and give clearer messages; explains more clearly when a performance measurement stops for lack of memory, when FreeVideo does not answer in time and when no NVIDIA graphics card is found; and adds three tutorial chapters.", + "summary": "Fixes generating after opening Presets, makes Preview first follow the step count, and makes update failure reports more complete.", "changes": [ - "More tracks in view in the Edit view: when the timeline cannot show every track, the sound tracks become slightly shorter so that as many as possible are visible; if they still do not fit, a fade at the bottom of the timeline shows that more tracks are below.", - "Smoother continuation in the Edit view: when a continued video finishes, its next part is made ready and the creation preview being watched stays open.", - "In a wider window, while a part is generating in the Edit view, Cancel stands on the greyed Generate key, where the mouse can reach it.", - "More recordings can be imported in the Edit view: WebM and MKV recordings that do not state their length can now be imported.", - "Clearer prompt when dubbing is stopped: in the Edit view, the confirmation says that lines already dubbed are kept and the rest can be dubbed again later.", - "The launcher restores missing program files: when files in its saved program folder are missing or empty, the launcher restores them from its built-in copy before setup or launch, then continues as usual. When a Windows setup step ends like a crash, the setup log gains one line with the exit code, a short check of that step's Python and its path.", - "Clearer launcher wording: the status heading says FreeVideo (such as Starting FreeVideo and FreeVideo stopped), and on the setup page the first step and the first option are called Runtime and New installation. The setting \"ComfyUI address\" is now called \"Server address\", and the message for a port in use says the same; when the LAN access ports are in use, the message says to close the programs using them, then turn LAN access on again.", - "Clearer explanation of the graphics card at setup: on Windows, when no NVIDIA driver is found and the computer lists only display devices from other makers, a virtual machine's included, the launcher says that no NVIDIA graphics card was found; when the graphics list cannot be read, the setup report says which step failed. FreeVideo still needs an NVIDIA graphics card with compute capability 8.0 or higher (such as the RTX 30 series or newer, professional cards included).", - "Clearer message when a performance measurement stops: when it stops because the computer ran out of available memory, Settings states the cause and the next step, and a problem can be reported. In a narrow window, a failure message in Settings grows with its text and shows in full.", - "Clearer notice when an answer is late: when FreeVideo does not answer in time, some cases that used to read as a lost connection now say FreeVideo is not responding and suggest checking the queue first; when a queue action gets no answer, the card suggests checking the queue's current state.", - "Three new tutorial chapters: Upscale a video, how to upscale a video to a larger size or to about 4K; making several videos at once (batch, one prompt per line, loop); and organizing creations (tags, filters, compare, recently deleted). The tutorial also covers \"Composition only\" for reference videos and running the second pass from a preview's right-click menu in Creations, and updates how characters, scenes and props work with first and last frames and the steps for selecting creations and finding Favorites.", - "More accurate memory planning on NVIDIA computers whose video memory and system memory are one pool (such as DGX Spark): the plan counts the pool once and leaves a part of it for the system (not verified on a physical computer). Windows on Arm computers: setup chooses its downloads by the processor of the computer (not verified on a physical computer). Dubbing is not available on these computers." + "Generate works after opening Presets: when a setting needs changing, the reason appears next to it and you can fill it in there.", + "Preview first follows the step count: when a workflow's first-pass steps are not 8, Preview first is unavailable with the reason shown, and the key generates the video.", + "More complete update failure reports: \"Report a problem\" on an update failure now adds the last lines of the update log, with file paths, IP addresses and access tokens removed." ] }, "zh": { - "summary": "0.6.9 改进剪辑视图的取消、轨道显示和接续生成;启动器自动补回缺失的程序文件,提示更清楚;性能测量因内存不足停止、FreeVideo 没有及时应答、没有找到 NVIDIA 显卡时,说明更清楚;教程新增三章。", + "summary": "修复了打开“预设”后无法生成的问题,“先出预览”会跟随步数说明是否可用,更新失败的报告也更完整。", "changes": [ - "剪辑视图轨道多时看得更全:时间线放不下所有轨道时,声音轨会略微变矮,让轨道尽量全部显示;仍放不下时,时间线下沿出现渐隐,提示下面还有轨道。", - "剪辑视图接续生成更顺畅:接续生成的视频完成后,下一段会照常备好,正在看的作品预览保持打开。", - "在较宽的窗口里,剪辑视图生成一段时,“取消”键移到变灰的“生成视频”键处,可以用鼠标点到。", - "剪辑视图可以导入更多录制文件:文件中没有写明时长的 WebM、MKV 录制文件现在可以导入。", - "停止配音时说明更准确:在剪辑视图中停止配音,确认框会说明已配好的台词会保留,其余台词可以稍后重新配音。", - "启动器自动补回缺失的程序文件:已保存的程序文件夹中有文件缺失或被清空时,启动器会在安装或启动前从自带的副本补回,然后照常继续。Windows 安装中某一步像崩溃一样结束时,安装日志会多记一行,写明退出码、对该步 Python 的简短检查和 Python 路径。", - "启动器用词更清楚:状态标题改用“FreeVideo”(如“正在启动 FreeVideo”“FreeVideo 已停止”),安装页的第一步和第一个选项改称“环境”和“全新安装”。设置项“ComfyUI 地址”改称“服务地址”,端口被占用时的提示也用这个名字;局域网访问的端口被占用时,提示关闭占用端口的程序,再重新开启局域网访问。", - "安装时的显卡说明更清楚:在 Windows 上找不到 NVIDIA 驱动、电脑里只有其他厂商的显示设备(包括虚拟机的)时,启动器会说明没有找到 NVIDIA 显卡;读不出显卡列表时,安装报告写明是哪一步。FreeVideo 仍需要计算能力 8.0 及以上的 NVIDIA 显卡(如 RTX 30 系列及更新,包括专业卡)。", - "性能测量停止时说明更清楚:性能测量因电脑可用内存不足而停止时,设置页会写明原因和下一步,并可以提交问题。设置页的失败说明在窄窗口中随文字变高,完整显示。", - "应答超时的提示更准确:FreeVideo 没有及时应答时,部分原先显示“连接已断开”的情况改为显示“FreeVideo 没有响应”,并提醒先查看队列;队列操作没有得到应答时,提醒查看队列中的实际状态。", - "教程新增三章:“放大视频”,说明如何把视频放大到更大的尺寸或 4K 级别;“一次生成多条”(批量、每行一条描述、循环);“整理作品”(标签、筛选、对比、最近删除)。另补充参考视频“仅参考构图”和在作品库中右键预览继续二采的用法,更新角色、场景和道具与首帧、尾帧搭配使用的说明,以及作品库多选和收藏位置的说明。", - "显存与内存为同一片的 NVIDIA 电脑(如 DGX Spark)的内存规划更准确:规划时这片内存只算一次,并为系统留出一部分(未在真机验证)。Windows on Arm 电脑:安装时按电脑架构选择下载内容(未在真机验证)。这类电脑上无法使用配音。" + "打开“预设”后可正常生成:有设置需要修改时,会在对应位置说明原因,并可直接填写。", + "“先出预览”跟随步数:工作流的一采步数不是 8 时,“先出预览”不可选并写明原因,按键直接生成视频。", + "更新失败的报告更完整:在更新失败提示中点“提交问题”,报告会附上最近几行更新记录,其中的文件路径、IP 地址和访问令牌已移除。" ] }, "history": [ + { + "product_version": "0.6.9", + "en": { + "summary": "0.6.9 improves canceling, track display and continuation in the Edit view; has the launcher restore missing program files and give clearer messages; explains more clearly when a performance measurement stops for lack of memory, when FreeVideo does not answer in time and when no NVIDIA graphics card is found; and adds three tutorial chapters.", + "changes": [ + "More tracks in view in the Edit view: when the timeline cannot show every track, the sound tracks become slightly shorter so that as many as possible are visible; if they still do not fit, a fade at the bottom of the timeline shows that more tracks are below.", + "Smoother continuation in the Edit view: when a continued video finishes, its next part is made ready and the creation preview being watched stays open.", + "In a wider window, while a part is generating in the Edit view, Cancel stands on the greyed Generate key, where the mouse can reach it.", + "More recordings can be imported in the Edit view: WebM and MKV recordings that do not state their length can now be imported.", + "Clearer prompt when dubbing is stopped: in the Edit view, the confirmation says that lines already dubbed are kept and the rest can be dubbed again later.", + "The launcher restores missing program files: when files in its saved program folder are missing or empty, the launcher restores them from its built-in copy before setup or launch, then continues as usual. When a Windows setup step ends like a crash, the setup log gains one line with the exit code, a short check of that step's Python and its path.", + "Clearer launcher wording: the status heading says FreeVideo (such as Starting FreeVideo and FreeVideo stopped), and on the setup page the first step and the first option are called Runtime and New installation. The setting \"ComfyUI address\" is now called \"Server address\", and the message for a port in use says the same; when the LAN access ports are in use, the message says to close the programs using them, then turn LAN access on again.", + "Clearer explanation of the graphics card at setup: on Windows, when no NVIDIA driver is found and the computer lists only display devices from other makers, a virtual machine's included, the launcher says that no NVIDIA graphics card was found; when the graphics list cannot be read, the setup report says which step failed. FreeVideo still needs an NVIDIA graphics card with compute capability 8.0 or higher (such as the RTX 30 series or newer, professional cards included).", + "Clearer message when a performance measurement stops: when it stops because the computer ran out of available memory, Settings states the cause and the next step, and a problem can be reported. In a narrow window, a failure message in Settings grows with its text and shows in full.", + "Clearer notice when an answer is late: when FreeVideo does not answer in time, some cases that used to read as a lost connection now say FreeVideo is not responding and suggest checking the queue first; when a queue action gets no answer, the card suggests checking the queue's current state.", + "Three new tutorial chapters: Upscale a video, how to upscale a video to a larger size or to about 4K; making several videos at once (batch, one prompt per line, loop); and organizing creations (tags, filters, compare, recently deleted). The tutorial also covers \"Composition only\" for reference videos and running the second pass from a preview's right-click menu in Creations, and updates how characters, scenes and props work with first and last frames and the steps for selecting creations and finding Favorites.", + "NVIDIA computers whose video memory and system memory are one pool (such as DGX Spark): the plan counts the pool once and leaves a part of it for the system. Windows on Arm computers: setup chooses its downloads by the processor of the computer, and dubbing is not available on them." + ] + }, + "zh": { + "summary": "0.6.9 改进剪辑视图的取消、轨道显示和接续生成;启动器自动补回缺失的程序文件,提示更清楚;性能测量因内存不足停止、FreeVideo 没有及时应答、没有找到 NVIDIA 显卡时,说明更清楚;教程新增三章。", + "changes": [ + "剪辑视图轨道多时看得更全:时间线放不下所有轨道时,声音轨会略微变矮,让轨道尽量全部显示;仍放不下时,时间线下沿出现渐隐,提示下面还有轨道。", + "剪辑视图接续生成更顺畅:接续生成的视频完成后,下一段会照常备好,正在看的作品预览保持打开。", + "在较宽的窗口里,剪辑视图生成一段时,“取消”键移到变灰的“生成视频”键处,可以用鼠标点到。", + "剪辑视图可以导入更多录制文件:文件中没有写明时长的 WebM、MKV 录制文件现在可以导入。", + "停止配音时说明更准确:在剪辑视图中停止配音,确认框会说明已配好的台词会保留,其余台词可以稍后重新配音。", + "启动器自动补回缺失的程序文件:已保存的程序文件夹中有文件缺失或被清空时,启动器会在安装或启动前从自带的副本补回,然后照常继续。Windows 安装中某一步像崩溃一样结束时,安装日志会多记一行,写明退出码、对该步 Python 的简短检查和 Python 路径。", + "启动器用词更清楚:状态标题改用“FreeVideo”(如“正在启动 FreeVideo”“FreeVideo 已停止”),安装页的第一步和第一个选项改称“环境”和“全新安装”。设置项“ComfyUI 地址”改称“服务地址”,端口被占用时的提示也用这个名字;局域网访问的端口被占用时,提示关闭占用端口的程序,再重新开启局域网访问。", + "安装时的显卡说明更清楚:在 Windows 上找不到 NVIDIA 驱动、电脑里只有其他厂商的显示设备(包括虚拟机的)时,启动器会说明没有找到 NVIDIA 显卡;读不出显卡列表时,安装报告写明是哪一步。FreeVideo 仍需要计算能力 8.0 及以上的 NVIDIA 显卡(如 RTX 30 系列及更新,包括专业卡)。", + "性能测量停止时说明更清楚:性能测量因电脑可用内存不足而停止时,设置页会写明原因和下一步,并可以提交问题。设置页的失败说明在窄窗口中随文字变高,完整显示。", + "应答超时的提示更准确:FreeVideo 没有及时应答时,部分原先显示“连接已断开”的情况改为显示“FreeVideo 没有响应”,并提醒先查看队列;队列操作没有得到应答时,提醒查看队列中的实际状态。", + "教程新增三章:“放大视频”,说明如何把视频放大到更大的尺寸或 4K 级别;“一次生成多条”(批量、每行一条描述、循环);“整理作品”(标签、筛选、对比、最近删除)。另补充参考视频“仅参考构图”和在作品库中右键预览继续二采的用法,更新角色、场景和道具与首帧、尾帧搭配使用的说明,以及作品库多选和收藏位置的说明。", + "显存与内存为同一片的 NVIDIA 电脑(如 DGX Spark):规划时这片内存只算一次,并为系统留出一部分。Windows on Arm 电脑:安装时按电脑架构选择下载内容,这类电脑上无法使用配音。" + ] + } + }, { "product_version": "0.6.8", "en": { @@ -49,8 +68,7 @@ "Launcher path tip: a folder's full path is shown as a tip only when the path is cut off.", "More failures explain their cause: the prompt model and dubbing say when they fail for lack of disk space; a failure whose cause the engine has stated is no longer shown as an unexplained process exit and gets advice for that cause; on a Mac, using reference media together with first and last frames explains that one of the two has to be kept, and what to do next.", "More accurate LoRA check: step-distillation acceleration LoRAs saved in other layouts are recognized as acceleration LoRAs, and language-model LoRAs are identified as such.", - "Edit view details: the title bar is no longer covered by the timeline's drag layers; at phone width the toolbar fits in one row; closing the Edit view clears the \"last edit not found\" notice; the slow-interface notice stays in the notification list until it is closed.", - "Reverse prompt: a video clip that yields a single frame can be reverse-prompted." + "Edit view details: the title bar is no longer covered by the timeline's drag layers; at phone width the toolbar fits in one row; closing the Edit view clears the \"last edit not found\" notice; the slow-interface notice stays in the notification list until it is closed." ] }, "zh": { @@ -64,8 +82,7 @@ "启动器路径提示:文件夹路径只在显示不全时才出现完整路径提示。", "更多失败会说明原因:提示词模型和配音因磁盘空间不足失败时会说明;引擎已写明原因的失败不再显示为原因不明的进程退出,并给出对应的处理建议;在 Mac 上同时使用参考素材和首尾帧时,会说明需要保留其中一种,以及下一步怎么做。", "LoRA 检查更准确:以其他方式保存的步数蒸馏加速 LoRA 也能被识别为加速 LoRA;语言模型的 LoRA 会被如实指出。", - "剪辑视图细节:标题栏不再被时间线拖动层遮住;手机宽度下工具条完整放在一行;关闭剪辑视图后,“找不到上次的剪辑”提示随之清除;界面变慢的提示会保留在通知列表中,直到手动关闭。", - "反推提示词:只取到一帧的视频片段也能正常反推。" + "剪辑视图细节:标题栏不再被时间线拖动层遮住;手机宽度下工具条完整放在一行;关闭剪辑视图后,“找不到上次的剪辑”提示随之清除;界面变慢的提示会保留在通知列表中,直到手动关闭。" ] } }, diff --git a/web/editor.js b/web/editor.js index 1a6f7795..7cd71f53 100644 --- a/web/editor.js +++ b/web/editor.js @@ -842,6 +842,12 @@ export function openEditor({api, app, from = null, panel = {}, components: given : t('Save the whole edit as one video in the library', '把整条剪辑存成一个视频,放进作品库')}); tip(exportCancel, {name: t('Cancel export', '取消导出'), use: t('Stop this export; no partial file is kept', '停止导出,不留下不完整的文件')}); } + // The first-pass steps the next request carries, by the same rule as snapshot() below; a linked value is not known here. + function stepsToSend() { + const panelSteps = panel.sampling?.().base_steps, own = state.record.settings?.base_steps; + const steps = panel.barActive ? bar?.overrides?.().base_steps ?? panelSteps ?? own : own ?? panelSteps; + return typeof steps === 'number' ? steps : 8; + } async function snapshot() { let value = panel.snapshot ? clonePrompt(await panel.snapshot()) : clonePrompt(await app.graphToPrompt()); if (value.output) { @@ -1391,8 +1397,9 @@ export function openEditor({api, app, from = null, panel = {}, components: given // frames, which the second pass changes. It may continue the part before it where the engine can. previewFirst(selection = state.selection) { if (actions.passMode()?.mode !== 'preview' || music.target(selection)) return false; - if ((state.record.settings?.base_steps ?? 8) !== 8) return false; const run = partRun(selection), chosen = run ? clipChoice(run) : selection, range = selectionRange(chosen); if (!range) return false; + // A part that continues is made with 8 steps whatever is set (comfy_continuation.part_steps). + if (!continuesEarlier(range) && stepsToSend() !== 8) return false; if (continuesEarlier(range) && !store.continuationPreview) return false; try { // The parts Generate would send, planned as it plans them. @@ -1506,7 +1513,9 @@ export function openEditor({api, app, from = null, panel = {}, components: given if (!alone) throw new model.EditError('unsupported'); Object.assign(inputs, {two_pass: true, preview: false, refine_from: secondPass}); } else { - if ('preview' in inputs || previewing) inputs.preview = previewing && alone; + // By the steps in this very request: they may have changed on the node since the key was drawn. + const stepsFit = beforeKeys.some(Boolean) || typeof inputs.base_steps !== 'number' || inputs.base_steps === 8; + if ('preview' in inputs || previewing) inputs.preview = previewing && alone && stepsFit; if ('refine_from' in inputs) inputs.refine_from = ''; } await followSound(frozen, prepared, ids); @@ -1835,7 +1844,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given const fromStart = event => { if (event.target instanceof HTMLTextAreaElement && event.target.closest('.fv-prompt-editor')) event.target.scrollTop = 0; }; attachBar = () => { if (bar) return; - bar = panel.borrowBar({mount: genHost, onSeconds: value => { const field = genbar.duration; if (!field || field.element.hidden || field.input.disabled || !(value > 0)) return; field.input.value = String(Math.round(value)); field.commit(); }, label: () => barLabel || null, disabled: () => !genbar.canGenerate(), + bar = panel.borrowBar({mount: genHost, onSeconds: value => { const field = genbar.duration; if (!field || field.element.hidden || field.input.disabled || !(value > 0)) return; field.input.value = String(Math.round(value)); field.commit(); }, label: () => barLabel || null, previews: () => [t('Generate preview', '生成预览'), t('Regenerate preview', '重新生成预览')].includes(barLabel), disabled: () => !genbar.canGenerate(), submit: async options => { genbar.setText(bar.prompt.value); await genbar.press(options?.allowEmpty === true); }, onFirstFrame: value => genbar.firstFrame?.set(value)}); if (bar) { diff --git a/web/error_panel.js b/web/error_panel.js index 47b148da..d9da4c7a 100644 --- a/web/error_panel.js +++ b/web/error_panel.js @@ -361,6 +361,10 @@ export function createErrorReport(detail, context = {}) { // Failures of turning a reference video into depth (freevideo_engine/depth_reference.py), most specific first. const RETRY_REPORT = ['Try again. If it happens again, choose "Report a problem" to send us the report.', '请重试。再次出现时,请点击“提交问题”,把报告发给我们。']; +// The engine's refusal of a preview with other first-pass steps (preview.validate_flags; Lane, review/preview-steps-check-0610). +const PREVIEW_STEPS = [/A preview uses two-pass generation, which runs only with 8 first-pass steps/, + 'preview-steps', ['Preview first needs 8 first-pass steps', '先出预览需一采 8 步'], ['', ''], + ['Set the first-pass steps to 8, or turn off Preview first, then generate again.', '请将一采步数改为 8,或关闭“先出预览”,再重新生成。']]; const REFERENCE_FAILURES = [ [/Source video (?:frame count )?changed during depth (?:conversion|inspection)|reference video changed while it was being turned into lines/i, 'reference-changed', ['The reference video changed', '参考视频在转换时被改动'], @@ -445,7 +449,7 @@ export function failureAdvice(value, t, known = knownError(value)) { } // A reference video turned into depth (depth_reference.py) failed: the cause in people's words and the // next step, in both languages; the engine's own sentence stays in the details below. - for (const [pattern, kind, title, summary, action] of REFERENCE_FAILURES) { + for (const [pattern, kind, title, summary, action] of [...REFERENCE_FAILURES, PREVIEW_STEPS]) { if (pattern.test(text)) return row(kind, title, summary, action); } if (known === 'media-missing') diff --git a/web/glass/advanced_tray.js b/web/glass/advanced_tray.js index 28aab481..f87fd248 100644 --- a/web/glass/advanced_tray.js +++ b/web/glass/advanced_tray.js @@ -194,7 +194,8 @@ function paintLength(tray, dialog) { const shown = (dialog.querySelector('.fvs-key-eta')?.textContent || '').match(/分\s*(\d+)\s*段|(\d+)\s*parts/); count = shown ? Number(shown[1] || shown[2]) : seconds <= each ? 1 : Math.ceil(seconds / each); } - const idle = !one && count <= 1; + // An emptied box on a duration that needs parts stays editable, so it can be filled in. + const idle = !one && count <= 1 && !(block?.value === '' && block.dataset.fvPartsNeeded === 'true'); toggle(part, 'fv-at-idle', idle); const field = part?.querySelector('.fv-at-num'); if (field && field.hasAttribute('inert') !== idle) { field.toggleAttribute('inert', idle); field.setAttribute('aria-disabled', String(idle)); } @@ -211,7 +212,7 @@ function paintLength(tray, dialog) { const refusal = dialog.querySelector('.fv-length-plan:not([hidden])'), said = refusal ? (refusal.firstChild?.textContent || refusal.textContent || '').trim() : ''; const problem = section.querySelector('.fv-at-problem'); if (problem) { if (problem.textContent !== said) problem.textContent = said; toggle(problem, 'fv-at-gone', !said); } - toggle(part, 'fv-at-bad', Boolean(said) && /每段时长|part length/i.test(said)); + toggle(part, 'fv-at-bad', Boolean(said) && /每段时长|每段最长|part length/i.test(said)); toggle(section.querySelector('.fv-at-segments[data-at=length]'), 'fv-at-bad', Boolean(said) && /单次|single run/i.test(said)); } diff --git a/web/glass/studio.css b/web/glass/studio.css index 6e2698f9..6cc91766 100644 --- a/web/glass/studio.css +++ b/web/glass/studio.css @@ -477,8 +477,8 @@ /* ── Prompt history, templates and presets: a popover over the console's right half ── */ .fv-studio.fv-create .fvs-library{position:absolute;right:0;bottom:calc(100% + var(--fv-sp-8));z-index:7;width:min(520px,100%);max-height:min(56vh,520px);display:flex;flex-direction:column; - border-radius:var(--fv-rad-pop);overflow:hidden;background:rgb(var(--fv-tint) / var(--fv-a3));border:1px solid var(--fv-edge);box-shadow:inset 0 1px 0 var(--fv-edge-hi),var(--fv-sh3); - -webkit-backdrop-filter:blur(var(--fv-glass-blur3)) saturate(175%);backdrop-filter:blur(var(--fv-glass-blur3)) saturate(175%);animation:fvs-pop var(--fv-dur-1) var(--fv-ease-out)} + border-radius:var(--fv-rad-pop);overflow:hidden;background:rgb(var(--fv-solid3));border:1px solid var(--fv-edge);box-shadow:inset 0 1px 0 var(--fv-edge-hi),var(--fv-sh3); + animation:fvs-pop var(--fv-dur-1) var(--fv-ease-out)} .fv-studio.fv-create .fvs-library[hidden]{display:none} .fvs-library-head{display:flex;align-items:center;gap:var(--fv-sp-8);padding:var(--fv-sp-8) var(--fv-sp-8) var(--fv-sp-8) var(--fv-sp-12);border-bottom:1px solid var(--fv-line)} .fvs-library-tabs{display:inline-flex;gap:var(--fv-sp-2);padding:var(--fv-sp-2);border-radius:var(--fv-rad-pill);background:var(--fv-ctl-bg);flex:none} diff --git a/web/prompt_library.js b/web/prompt_library.js index 3d636402..7fa45f25 100644 --- a/web/prompt_library.js +++ b/web/prompt_library.js @@ -2,6 +2,7 @@ // History: prompts that were generated, newest first. Templates: read-only starting points. Presets: the panel's // settings saved under a name (shape, resolution, length, quality, seed rule, LoRA choice, enhancement, and the // prompt and seed value when asked); files are never stored, only names, and a missing LoRA is named when applied. +import { fieldNote } from './field_note.js'; import {privacyOffered} from './private_offers.js'; export const HISTORY_KEY = 'freevideo.prompts.history', PRESET_KEY = 'freevideo.prompts.presets'; @@ -188,8 +189,11 @@ export function createPromptLibrary({t, host, fill, snapshot, apply, describe = const save = el('button', 'fvs-preset-save', t('Save', '保存')); save.type = 'submit'; setTip(save, t('Save preset', '保存预设'), t('Save the current settings under this name', '用这个名称保存当前设置')); form.append(name, withPrompt, withSeed, save); + form.noValidate = true; // the name is asked for here, under the form + const nameNote = fieldNote(name, {t, place: () => form}); form.onsubmit = event => { event.preventDefault(); + if (!name.value.trim()) { name.focus(); nameNote.say(t('Fill in the preset name.', '请填写预设名称。')); return; } const settings = snapshot({prompt: promptBox.checked, seed: seedBox.checked}); if (savePreset(name.value, settings, storage)) { name.value = ''; render(); notify(t('Preset saved', '预设已保存')); } else notify(t('Could not save the preset.', '预设没能保存。'), null, 'fail'); diff --git a/web/studio.js b/web/studio.js index bcef69c4..05e4855a 100644 --- a/web/studio.js +++ b/web/studio.js @@ -849,6 +849,7 @@ export function openStudio(node, {extendFrom = null} = {}) { setPrompt: text => { set(node, 'text', text); prompt.value = text; placeholder(); castOverlay.refresh(); }, // Two-pass and preview settle into one pass mode, whichever of the two the example lists first. setSetting: (name, input) => { + if (['quality', 'two_pass', 'preview', 'base_steps'].includes(name)) holdPreview(false); if (name === 'quality') { const tier = effort.levels().find(tier => tier.name === input); baseSteps.value = tier.steps; twoPass.checked = tier.twoPass; refineSteps.value = 3; @@ -1151,22 +1152,48 @@ export function openStudio(node, {extendFrom = null} = {}) { }; // (effortPointed: the quality panel's line on what the pointed-at level gives; set with that panel.) let effortPointed = () => {}; - const effort = createSamplingEffort(t, {onChange: chooseEffort, onPreview: tier => { if (tier) showEffortEstimate(tier.steps, tier.twoPass, tier.stepCache, tier.upscale); else showEffortEstimate(); effortPointed(tier); }}); + const effort = createSamplingEffort(t, {onChange: chooseLevel, onPreview: tier => { if (tier) showEffortEstimate(tier.steps, tier.twoPass, tier.stepCache, tier.upscale); else showEffortEstimate(); effortPointed(tier); }}); // What the quality control shows now; the editor's generation bar shows the same control from this. const effortState = () => ({baseSteps: Number(baseSteps.value), refineSteps: Number(refineSteps.value), twoPass: twoPass.checked, stepCache: stepCacheNow(), upscale: upscaleNow(), disabled: baseSteps.disabled || linked(node, 'two_pass') || linked(node, 'refine_steps') || linked(node, 'step_cache') || linked(node, 'upscale_factor'), reason: extension.source ? continuationReason() : ''}); const effortListeners = new Set(); - const sharedEffort = {state: effortState, choose: chooseEffort, levels: () => effort.levels(), + const sharedEffort = {state: effortState, choose: chooseLevel, levels: () => effort.levels(), subscribe(listener) { effortListeners.add(listener); return () => effortListeners.delete(listener); }}; node.freevideoEffort = sharedEffort; cleanup.push(() => { effortListeners.clear(); if (node.freevideoEffort === sharedEffort) delete node.freevideoEffort; }); const samplingSettings = el('div', null, 'fv-sampling-settings'); + // A preview is the first of two passes, which run only with 8 first-pass steps (two_pass.TWO_PASS_BASE_STEPS): a workflow + // saved with two-pass and other steps makes the video without one. + const previewNeedsSteps = () => t('Preview first needs 8 first-pass steps', '先出预览需一采 8 步'); + const previewStepsWrong = () => twoPass.checked && !extension.source && !linked(node, 'base_steps') && Number(baseSteps.value) !== 8; + // A saved Preview first that these steps cannot use waits in the workflow. It returns only when the steps are brought + // back to 8 in this panel; a one-pass level, a filled-in preset or example, or a choice of what to generate ends the wait. + const previewHeld = () => node.properties?.freevideo_preview_held === true; + function returnHeldPreview() { + if (!previewHeld() || !twoPass.checked || Number(baseSteps.value) !== 8 || extension.source || linked(node, 'preview') || !widget(node, 'preview')) return; + holdPreview(false); previewFirst.checked = true; set(node, 'preview', true); + syncSamplingSteps(); + if (runButtonReady) updateRunButton(); + } + // A level chosen on the control. + function chooseLevel(tier) { + chooseEffort(tier); + if (tier.twoPass) returnHeldPreview(); else holdPreview(false); + } + const holdPreview = on => { + if (previewHeld() === on) return; + node.properties ||= {}; + if (on) node.properties.freevideo_preview_held = true; else delete node.properties.freevideo_preview_held; + node.graph?.change?.(); + }; const previewFirst = el('input'); previewFirst.type = 'checkbox'; previewFirst.checked = value(node, 'preview') === true; function choosePassMode(mode) { if (extension.source) return; const wantsTwoPass = mode !== 'off', wantsPreview = mode === 'preview'; + // Chosen, so nothing waits; the workflow has to record that even when no other setting changes. + if (!wantsPreview && node.properties?.freevideo_preview_held) { delete node.properties.freevideo_preview_held; node.graph?.change?.(); } if (twoPass.checked !== wantsTwoPass) { // Switching off uses Max including its cache; switching on uses uncached Light. Typed steps stay. const next = passSwitch(wantsTwoPass, Number(baseSteps.value), Number(refineSteps.value), stepCacheNow(), effort.levels()); @@ -1183,8 +1210,8 @@ export function openStudio(node, {extendFrom = null} = {}) { const passLinked = linked(node, 'two_pass'), previewLinked = linked(node, 'preview'); return {mode: !twoPass.checked ? 'off' : previewFirst.checked ? 'preview' : 'on', disabled: {off: Boolean(extension.source) || passLinked || !widget(node, 'two_pass'), on: twoPass.disabled, - preview: Boolean(extension.source) || twoPass.disabled || previewLinked || !widget(node, 'preview')}, - hidden: {preview: !widget(node, 'preview')}, hint: passLinked || previewLinked ? '' : previewPassHint}; + preview: Boolean(extension.source) || twoPass.disabled || previewLinked || !widget(node, 'preview') || previewStepsWrong()}, + hidden: {preview: !widget(node, 'preview')}, hint: passLinked || previewLinked ? '' : previewStepsWrong() ? previewNeedsSteps() : previewPassHint}; } // The editor's generation bar shows the same choices; it hears every change made here and chooses through here. const passListeners = new Set(); @@ -1380,7 +1407,7 @@ export function openStudio(node, {extendFrom = null} = {}) { samplingFields.append(field(label, input)); } // Typed steps are custom sampling, which has no step cache. - baseSteps.oninput = () => { clearStepCache(); syncSamplingSteps(); }; + baseSteps.oninput = () => { clearStepCache(); syncSamplingSteps(true); }; // Apply the two-pass rule to committed values, never while typing. const twoPassRule = () => { const steps = Number(baseSteps.value); @@ -1398,10 +1425,11 @@ export function openStudio(node, {extendFrom = null} = {}) { fieldNotes.get(baseSteps).settle(); if (baseSteps.value !== typed) twoPassRule(); syncSamplingSteps(); + returnHeldPreview(); }; // The run button exists only further down; until then its label is set there. let runButtonReady = false; - function syncSamplingSteps() { + function syncSamplingSteps(typing = false) { if (extension.source) { const factor = continuationUpscale(baseSteps.value, twoPass.checked, refineSteps.value, stepCacheNow(), value(node, 'upscale_factor'), effort.levels()); baseSteps.value = '8'; refineSteps.value = '3'; twoPass.checked = true; set(node, 'two_pass', true); clearStepCache(); setUpscale(factor); autoSinglePass = false; @@ -1415,11 +1443,15 @@ export function openStudio(node, {extendFrom = null} = {}) { twoPassStatus.textContent = Number(baseSteps.value) !== 8 && !onePassLevel ? t('Needs 8 first-pass steps', '一采需 8 步') : ''; twoPassLabel.classList.toggle('fv-two-pass-unavailable', unavailable); // A preview stops after the first pass, so it needs two-pass sampling. - if (!twoPass.checked && previewFirst.checked) { + // Steps half typed decide nothing; the two-pass rule above is applied to them once they are committed. + const stepsWrong = !typing && previewStepsWrong(); + if ((!twoPass.checked || stepsWrong) && previewFirst.checked) { + // A linked value is another node's to change. + if (stepsWrong && !linked(node, 'preview')) holdPreview(true); previewFirst.checked = false; set(node, 'preview', false); if (runButtonReady) updateRunButton(); } - previewFirst.disabled = !twoPass.checked || linked(node, 'preview') || !widget(node, 'preview'); + previewFirst.disabled = !twoPass.checked || previewStepsWrong() || linked(node, 'preview') || !widget(node, 'preview'); blockOriginal('preview', previewFirst.checked && !previewFirst.disabled, {release() { choosePassMode('on'); return ['Preview first was turned off for "Use as is".', '已为“原样使用”关闭“先出预览”。']; }}); syncPassMode(); baseSteps.disabled = baseLinked || !widget(node, 'base_steps') || Boolean(extension.source); @@ -1441,6 +1473,9 @@ export function openStudio(node, {extendFrom = null} = {}) { refreshEffortEstimate(); consoleUI?.sync(); } + // Already at 8 steps with the preview off: that was set outside this panel, and it stands. A continuation's 8 steps are + // its own, so the choice keeps waiting for the end of it. + if (previewHeld() && !extension.source && Number(baseSteps.value) === 8) holdPreview(false); syncSamplingSteps(); advanced.append(samplingFields, samplingWarning); // A continuation keeps a two-pass level (Light or Medium). @@ -2267,7 +2302,7 @@ export function openStudio(node, {extendFrom = null} = {}) { }); b.dataset.mode = id; modeButtons.push(b); optionsPanel.append(b); } - const count = el('input'); count.type = 'number'; count.min = '2'; count.max = '100'; count.step = '1'; + const count = el('input'); count.type = 'number'; count.required = true; count.min = '2'; count.max = '100'; count.step = '1'; // disabled unless a batch uses it count.value = node.properties?.freevideo_batch_count ?? 4; count.setAttribute('aria-label', t('Number of videos', '生成数量')); const countField = field(t('Number of videos', '生成数量'), count); optionsPanel.append(countField); @@ -2328,6 +2363,7 @@ export function openStudio(node, {extendFrom = null} = {}) { const b = button(label, () => { choosePassMode(id === 'preview' ? 'preview' : twoPass.checked ? 'on' : 'off'); keyMore.open = false; }); b.dataset.choice = id; keyMenu.append(b); return b; }); + const keyMenuWhy = el('p', null, 'fv-key-why'); keyMenuWhy.hidden = true; keyMenu.append(keyMenuWhy); keyMore.append(keyMoreToggle, keyMenu); liftMenu(keyMore, keyMenu); const syncKeyMore = () => { @@ -2335,6 +2371,7 @@ export function openStudio(node, {extendFrom = null} = {}) { keyMore.hidden = runMode !== 'single' || videoMissing || Boolean(state.hidden.preview) || Boolean(extension.source); for (const b of keyChoices) setAttr(b, 'aria-pressed', String((b.dataset.choice === 'preview') === (state.mode === 'preview'))); keyChoices[1].disabled = state.disabled.preview && !(state.mode === 'preview'); + keyMenuWhy.hidden = !previewStepsWrong(); keyMenuWhy.textContent = keyMenuWhy.hidden ? '' : previewNeedsSteps(); if (keyMore.hidden) keyMore.open = false; }; runrow.append(generate, runOptions, keyMore); @@ -2475,7 +2512,7 @@ export function openStudio(node, {extendFrom = null} = {}) { ? t('Joining the parts…', '正在接合各段…') : chain?.state === 'queued' ? (chain.waiting ? waitingText(chain.waiting, t) : t('Queued…', '排队中…')) : t(`Generating part ${position.index + 1}…`, `正在生成第 ${position.index + 1} 段…`); - generate.disabled = submitting || chainWait || lengthControl.blocked || (runMode === 'loop' && queueState?.looping); + generate.disabled = submitting || chainWait || (lengthControl.blocked && !lengthControl.retryable) || (runMode === 'loop' && queueState?.looping); // Planning the parts and adding a batch are different waits; a count is only shown when the queue really has one. const adding = queueState?.batch ? t(`Adding ${Math.min(queueState.batch.done + 1, queueState.batch.total)}/${queueState.batch.total}…`, `正在添加 ${Math.min(queueState.batch.done + 1, queueState.batch.total)}/${queueState.batch.total}…`) @@ -2485,7 +2522,7 @@ export function openStudio(node, {extendFrom = null} = {}) { : runMode === 'batch' ? t(`Add ${count.value || '…'} videos`, `添加 ${count.value || '…'} 个视频`) : runMode === 'loop' ? (queueState?.looping ? t('Looping', '循环中') : t('Start loop', '开始循环')) : busy ? t('Add to queue', '加入队列') - : previewFirst.checked && !previewFirst.disabled ? t('Generate preview', '生成预览') : t('Generate video', '生成视频')); + : !borrowed && previewFirst.checked && !previewFirst.disabled ? t('Generate preview', '生成预览') : t('Generate video', '生成视频')); paintKey(borrowed?.label?.() ?? label, borrowed ? true : !submitting && !chainReason); syncKeyMore(); if (borrowed) generate.disabled = borrowed.disabled?.() ?? false; @@ -2500,7 +2537,9 @@ export function openStudio(node, {extendFrom = null} = {}) { : runMode === 'batch' ? t(...TIPS['studio.mode.batch'].use) : runMode === 'loop' ? t(...TIPS['studio.mode.loop'].use) : busy ? t('Starts when the current video finishes', '当前视频完成后自动开始') - : previewFirst.checked && !previewFirst.disabled ? t(...TIPS['studio.twoPass.preview'].use) : t(...TIPS['studio.generate'].use); + // Why the key makes no preview although the saved settings asked for one (a reason is read only on a greyed key). + : previewHeld() && previewStepsWrong() ? previewNeedsSteps() + : (borrowed ? borrowed.previews?.() : previewFirst.checked && !previewFirst.disabled) ? t(...TIPS['studio.twoPass.preview'].use) : t(...TIPS['studio.generate'].use); const why = !generate.disabled ? '' : submitting ? t('Adding to the queue. One moment.', '正在加入队列,请稍候') : chainWait ? t('Parts are generating. Wait, or cancel them in the queue.', '分段视频生成中,完成或在队列里取消后可再生成') @@ -2694,16 +2733,24 @@ export function openStudio(node, {extendFrom = null} = {}) { // Ctrl+Enter leaves focus in a field: commit its edit (change fires on blur) first. const editing = dialog.contains(document.activeElement) ? document.activeElement : null; if (editing && editing !== generate) { editing.blur(); editing.focus({preventScroll: true}); } - const invalid = [...dialog.querySelectorAll('input:not(:disabled)')].find(e => !e.checkValidity()); + lengthControl.settleUnusedBlock(); + // The fields of this request, shown or in a closed tray. A field in a form of its own (the preset name) is that form's + // to check; the frame window's two boxes only mirror the width and height, which are checked themselves. + const invalid = [...dialog.querySelectorAll('input:not(:disabled)')].find(e => !e.form && !e.classList.contains('fvp-dim') && !e.checkValidity()); if (invalid) { const details = invalid.closest('details'); if (details) details.open = true; + if (invalid.dataset.fvLength === 'block') { lengthControl.reportBlock(); invalid.focus(); invalid.scrollIntoView({block: 'center'}); return; } if (invalid.validity.valueMissing) { const message = new Map([[seconds, t('Fill in the duration.', '请填写时长。')], [width, t('Fill in the width.', '请填写宽度。')], [height, t('Fill in the height.', '请填写高度。')], - [seed, t('Fill in the seed.', '请填写种子。')], + [seed, t('Fill in the seed.', '请填写种子。')], [count, t('Fill in the number of videos.', '请填写生成数量。')], [baseSteps, t('Fill in the first-pass steps.', '请填写一采步数。')], - [refineSteps, t('Fill in the second-pass steps.', '请填写二采步数。')]]).get(invalid); - if (message) { status.dataset.error = 'true'; status.textContent = message; } + [refineSteps, t('Fill in the second-pass steps.', '请填写二采步数。')]]).get(invalid) + || t('Check the settings, then generate.', '请检查设置后再生成。'); + // On the field's own row when the opened tray shows it; the status line would be under the tray. + const row = fieldNotes.get(invalid); + if (row && invalid.checkVisibility()) { row.say(message); invalid.focus(); invalid.scrollIntoView({block: 'center'}); return; } + status.dataset.error = 'true'; status.textContent = message; } // A value out of range is brought in and said under its field (the length: in the console's line); a rule // between fields is said there too. No browser bubble. @@ -2712,7 +2759,7 @@ export function openStudio(node, {extendFrom = null} = {}) { if (!invalid.validity.valueMissing) { status.dataset.error = 'true'; status.textContent = invalid.validationMessage; } // Width and height are typed in the frame panel: it opens at the empty field. const side = (invalid === width || invalid === height) && framePicker?.element.checkVisibility() ? [...framePicker.pop.querySelectorAll('.fvp-dim')][invalid === width ? 0 : 1] : null; - if (side) { framePicker.set({empty: emptySide, ask: true}); if (framePicker.pop.dataset.open !== 'true') framePicker.element.click(); side.focus(); return; } + if (side) { framePicker.set({empty: emptySide || (invalid === height ? 'height' : 'width'), ask: true}); if (framePicker.pop.dataset.open !== 'true') framePicker.element.click(); side.focus(); return; } // The duration is typed in the stepper's number: it opens for typing. const stepValue = invalid === seconds ? dialog.querySelector('.fvs-step-value') : null; if (stepValue?.checkVisibility()) { stepValue.click(); return; } @@ -3073,7 +3120,7 @@ export function openStudio(node, {extendFrom = null} = {}) { // same chips and their rules stay in one place. Pressing Generate runs the editor's submission instead; the values // come from the same node the bar edits. Release puts everything back as it was. let popHolder = null; - current.borrow = ({mount, submit, label = null, disabled = null, onSeconds = null, onFirstFrame = null, initial = {}, locked = []}) => { + current.borrow = ({mount, submit, label = null, previews = null, disabled = null, onSeconds = null, onFirstFrame = null, initial = {}, locked = []}) => { if (borrowed || disposed) return null; const outer = mount.closest('dialog') || document.body; const home = {parent: controls.parentNode, next: controls.nextSibling}; @@ -3110,7 +3157,7 @@ export function openStudio(node, {extendFrom = null} = {}) { updateRunButton(); }}; shadow = new Map(); - borrowed = {submit, label: () => (state.labelFn ?? label)?.(), disabled, onSeconds, onFirstFrame, firstFrame: null, applying: false, release: state.release}; + borrowed = {submit, label: () => (state.labelFn ?? label)?.(), previews, disabled, onSeconds, onFirstFrame, firstFrame: null, applying: false, release: state.release}; const unlock = () => { for (const control of lockedNow.splice(0)) { control.disabled = false; delete control.dataset.fvLocked; } for (const element of [framePicker?.element, stepper?.element]) delete element?.dataset.fvLocked; @@ -3177,6 +3224,7 @@ export function openStudio(node, {extendFrom = null} = {}) { // The media panel and the @ list read whether a video is being continued. if (mediaNode) window.dispatchEvent(new CustomEvent('freevideo-media', {detail: mediaNode.id})); syncSamplingSteps(); syncCanvasSize(); seconds.dispatchEvent(new Event('input')); + if (!source) returnHeldPreview(); prompt.focus({preventScroll: true}); } current.enterExtend = record => { @@ -3450,6 +3498,7 @@ export function openStudio(node, {extendFrom = null} = {}) { seconds.dispatchEvent(new Event('input', {bubbles: true})); seconds.dispatchEvent(new Event('change', {bubbles: true})); } if (!baseSteps.disabled) { + holdPreview(false); const tier = settings.level && effort.levels().find(level => level.name === settings.level); if (tier) chooseEffort(tier); else if (settings.steps) { diff --git a/web/studio_length.js b/web/studio_length.js index 75df6879..a775834f 100644 --- a/web/studio_length.js +++ b/web/studio_length.js @@ -92,6 +92,10 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie blockSeconds: blockEdited || Object.hasOwn(node.properties || {}, LENGTH_PROPERTIES.block) ? Number(block.value) : !planLimits && total() > 15 && total() <= 30 ? defaultBlockSeconds(null) : null}; } + // The part length to fall back on, and whether this duration needs parts of it. + const storedBlock = () => Math.min(node.properties?.[LENGTH_PROPERTIES.block] || defaultBlockSeconds(planLimits?.maximum), planLimits?.maximum || Infinity); + const partsNeeded = () => !absent && !effectiveSingle() && !block.disabled + && total() > (Object.hasOwn(node.properties || {}, LENGTH_PROPERTIES.block) ? storedBlock() : singleLimitSeconds(planLimits?.maximum)); function paintModel() { const multiple = !absent && !error && plan?.count >= 2; put(modelNotice, 'hidden', !multiple || modelState.info?.ready !== false); @@ -123,6 +127,8 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie if (positive(maximum)) { if (block.max !== String(maximum)) block.max = String(maximum); } else if (block.hasAttribute('max')) block.removeAttribute('max'); if (!edited) put(block, 'value', String(Math.min(node.properties?.[LENGTH_PROPERTIES.block] || defaultBlockSeconds(maximum), maximum || Infinity))); put(block, 'disabled', Boolean(absent || seconds.disabled || effectiveSingle() || (positive(maximum) && maximum < 5))); put(controls, 'hidden', Boolean(absent)); + // Whether this duration is made in parts whatever the box holds now: an emptied box stays editable then. + if (block.dataset.fvPartsNeeded !== String(partsNeeded())) block.dataset.fvPartsNeeded = String(partsNeeded()); put(reset, 'hidden', !Object.hasOwn(node.properties || {}, LENGTH_PROPERTIES.block)); put(reset, 'disabled', block.disabled); put(block, 'title', !block.disabled || absent || seconds.disabled || effectiveSingle() ? '' : t('These settings cannot generate in parts.', '当前设置不能分段生成。')); @@ -141,6 +147,7 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie continuation_unavailable: noParts ? NO_PARTS : t('Choose a smaller picture size to make a longer video.', '如需生成更长的视频,请选择更小的画面大小。'), too_long: TOO_LONG() + storyboardText(), + block_missing: t('Fill in the longest part length.', '请填写每段最长时长。'), block_too_short: t('The part length is too short. Set a longer part length.', '每段时长过短,请加长。'), block_too_long: t('The part length is longer than one run allows at this size. Set a shorter part length.', '每段时长超过当前画面大小的单次上限,请缩短。'), other: t('Could not plan this video. Try again.', '暂时无法安排这条视频的分段,请重试。')}[kind]; @@ -206,11 +213,23 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie // Short original audio keeps its single run; long selections can use parts. forceSingle(on) { if (forced === on) return; forced = on; submitted = false; invalidate(); schedule(); }, commit, options, get plan() { return plan; }, get absent() { return absent; }, + // A part length that cannot be used now does not stop a run: it goes back to the one in force. + settleUnusedBlock() { + if (block.disabled || block.checkValidity() || partsNeeded()) return; + edited = blockEdited = false; blockNote.clear(); block.value = String(storedBlock()); invalidate(); schedule(); + }, + // The part length stops this run: said on its own row, until it is edited. + reportBlock() { + if (!block.validity.valueMissing) { blockNote.settle(); return; } + error = 'block_missing'; paint(); onChange(); + }, get needsPlan() { return !absent && !effectiveSingle() && (total() > singleLimitSeconds(planLimits?.maximum) || Object.hasOwn(node.properties || {}, LENGTH_PROPERTIES.block)); }, get estimate() { return limits?.estimate || null; }, get capabilityState() { return capabilityState; }, get estimating() { return waiting; }, - get blocked() { return !absent && Boolean(error); }, get message() { return error ? errorMessage(error) : ''; }, + get blocked() { return !absent && Boolean(error); }, + // A plan that could not be made says "Try again": Generate stays pressable and asks for it again. + get retryable() { return !absent && error === 'other'; }, get message() { return error ? errorMessage(error) : ''; }, // The line shown beside the greyed button: the reason, and always what to do next. get visibleMessage() { if (absent || !error) return ''; @@ -222,6 +241,7 @@ export function createStudioLength({api, node, seconds, advanced, fields, t, fie set autopilot(shown) { if (disposed || Boolean(shown) === autopilotShown) return; autopilotShown = Boolean(shown); writeHint(); paint(); onChange(); }, freeze() { submitted = true; }, async ready() { + if (error === 'other') { error = null; plan = null; pending = null; paint(); onChange(); } while (!disposed) { const version = revision; clearTimeout(timer); timer = null; if (pending) await pending;