Compare commits

...
Author SHA1 Message Date
Vito 89ba820153 Update Buy Me a Coffee username to 'veets' 2026-11-15 06:24:40 -08:00
Vito 6c19f0a228 fix(tests): System specs wait for the save's answer before reading the status (#634) (#635)
Every System spec that saved to the server and then read the status line
gave it five seconds, the same wait that failed in the LoRA import review
spec (#631) when the durable config write took longer on a busy CI disk.

A shared helper (tests/browser/settings-save.mjs) waits for the host's
answer to the save: 23 sites in the sources, backups, integrations,
tagging and system specs now use it, and so does the import review spec.
Saves kept in the browser send nothing and are unchanged.

Under a 20 IOPS write throttle the five specs went from 11 failures, four
of them the stale status, to 7, all of them the 30 s test limit.
2026-11-15 13:24:31 +00:00
Vito a387643946 feat(brand): new logo in the README, Registry icon and browser tabs (#632) (#633)
The README opens with the PromptManager banner, the Comfy Registry icon
is the new app icon from this repository, and every page Prompt Manager
serves links a 32 px favicon and a 128 px touch icon.

Only small files are added: the two page icons (12 KB) ship in the
Registry package, the banner is a 26 KB WebP and the Registry icon a
43 KB PNG.
2026-11-15 02:17:40 +00:00
Vito 1a177e39a2 fix(tests): browser fixtures seed on Windows; import review spec waits for its save (#629, #631) (#630)
* fix(tests): seed browser fixtures in the host's path style (#629)

The concept and history fixtures recorded their outputs with a hardcoded
posix path style. On Windows the server's temp root is not an absolute
POSIX path, so the root key was None, the output bundle was refused and
both reset endpoints answered 500.

They now use the host's style, as production does. A Python test starts
the test server and seeds both fixtures, so the Windows job covers it.

* fix(tests): wait for the LoRA save's answer in the import review spec (#631)

The spec clicked Save preferences and gave the saved status five seconds.
The save commits config.json durably, and on a busy CI disk that write
alone took 6.4 s, so the status still read Unsaved changes.

It now waits for the /lora/enable response first, as TESTING.md asks of
disk-bound steps. Under a 20 IOPS write throttle the commit takes 10.4 s:
3 of 12 runs failed before, 12 of 12 pass now.
2026-11-15 02:17:39 +00:00
Vito faac2d6f52 ci(deps): stop Dependabot raising pip version floors (#625) (#626)
A custom node's requirements install into ComfyUI's shared environment,
so raising a floor force-upgrades the package for every other custom
node there. Our >= floors already allow each new release, so leave them
alone and only widen a requirement that excludes it.
2026-11-11 15:12:43 +00:00
dependabot[bot] 2bf3e5202d deps(pip)(deps-dev): update coverage requirement (#624)
Updates the requirements on [coverage](https://github.com/coveragepy/coveragepy) to permit the latest version.
- [Release notes](https://github.com/coveragepy/coveragepy/releases)
- [Changelog](https://github.com/coveragepy/coveragepy/blob/main/CHANGES.rst)
- [Commits](https://github.com/coveragepy/coveragepy/compare/7.17.0...7.17.2)

---
updated-dependencies:
- dependency-name: coverage
  dependency-version: 7.17.2
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-11 15:12:08 +00:00
25 changed files with 213 additions and 36 deletions
+15
View File
@@ -0,0 +1,15 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: veets
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+4
View File
@@ -4,6 +4,10 @@ updates:
# Python dependencies (requirements.txt / setup.cfg / pyproject.toml)
- package-ecosystem: "pip"
directory: "/"
# Our requirements are minimum versions that install into ComfyUI's shared
# environment. Leave a floor alone when it already allows the new release;
# raising it would force-upgrade the package for every other custom node.
versioning-strategy: "increase-if-necessary"
schedule:
interval: "weekly"
day: "sunday"
+2
View File
@@ -1,3 +1,5 @@
![PromptManager by ComfyAssets](assets/brand/banner.webp)
# ComfyUI Prompt Manager
**Every prompt you run, every image it made, and every negative you tried, in one searchable library inside ComfyUI.**
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

+1 -1
View File
@@ -18,7 +18,7 @@ Repository = "https://github.com/ComfyAssets/ComfyUI_PromptManager"
[tool.comfy]
PublisherId = "kiko9"
DisplayName = "ComfyUI_PromptManager"
Icon = "https://avatars.githubusercontent.com/u/213204677?s=200"
Icon = "https://raw.githubusercontent.com/ComfyAssets/ComfyUI_PromptManager/main/assets/brand/icon-256.png"
[tool.black]
line-length = 88
+1 -1
View File
@@ -4,7 +4,7 @@ Pillow>=10.1.0
aiohttp>=3.11.8
# Tests and coverage
coverage>=7.17.0
coverage>=7.17.2
numpy>=1.25.0 # WD14 engine tests
# Code quality
+22
View File
@@ -0,0 +1,22 @@
/**
* Saving System settings in a spec (#631).
*
* A host save commits config.json durably (fsync, then an atomic replace). On a busy CI disk that write alone can
* take seconds, longer than the five an expect gives the status line. So a spec waits for the save's answer before
* it reads the status (TESTING.md: wait for a response, never for time). A save kept in this browser sends nothing
* and needs no wait.
*/
export const SETTINGS_URL = '/prompt_manager/settings';
export const LORA_ENABLE_URL = '/prompt_manager/lora/enable';
/** The host's answer to the next save sent to `url`. Start it before the click that saves. */
export const hostSaveAnswer = (page, url = SETTINGS_URL) =>
page.waitForResponse(response => response.request().method() === 'POST' && response.url().endsWith(url));
/** Click `button` and wait for the host's answer to the save it sends to `url`; resolves to that response. */
export async function clickHostSave(page, button, url = SETTINGS_URL) {
const answer = hostSaveAnswer(page, url);
await button.click();
return answer;
}
@@ -1,5 +1,6 @@
import { startCoverage, saveCoverage } from '../../tools/vendor/browser-coverage.mjs';
import { test, expect } from './fixtures.mjs';
import { clickHostSave, LORA_ENABLE_URL } from './settings-save.mjs';
import { SIZES, THEMES, seedConcept, openConcept, openProduction, diffInventory, mutate } from './concept-inventory.mjs';
// #249 System S10 Task 28: System › Integrations (app.js renderSystem 682–684) and the LoRA import review against the
@@ -300,7 +301,8 @@ async function productionReview(page, request, theme) {
await expect(page.locator('#workspace-main #renderer-status')).toHaveText(RENDERER_NONE);
// The import reviews what is enabled: save the integration on first.
await page.locator('#workspace-main #lora-enable').check();
await page.getByRole('button', { name: 'Save preferences', exact: true }).click();
// The save writes config.json durably, which a busy CI disk can hold for seconds (#631): wait for its answer.
await clickHostSave(page, page.getByRole('button', { name: 'Save preferences', exact: true }), LORA_ENABLE_URL);
await expect(page.locator('#settings-status')).toHaveText('Saved to the server configuration.');
const answer = page.waitForResponse(response => response.url().endsWith(PREVIEW_URL));
await page.locator('#workspace-main').getByRole('button', { name: 'Review import', exact: true }).click();
@@ -1,5 +1,6 @@
import { startCoverage, saveCoverage } from '../../tools/vendor/browser-coverage.mjs';
import { test, expect } from './fixtures.mjs';
import { hostSaveAnswer } from './settings-save.mjs';
import { seedConcept } from './concept-inventory.mjs';
import { followRestore, SEEN_RESTORE_PILL, SEEN_RESTORE_TOAST } from './unseen-restore.mjs';
@@ -387,9 +388,9 @@ test('safety backup toggle saves through Save preferences with revision (D104)',
await expect(toggle).toBeChecked();
await toggle.uncheck();
await expect(settingsStatus(page)).toHaveText('Unsaved changes.');
const saved = page.waitForRequest(item => item.url().endsWith('/prompt_manager/settings') && item.method() === 'POST');
const saved = hostSaveAnswer(page);
await save(page).click();
const body = (await saved).postDataJSON();
const body = (await saved).request().postDataJSON();
expect(body).toEqual({ safety_backup: false, expected_revision: before.revision });
await expect(settingsStatus(page)).toHaveText('Saved to the server configuration.');
expect((await serverJson(request, '/prompt_manager/settings')).settings.safety_backup).toBe(false);
@@ -1,5 +1,6 @@
import { startCoverage, saveCoverage } from '../../tools/vendor/browser-coverage.mjs';
import { test, expect } from './fixtures.mjs';
import { clickHostSave } from './settings-save.mjs';
import { seedConcept } from './concept-inventory.mjs';
// System › Integrations (#249 System S10 Task 27) on the concept-shaped fixture with a fake LoraManager install
@@ -65,7 +66,7 @@ async function openIntegrations(page) {
async function enable(page, { triggers = false } = {}) {
await settingOf(page, 'LoraManager integration').locator('input').check();
if (triggers) await settingOf(page, 'Automatically include trigger words').locator('input').check();
await save(page).click();
await clickHostSave(page, save(page), ENABLE_URL);
await expect(status(page)).toHaveText('Saved to the server configuration.');
}
@@ -201,7 +202,7 @@ test('key never prefilled; blank keeps; Clear saved key clears; saved through Sa
await field.fill('sk-test-key');
await expect(key.locator('p.small')).toHaveText('The new key replaces the saved one when you save.');
await expect(status(page)).toHaveText('Unsaved changes.');
await save(page).click();
await clickHostSave(page, save(page), ENABLE_URL);
await expect(status(page)).toHaveText('Saved to the server configuration.');
expect(enables).toHaveLength(1);
expect(enables[0]).toMatchObject({ civitai_api_key: 'sk-test-key', enabled: false });
@@ -243,7 +244,7 @@ test('key never prefilled; blank keeps; Clear saved key clears; saved through Sa
await expect(key.locator('p.small')).toHaveText('The saved key is removed when you save.');
await expect(clear).toHaveCount(0);
await expect(field).toBeFocused();
await save(page).click();
await clickHostSave(page, save(page), ENABLE_URL);
await expect(status(page)).toHaveText('Saved to the server configuration.');
expect(enables.at(-1)).toMatchObject({ clear_civitai_api_key: true });
expect(enables.at(-1)).not.toHaveProperty('civitai_api_key');
@@ -261,7 +262,7 @@ test('a LoRA save over settings changed elsewhere is a conflict, never a blind w
await expect(status(page)).toHaveText('Settings changed elsewhere. Reload this section to see them.');
expect((await serverJson(request, '/__test__/integrations/state')).trigger_words).toBe(false);
// The draft stays; the next Save carries the reread revision and succeeds.
await save(page).click();
await clickHostSave(page, save(page), ENABLE_URL);
await expect(status(page)).toHaveText('Saved to the server configuration.');
expect((await serverJson(request, '/__test__/integrations/state')).trigger_words).toBe(true);
});
@@ -292,7 +293,7 @@ test('a save where only the LoRA part is written says so; the next save needs no
// The next save carries the revision the saved part left: it saves, with no "changed elsewhere".
await nav.getByRole('button', { name: 'Sources & scans', exact: true }).click();
await sourceRow('unplugged').getByRole('button', { name: 'Remove', exact: true }).click();
await save(page).click();
await clickHostSave(page, save(page));
await expect(status(page)).toHaveText('Saved to the server configuration.');
expect((await serverJson(request, '/prompt_manager/settings')).sources.configured.map(source => source.path)).toEqual(['output']);
});
+11 -11
View File
@@ -1,5 +1,6 @@
import { startCoverage, saveCoverage } from '../../tools/vendor/browser-coverage.mjs';
import { test, expect } from './fixtures.mjs';
import { clickHostSave, hostSaveAnswer, SETTINGS_URL } from './settings-save.mjs';
import { seedConcept } from './concept-inventory.mjs';
// System › Sources & scans (#249 System S4 Task 11) on the concept-shaped real fixture, whose two sources are this
@@ -7,7 +8,6 @@ import { seedConcept } from './concept-inventory.mjs';
// Add/Remove edit the host draft behind the one Save row, and every scan starts the session job through the shared
// "Review metadata scan" (D55), scoped to one source from its row (S4 Task 10). The hooks are workspace_system_fixture.py's.
const workspace = '/prompt_manager/workspace';
const SETTINGS_URL = '/prompt_manager/settings';
const NOTICE_KEY = 'pm_update_notice_dismissed';
const OUTSIDE_REASON = 'Gallery root must be inside a ComfyUI directory (output, input, temp, user) or one listed in PROMPT_MANAGER_EXTRA_GALLERY_ROOTS';
@@ -152,9 +152,9 @@ test('Add source validates on the server, then marks the host draft dirty; Save
]);
await expect(statusOf(page)).toHaveText('Unsaved changes.');
expect((await serverJson(request, SETTINGS_URL)).sources.effective).toHaveLength(2);
const saved = page.waitForRequest(item => item.method() === 'POST' && item.url().endsWith(SETTINGS_URL));
const saved = hostSaveAnswer(page);
await saveButton(page).click();
const body = (await saved).postDataJSON();
const body = (await saved).request().postDataJSON();
expect(body.gallery_root_paths).toEqual(['output', 'input', 'output/unthumbnailed']);
expect(typeof body.expected_revision).toBe('string');
await expect(statusOf(page)).toHaveText('Saved to the server configuration.');
@@ -207,7 +207,7 @@ test('Remove marks the draft; removing the last entry states auto-detect', async
await expect(statusOf(page)).toHaveText('Unsaved changes.');
await sourceRow(page, 'ComfyUI output').getByRole('button', { name: 'Remove', exact: true }).click();
expect(await rowsOf(page)).toEqual([['p', 'small', 'No source is configured. After saving, ComfyUI’s output folder is used.']]);
await saveButton(page).click();
await clickHostSave(page, saveButton(page));
await expect(statusOf(page)).toHaveText('Saved to the server configuration.');
// Saved: ComfyUI's output folder is detected and listed without Remove, its row saying it is the default.
await expect.poll(rowsOf.bind(null, page)).toEqual([
@@ -224,7 +224,7 @@ test('a configured source that does not exist says why and can be removed', asyn
expect((await rowsOf(page)).at(-1)).toEqual(['unmounted-drive', `unmounted-drive · ${OUTSIDE_REASON}`, ['Remove']]);
await sourceRow(page, 'unmounted-drive').getByRole('button', { name: 'Remove', exact: true }).click();
await expect(sourceList(page).locator('.operation')).toHaveCount(2);
await saveButton(page).click();
await clickHostSave(page, saveButton(page));
await expect(statusOf(page)).toHaveText('Saved to the server configuration.');
expect((await serverJson(request, SETTINGS_URL)).sources.configured.map(source => source.path)).toEqual(['output', 'input']);
});
@@ -266,7 +266,7 @@ test('Watch for new outputs saves monitoring_enabled; a restart applies it', asy
await expect(sourceList(page).locator('.operation .row-actions > button:first-child')).toHaveText(['Scan changes', 'Scan changes']);
// Switched back on before the restart: the observer still runs, so nothing waits for one.
await monitoring.check();
await saveButton(page).click();
await clickHostSave(page, saveButton(page));
await expect(statusOf(page)).toHaveText('Saved to the server configuration.');
await expect(sourceList(page).locator('.operation p')).toHaveText(['output · watching', 'input · watching']);
});
@@ -327,9 +327,9 @@ test('D158: saved off while the monitor still watches until a restart, the forei
await expect(layout.locator('.setting-row').filter({ has: page.locator('#foreign-runs') }).locator('p.small'))
.toHaveText('Applies while Watch for new outputs is on.');
await foreign.uncheck();
const saved = page.waitForRequest(item => item.method() === 'POST' && item.url().endsWith(SETTINGS_URL));
const saved = hostSaveAnswer(page);
await saveButton(page).click();
expect((await saved).postDataJSON()).toEqual({ save_foreign_runs: false, expected_revision: expect.any(String) });
expect((await saved).request().postDataJSON()).toEqual({ save_foreign_runs: false, expected_revision: expect.any(String) });
await expect(statusOf(page)).toHaveText('Saved to the server configuration.');
} finally {
await request.post(SETTINGS_URL, { data: { save_foreign_runs: true } });
@@ -349,9 +349,9 @@ test('worker range max is cpu_count', async ({ page, request }) => {
await workers.fill(String(next));
await expect(statusOf(page)).toHaveText(next === settings.worker_threads ? 'No unsaved changes.' : 'Unsaved changes.');
test.skip(next === settings.worker_threads, 'One core: the range has a single value');
const saved = page.waitForRequest(item => item.method() === 'POST' && item.url().endsWith(SETTINGS_URL));
const saved = hostSaveAnswer(page);
await saveButton(page).click();
expect((await saved).postDataJSON().worker_threads).toBe(next);
expect((await saved).request().postDataJSON().worker_threads).toBe(next);
await expect(statusOf(page)).toHaveText('Saved to the server configuration.');
expect((await serverJson(request, SETTINGS_URL)).settings.worker_threads).toBe(next);
});
@@ -601,7 +601,7 @@ test('a save refused for one unusable source names it and marks its row', async
// Removed, the list saves.
await sourceRow(page, 'unplugged').getByRole('button', { name: 'Remove', exact: true }).click();
await expect(sourceList(page).locator('.operation[aria-invalid="true"]')).toHaveCount(0);
await saveButton(page).click();
await clickHostSave(page, saveButton(page));
await expect(statusOf(page)).toHaveText('Saved to the server configuration.');
expect((await serverJson(request, SETTINGS_URL)).sources.configured.map(source => source.path)).toEqual(['output']);
});
@@ -1,5 +1,6 @@
import { startCoverage, saveCoverage } from '../../tools/vendor/browser-coverage.mjs';
import { test, expect } from './fixtures.mjs';
import { clickHostSave, hostSaveAnswer, SETTINGS_URL } from './settings-save.mjs';
// System › Auto-tagging (#328, System S11 Tasks 6–7) on the tagging fixture (workspace_tagging_fixture.py) with the
// injected fake model: no model file exists and nothing is downloaded or run for real. The fake download waits on the
@@ -8,7 +9,6 @@ import { test, expect } from './fixtures.mjs';
const workspace = '/prompt_manager/workspace';
const MODELS_URL = '/prompt_manager/autotag/models';
const PREVIEW_URL = '/prompt_manager/autotag/batch/preview';
const SETTINGS_URL = '/prompt_manager/settings';
const MODEL_LABELS = ['WD14 SwinV2 · ~400 MB', 'WD14 ViT · ~400 MB', 'GGUF JoyCaption · ~4.5 GB', 'HuggingFace JoyCaption · ~16 GB'];
const FIRST = 'tagging/dunes_00001.png';
const SECOND = 'tagging/dunes_00002.png';
@@ -169,9 +169,9 @@ test('defaults save through Save preferences and the Tag image dialog uses them'
await page.locator('#threshold-general').press('Tab');
await page.locator('#tag-suggestions').fill('15');
await page.locator('#tag-suggestions').press('Tab');
const posted = page.waitForRequest(item => item.method() === 'POST' && new URL(item.url()).pathname === SETTINGS_URL);
const posted = hostSaveAnswer(page);
await save(page).click();
const body = (await posted).postDataJSON();
const body = (await posted).request().postDataJSON();
expect(body).toMatchObject({ autotag_existing: 'merge', autotag_general_threshold: 0.4, autotag_suggestion_limit: 15 });
expect(typeof body.expected_revision).toBe('string');
await expect(status(page)).toHaveText('Saved to the server configuration.');
@@ -468,7 +468,7 @@ test('skipped tags add, preview, remove, save and reload (D202)', async ({ page,
await skippedChips(page).last().getByRole('button', { name: 'Remove zebra', exact: true }).click();
await expect(skippedChips(page)).toHaveCount(2);
await expect(status(page)).toHaveText('Unsaved changes.');
await save(page).click();
await clickHostSave(page, save(page));
await expect(status(page)).toHaveText('Saved to the server configuration.');
expect((await serverJson(request, SETTINGS_URL)).settings.autotag_skipped_tags).toEqual(['blurry', 'light']);
await openTagging(page);
@@ -526,7 +526,7 @@ test('saved instructions: new, edit, per-engine default, delete, save and reload
await page.locator('#instruction-default-hf').selectOption({ label: 'Photo realism' });
await expect(instructionOption(page, 'Photo realism').locator('.chip')).toHaveText(['Default for HuggingFace']);
await expect(status(page)).toHaveText('Unsaved changes.');
await save(page).click();
await clickHostSave(page, save(page));
await expect(status(page)).toHaveText('Saved to the server configuration.');
let saved = (await serverJson(request, SETTINGS_URL)).settings;
expect(saved.autotag_instructions.map(entry => [entry.name, entry.text])).toEqual([['Describe the image', 'Describe the image'],
@@ -538,7 +538,7 @@ test('saved instructions: new, edit, per-engine default, delete, save and reload
await page.locator('#instruction-delete').click();
await expect(page.locator('#instruction-reset')).toHaveText('GGUF now uses Built-in.');
await expect(page.locator('#instruction-default-gguf')).toHaveValue('builtin');
await save(page).click();
await clickHostSave(page, save(page));
await expect(status(page)).toHaveText('Saved to the server configuration.');
saved = (await serverJson(request, SETTINGS_URL)).settings;
expect(saved.autotag_instructions.map(entry => entry.name)).toEqual(['Photo realism']);
+6 -3
View File
@@ -1,5 +1,6 @@
import { startCoverage, saveCoverage } from '../../tools/vendor/browser-coverage.mjs';
import { test, expect } from './fixtures.mjs';
import { clickHostSave, SETTINGS_URL } from './settings-save.mjs';
import { seedConcept } from './concept-inventory.mjs';
import { readCoverageTable, parseControl, CONTROL_EXEMPTIONS } from '../../tools/vendor/legacy-coverage.mjs';
@@ -326,7 +327,7 @@ test('Appearance › Thumbnails saves the server thumbnail settings and never co
await format.selectOption('jpeg');
await surface.locator('#thumbnail-quality').fill('65');
await surface.locator('#thumbnail-quality').dispatchEvent('change');
await page.getByRole('button', { name: 'Save preferences', exact: true }).click();
await clickHostSave(page, page.getByRole('button', { name: 'Save preferences', exact: true }));
await expect(page.locator('#settings-status')).toHaveText('Saved to the server configuration.');
const { settings } = await serverJson(request, '/prompt_manager/settings');
expect([settings.thumbnail_format, settings.thumbnail_quality, settings.thumbnail_edge]).toEqual(['jpeg', 65, 512]);
@@ -456,8 +457,8 @@ test('out-of-order overview responses never repaint a newer section', async ({ p
// System › Appearance (#249 System S3 Task 8): the browser display defaults (`gallerySettings`, preferences.mjs) and the
// two host fields behind the one Save row, and the consumers that read them on their next visit.
const SETTINGS_URL = '/prompt_manager/settings';
const INSPECT_PATH = '/prompt_manager/images/inspect/';
const HOST_SAVED = 'Saved to the server configuration.';
const statusOf = page => page.locator('#workspace-main #settings-status');
const saveOf = page => page.locator('#workspace-main .save-row > button');
const storedSettings = page => page.evaluate(() => JSON.parse(localStorage.getItem('gallerySettings') || 'null'));
@@ -473,7 +474,9 @@ async function openAppearance(page) {
async function saveAppearance(page, text) {
await expect(saveOf(page)).not.toHaveAttribute('aria-disabled', 'true');
await saveOf(page).click();
// A save that reaches the server waits for its answer (#631); one kept in this browser sends nothing.
if (text.includes(HOST_SAVED)) await clickHostSave(page, saveOf(page));
else await saveOf(page).click();
await expect(statusOf(page)).toHaveText(text);
}
+8 -2
View File
@@ -35,6 +35,10 @@ from utils.execution_outputs import OutputBundle, OutputReference, snapshot_outp
from utils.pair_execution import EXECUTION_KEY
from tests.browser.folder_trash import replace_folder
# Recorded outputs use the host's path style, as production does (#629): a
# Windows temp root is not an absolute POSIX path and would get no root key.
HOST_PATH_STYLE = "windows" if os.name == "nt" else "posix"
if TYPE_CHECKING:
from py.api import PromptManagerAPI
@@ -433,7 +437,9 @@ def seed_workspace_concept(
folder = root / "output" / "concepts"
folder.mkdir()
roots = snapshot_output_roots("posix", str(root / "output"), str(root / "temp"))
roots = snapshot_output_roots(
HOST_PATH_STYLE, str(root / "output"), str(root / "temp")
)
# The API package needs the host stubs the server installs before importing it.
from py.api.images import _favorite_relative_key, _favorite_root_key
@@ -474,7 +480,7 @@ def seed_workspace_concept(
"3", _snapshot(prompt.positive), _snapshot(negative), "inferred"
)
reference = OutputReference(
"4", 0, "output", "concepts", name, "posix", roots.output_key
"4", 0, "output", "concepts", name, HOST_PATH_STYLE, roots.output_key
)
runs.append(
_record_run(
+5 -2
View File
@@ -15,6 +15,7 @@ from aiohttp import web
from PIL import Image
from PIL.PngImagePlugin import PngInfo
from tests.browser.workspace_concept_fixture import HOST_PATH_STYLE
from tests.browser.workspace_visual_fixture import _write_art, seed_workspace_visual
from utils.execution_contexts import (
ContextBundle,
@@ -293,7 +294,9 @@ def seed_workspace_history(
):
conn.execute(f"DELETE FROM {table}")
epoch = api.db.get_execution_epoch()
roots = snapshot_output_roots("posix", str(root / "output"), str(root / "temp"))
roots = snapshot_output_roots(
HOST_PATH_STYLE, str(root / "output"), str(root / "temp")
)
folder = root / "output" / "history"
folder.mkdir(exist_ok=True)
for index, name in enumerate(("current.png", "other.png")):
@@ -309,7 +312,7 @@ def seed_workspace_history(
kind,
"history",
name,
"posix",
HOST_PATH_STYLE,
roots.output_key if kind == "output" else roots.temp_key,
)
+70
View File
@@ -0,0 +1,70 @@
"""The logo and icons are wired in where a user sees them (#632).
Every page Prompt Manager serves names the favicon, the files it names exist
at the sizes they claim, the README and the Registry metadata point at files
that are in the repository, and the Registry package keeps what the pages
load at run time.
"""
import re
import tomllib
import unittest
from pathlib import Path
from PIL import Image
try:
from tests.test_package_contents import _ignored
except ImportError: # discovered with tests/ as the top-level directory
from test_package_contents import _ignored
ROOT = Path(__file__).resolve().parent.parent
PAGES = ("workspace.html", "admin.html", "gallery.html", "metadata.html", "index.html")
ICON_LINK = re.compile(
r'<link rel="(icon|apple-touch-icon)"(?: type="image/png")?'
r' sizes="(\d+)x(\d+)" href="(lib/brand/[a-z0-9-]+\.png)">'
)
RAW_PREFIX = "https://raw.githubusercontent.com/ComfyAssets/ComfyUI_PromptManager/main/"
def _size(path: Path) -> tuple[int, int]:
with Image.open(path) as image:
return image.size
class TestBrandAssets(unittest.TestCase):
def test_every_page_links_icons_that_exist_at_the_stated_size(self):
for page in PAGES:
with self.subTest(page=page):
html = (ROOT / "web" / page).read_text(encoding="utf-8")
links = ICON_LINK.findall(html)
self.assertEqual(
[kind for kind, *_ in links], ["icon", "apple-touch-icon"]
)
for _kind, width, height, href in links:
# Pages sit beside lib/ under /prompt_manager/, like their CSS.
file = ROOT / "web" / href
self.assertEqual(_size(file), (int(width), int(height)), href)
def test_page_icons_ship_in_the_registry_package(self):
for file in sorted((ROOT / "web" / "lib" / "brand").iterdir()):
relative = file.relative_to(ROOT).as_posix()
self.assertFalse(_ignored(relative), relative)
self.assertLess(file.stat().st_size, 16 * 1024, relative)
def test_readme_opens_with_the_banner(self):
readme = (ROOT / "README.md").read_text(encoding="utf-8")
first = next(line for line in readme.splitlines() if line.strip())
match = re.fullmatch(r"!\[[^\]]+\]\((assets/brand/[a-z0-9-]+\.webp)\)", first)
self.assertIsNotNone(match, first)
self.assertEqual(_size(ROOT / match.group(1)), (1280, 640))
def test_registry_icon_is_the_app_icon_in_this_repository(self):
with open(ROOT / "pyproject.toml", "rb") as handle:
icon = tomllib.load(handle)["tool"]["comfy"]["Icon"]
self.assertTrue(icon.startswith(RAW_PREFIX), icon)
self.assertEqual(_size(ROOT / icon[len(RAW_PREFIX) :]), (256, 256))
if __name__ == "__main__":
unittest.main()
+40 -2
View File
@@ -6,12 +6,14 @@ down when the launcher's end of its stdin pipe closes, and still removes its
temp root. This runs on every OS in CI, where Windows is the strict case.
"""
import json
import os
import subprocess
import sys
import tempfile
import time
import unittest
import urllib.error
import urllib.request
from pathlib import Path
@@ -19,7 +21,9 @@ REPO_ROOT = Path(__file__).resolve().parent.parent
SERVER_TIMEOUT_S = 60
class TestBrowserServerLifetime(unittest.TestCase):
class BrowserServerCase(unittest.TestCase):
"""Starts the test server in a temp folder of its own; holds no tests."""
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup)
@@ -47,7 +51,8 @@ class TestBrowserServerLifetime(unittest.TestCase):
self.addCleanup(stop)
line = process.stdout.readline().decode()
self.assertTrue(line.startswith("PM_TEST_SERVER_PORT="), line)
url = f"http://127.0.0.1:{int(line.split('=', 1)[1])}/prompt_manager/test"
self.origin = f"http://127.0.0.1:{int(line.split('=', 1)[1])}"
url = f"{self.origin}/prompt_manager/test"
deadline = time.monotonic() + SERVER_TIMEOUT_S
while True:
try:
@@ -62,6 +67,8 @@ class TestBrowserServerLifetime(unittest.TestCase):
def roots(self):
return sorted(path.name for path in Path(self.tmp.name).glob("pm-browser-*"))
class TestBrowserServerLifetime(BrowserServerCase):
def test_server_exits_and_removes_its_temp_root_when_stdin_closes(self):
process = self.start("--exit-on-stdin-eof")
self.assertEqual(len(self.roots()), 1, "the server works in its own temp root")
@@ -79,6 +86,37 @@ class TestBrowserServerLifetime(unittest.TestCase):
process.wait(timeout=1)
class TestBrowserServerSeeding(BrowserServerCase):
"""The fixtures seed on every OS (#629): Windows roots are not POSIX paths."""
def reset(self, path, body):
request = urllib.request.Request(
f"{self.origin}{path}",
json.dumps(body).encode(),
{"Content-Type": "application/json"},
)
try:
with urllib.request.urlopen( # nosec B310
request, timeout=SERVER_TIMEOUT_S
) as response:
return response.status, json.loads(response.read())
except urllib.error.HTTPError as error:
with error:
return error.code, error.read().decode(errors="replace")
def test_concept_fixture_seeds_its_recorded_runs(self):
self.start()
status, body = self.reset("/__test__/concept/reset", {})
self.assertEqual(status, 200, body)
self.assertTrue(body["success"])
def test_history_fixture_seeds_its_recorded_runs(self):
self.start()
status, body = self.reset("/__test__/reset", {"chronological_history": True})
self.assertEqual(status, 200, body)
self.assertTrue(body["success"])
class TestBrowserServerLoraIsolation(unittest.TestCase):
"""#355: page tests never read the developer's LoraManager settings."""
+2
View File
@@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="32x32" href="lib/brand/icon-32.png">
<link rel="apple-touch-icon" sizes="128x128" href="lib/brand/icon-128.png">
<title>PromptManager - Admin Dashboard</title>
<script src="js/theme-bridge.js"></script>
<script src="js/html-escape.js"></script>
+2
View File
@@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="32x32" href="lib/brand/icon-32.png">
<link rel="apple-touch-icon" sizes="128x128" href="lib/brand/icon-128.png">
<title>PromptManager - Gallery</title>
<script src="js/theme-bridge.js"></script>
<script src="js/html-escape.js"></script>
+2
View File
@@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="32x32" href="lib/brand/icon-32.png">
<link rel="apple-touch-icon" sizes="128x128" href="lib/brand/icon-128.png">
<title>PromptManager - Opening the workspace</title>
<style>
body {
Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

+2
View File
@@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="32x32" href="lib/brand/icon-32.png">
<link rel="apple-touch-icon" sizes="128x128" href="lib/brand/icon-128.png">
<title>Image Gallery - Generation Data</title>
<script src="js/theme-bridge.js"></script>
<script src="js/html-escape.js"></script>
+2
View File
@@ -3,6 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" sizes="32x32" href="lib/brand/icon-32.png">
<link rel="apple-touch-icon" sizes="128x128" href="lib/brand/icon-128.png">
<meta name="color-scheme" content="light dark">
<title>Prompt Manager · Workspace</title>
<link rel="stylesheet" href="js/shared/toolkit/controls.css">