Files
DemonGatanjieuandClaude Opus 5.5 c624f3f134 Tidy the AI workbench's task head and fix a startup race
Walking through the AI workbench as a user: the task head held nine loose
controls that wrapped to four or five lines with the side column open. It is
now two lines whatever the width, with rename, privacy, links and remove in a
menu. The stages and what a task made share one line over the timeline, a
failed step is a mark instead of red text, New task opens at once, and a
missing label in the Ways panel is filled in.

The walk also caught AMB not starting at all on one page load. ComfyUI imports
every script under web/ on its own and at once, so any module of the big import
cycle can run first; ui_ai_workbench.js wrote to a const of ui_ai_results.js as
it loaded, which failed when that module was entered first. The value now
lives in a module that imports nothing, and tests/module_cycles.mjs refuses
the pattern.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 01:40:33 +08:00

41 lines
1.6 KiB
JavaScript

/**
* Privacy mode of a task (api/ai_privacy.py): it keeps the task's pictures from the AI. It is turned on
* from the ⋯ in the task's head (ui_ai_task_menu.js); while on, a chip there says so ("🔒 Private") and
* turns it off (POST /anomalous/ai_tasks/{id} {privacy}). What the AI saw before stays seen, as the hint says.
*/
import { translate as t } from './locales.js';
import { anomalousAlert } from './ui_dialog.js';
import { icon } from './ui_ai_icons.js';
function el(tag, className, text) {
const node = document.createElement(tag);
if (className) node.className = className;
if (text !== undefined) node.textContent = text;
return node;
}
/** Turns `task`'s privacy mode to `on`; `changed()` after it was turned. */
export async function setPrivacy(task, on, changed) {
try {
const response = await fetch(`/anomalous/ai_tasks/${encodeURIComponent(task.id)}`, {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ privacy: on }),
});
if (!response.ok) throw new Error((await response.json().catch(() => ({}))).error || response.statusText);
} catch (error) {
await anomalousAlert(error.message);
return;
}
changed();
}
/** What says that `task` is private, and turns it off. */
export function privacyChip(task, changed) {
const chip = el('button', 'anomalous-ai-tool anomalous-ai-privacy is-on');
chip.type = 'button';
chip.title = t('aiPrivacyHint_on');
chip.append(icon('lock', 15), el('span', '', t('aiPrivacy')));
chip.onclick = () => void setPrivacy(task, false, changed);
return chip;
}