Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b9a6f3743 |
@@ -18,6 +18,27 @@ implementation.
|
||||
|
||||
<details>
|
||||
|
||||
<summary><strong>1.4.1 — Newer ComfyUI frontends and clip editor fixes</strong></summary>
|
||||
|
||||
- App Mode works with ComfyUI frontend 1.56.1 and later. These frontends add node pack details to
|
||||
the compiled workflow, which 1.4.0 refused with "The visible H3 graph could not be compiled."
|
||||
- The clip editor and image crop open with ComfyUI frontend 1.57.1 and later, where 1.4.0 said the
|
||||
full editor was unavailable and the image could not be opened. Keys used inside them, such as
|
||||
Ctrl+Z, still stay there instead of changing the canvas.
|
||||
- The sidebar, crop dialog and clip editor follow ComfyUI's light or dark palette on newer
|
||||
frontends too. Before, they could turn light while ComfyUI used a dark palette.
|
||||
- The sidebar stays within the window on older and newer frontends, including after you make the
|
||||
window narrower. Before, it could reach past the window edge.
|
||||
- Hover descriptions of the clip editor's icon buttons keep a readable width. A button alone in its
|
||||
group no longer squeezes its description into a narrow column.
|
||||
- The empty preview monitor and empty timeline tracks now say to click a thumbnail in **Media**,
|
||||
instead of mentioning a **+** button the media bin does not show.
|
||||
- **Settings → Language** names the Traditional Chinese option 正體中文.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary><strong>1.4.0 — Directional wipes, image cropping and easier App Mode setup</strong></summary>
|
||||
|
||||
- The clip editor adds four directional wipes, **Wipe from left**, **Wipe from right**,
|
||||
@@ -254,8 +275,8 @@ message names it. The canvas nodes keep working even when the sidebar cannot loa
|
||||
|
||||
- The prompt pipeline runs on Windows, Linux and WSL. The media features need Windows x64 for now;
|
||||
Linux support for them is coming in an upcoming update.
|
||||
- The clip editor and image crop have been tested on ComfyUI 0.41.0 with frontend 1.55.18. This is
|
||||
a tested combination, not a minimum version.
|
||||
- The clip editor, image crop and App Mode have been tested on ComfyUI 0.42.0 with frontend 1.55.18
|
||||
and with frontend 1.57.1. These are tested combinations, not minimum versions.
|
||||
- Longer-video generation checks the installed H3 implementation separately. If it reports an
|
||||
incompatibility, use a complete, compatible ComfyUI installation; installing FFmpeg or waiting
|
||||
does not fix it.
|
||||
@@ -372,7 +393,7 @@ Open **MiniMax H3 Studio** from the ComfyUI sidebar. It has three pages:
|
||||
| Production | Your generated clips as a project, longer-video planning, and the entry to the clip editor |
|
||||
| Settings | Language, media tools, recovery metadata, retained media, local-perception status and the optional assisted-authoring provider |
|
||||
|
||||
**Settings → Language** offers **Automatic (ComfyUI locale)**, English, 繁體中文 and 简体中文.
|
||||
**Settings → Language** offers **Automatic (ComfyUI locale)**, English, 正體中文 and 简体中文.
|
||||
|
||||
**Settings → Local perception** shows whether the host's existing visual and audio setup is
|
||||
available. **Refresh status** reads its readiness; it does not install dependencies, launch a
|
||||
|
||||
@@ -1,3 +1,69 @@
|
||||
# Release 1.4.1
|
||||
|
||||
## Newer ComfyUI frontends
|
||||
|
||||
- App Mode works with ComfyUI frontend 1.56.1 and later. These frontends add the node pack's
|
||||
identity (`cnr_id`, `aux_id` and `ver`) beside each node's title in the compiled workflow. 1.4.0
|
||||
accepted only the title there, so preparing, connecting or queueing an H3 graph stopped with "The
|
||||
visible H3 graph could not be compiled." These three details are now accepted as short text; any
|
||||
other addition is still refused. Earlier frontends behave as before.
|
||||
- The clip editor and image crop open with frontend 1.57.1 and later. These frontends report
|
||||
whether ComfyUI's mask editor is open in a different way, so 1.4.0 could not keep its own keys
|
||||
apart from ComfyUI's shortcuts there: **Open full editor** said the full editor was unavailable,
|
||||
and **Crop image** said the image could not be opened. Both ways are now supported. Keys used
|
||||
inside the editor or the crop dialog, such as Ctrl+Z, still stay there instead of changing the
|
||||
canvas, and ComfyUI's own shortcuts work again once they close.
|
||||
- ComfyUI frontends from 1.59.0 no longer mark a dark palette the way earlier frontends do, so
|
||||
1.4.0 showed the sidebar, crop dialog and clip editor in light colours even with a dark palette.
|
||||
They now also read the palette's colour scheme, and earlier frontends' dark-palette marker works
|
||||
as before.
|
||||
- Frontend 1.57.1 and later lay out the side panels differently, so 1.4.0 lost the sidebar's width
|
||||
limits there: it kept its minimum width in a narrow window and could reach past the window edge.
|
||||
The sidebar now finds both panel layouts and stays within the window and clear of a panel open on
|
||||
the other side. It keeps its usual minimum width when the window has room.
|
||||
- On earlier frontends, a sidebar at its minimum width could stay too wide after the window was
|
||||
made narrower, and reach past the window edge until the window was widened again. It now follows
|
||||
the window in both directions, on every frontend.
|
||||
|
||||
## Clip editor
|
||||
|
||||
- Hover descriptions of icon buttons keep a readable width, up to the space the editor shows. A
|
||||
button alone in its group used to squeeze its description to the button's width, which split
|
||||
words across lines.
|
||||
- The empty preview monitor and empty timeline tracks now say to click a thumbnail in **Media**,
|
||||
which adds it to the timeline. They no longer mention a **+** button that the media bin does not
|
||||
show. The hints are updated in English, Traditional Chinese and Simplified Chinese.
|
||||
|
||||
## Language setting
|
||||
|
||||
- **Settings → Language** lists the Traditional Chinese option as 正體中文, in every interface
|
||||
language. The saved setting is unchanged, so an existing choice stays selected.
|
||||
|
||||
## Compatibility
|
||||
|
||||
- The clip editor, image crop and App Mode were tested on ComfyUI 0.42.0 with frontend 1.55.18 and
|
||||
with frontend 1.57.1, including the light and dark palettes and narrow windows.
|
||||
|
||||
## Package links
|
||||
|
||||
- The package's repository, documentation, issue tracker and icon links now use the repository's
|
||||
current name, `MiniMaxH3-Studio`, so they no longer go through GitHub's redirect from the old name.
|
||||
The Comfy Registry name **ComfyUI-MiniMaxH3-Studio** is unchanged.
|
||||
|
||||
## Developer notes
|
||||
|
||||
- Browser tests model both side-panel layouts and both palette signals, and narrow and widen one
|
||||
page step by step instead of only loading it at each size. Unit tests cover both ways the host
|
||||
reports the mask editor and the node pack details in compiled workflows.
|
||||
|
||||
## Upgrade and limits
|
||||
|
||||
Replace the complete package, restart ComfyUI and refresh the browser. Project, settings and other
|
||||
public data formats are unchanged from 1.4.0. The supported FFmpeg build, platform requirements and
|
||||
storage requirements are unchanged.
|
||||
|
||||
---
|
||||
|
||||
# Release 1.4.0
|
||||
|
||||
## Clip editor transitions
|
||||
|
||||
@@ -137,7 +137,7 @@ if os.environ.get("H3_CONTEXT_HOST_SEQUENCE_CONTINUATION_CANARY") == "1":
|
||||
NODE_CLASS_MAPPINGS = {**NODE_CLASS_MAPPINGS, **CANARY_NODES}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {**NODE_DISPLAY_NAME_MAPPINGS, **CANARY_DISPLAY_NAMES}
|
||||
|
||||
__version__ = "1.4.0"
|
||||
__version__ = "1.4.1"
|
||||
WEB_DIRECTORY = "web"
|
||||
|
||||
# CRITICAL: this bounded operator attempt runs after node registration. Its module owner survives
|
||||
|
||||
@@ -5,26 +5,26 @@
|
||||
},
|
||||
"bundle": {
|
||||
"path": "comfyui_h3_context/web/h3-context-sidebar.js",
|
||||
"sha256": "sha256:a67420d0c60f13801603f4898610d789270e296c3d713f63e2ec02244bea8fe7",
|
||||
"size": 1970766
|
||||
"sha256": "sha256:e437955793c7eb29f2c32af62ff00c1bbc74915d7d99f80a988a0506d5f1630c",
|
||||
"size": 1974807
|
||||
},
|
||||
"embedded_identity": {
|
||||
"builder_id": "scripts/frontend_build_report.py",
|
||||
"resolved_dependencies_sha256": "sha256:545f3ad6c0687ba3bd93501e7f4225807fba71a6c80d0d135942a200ac22ddfb",
|
||||
"schema": "h3-context-build-identity/1",
|
||||
"source_commit": "b9e8134c284b01a78b12a1e1983d7aba538cd81e",
|
||||
"source_inputs_sha256": "sha256:f43896d9be3bc9cb9ecff1d3bd57de0e1ac7d8bab96216ccb97dbd660cef277c",
|
||||
"source_tree": "ebc021cada7d88ba545a168040ca08a20fd10aa6"
|
||||
"source_commit": "76c3231aa93c43b5decd1174c42ffea4f0f4c729",
|
||||
"source_inputs_sha256": "sha256:85da3e808263e4f5d8a6e5bf288242933da6114c68926f5056086a703e7fb592",
|
||||
"source_tree": "6a047d21dda16293dcc6e0450873bc711845431d"
|
||||
},
|
||||
"external_parameters": {
|
||||
"source_commit": "b9e8134c284b01a78b12a1e1983d7aba538cd81e",
|
||||
"source_inputs_sha256": "sha256:f43896d9be3bc9cb9ecff1d3bd57de0e1ac7d8bab96216ccb97dbd660cef277c",
|
||||
"source_tree": "ebc021cada7d88ba545a168040ca08a20fd10aa6"
|
||||
"source_commit": "76c3231aa93c43b5decd1174c42ffea4f0f4c729",
|
||||
"source_inputs_sha256": "sha256:85da3e808263e4f5d8a6e5bf288242933da6114c68926f5056086a703e7fb592",
|
||||
"source_tree": "6a047d21dda16293dcc6e0450873bc711845431d"
|
||||
},
|
||||
"invocation": {
|
||||
"finished_on": "2026-10-24T20:07:27Z",
|
||||
"id": "sha256:7255e94d45a10b9c20cd9776863ac431aaacd92d358b88f5df5814f3266427f1",
|
||||
"started_on": "2026-10-24T20:07:27Z"
|
||||
"finished_on": "2026-10-26T15:46:24Z",
|
||||
"id": "sha256:f5e49eab44fd3589fd4ab923b3175feba3c8e0394b3f77542f28ee6569c5e409",
|
||||
"started_on": "2026-10-26T15:46:24Z"
|
||||
},
|
||||
"resolved_dependencies": [
|
||||
{
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"profiles":[{"compatibility":["python>=3.10"],"distribution":"minimax-h3-studio==1.4.0","download_policy":"artifact_only","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"artifact","model_management":"none","owner":"package","profile_id":"core_manual","removal":"remove_package_owned_files","required":true,"rollback":"reinstall_previous_verified_artifact","runtime_entries":["comfyui_h3_context"],"storage_owner":"package"},{"compatibility":["comfyui-native-node-capabilities-v1","comfyui-frontend-extension-api-v1"],"distribution":"host-provided","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"host_reuse","model_management":"host_only","owner":"host","profile_id":"comfyui_native","removal":"leave_host_runtime_unchanged","required":true,"rollback":"restore_previous_verified_node_artifact","runtime_entries":["comfyui_h3_context"],"storage_owner":"host"},{"compatibility":["h3-context-ollama-qualification/1"],"distribution":"external-user-managed","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"external_runtime","model_management":"external_only","owner":"user","profile_id":"external_ollama","removal":"leave_external_runtime_unchanged","required":false,"rollback":"user_managed_external_rollback","runtime_entries":[],"storage_owner":"user"},{"compatibility":["openai-compatible-model-list-and-chat-v1"],"distribution":"external-user-managed","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"external_runtime","model_management":"external_only","owner":"user","profile_id":"external_openai_compatible_loopback","removal":"leave_external_runtime_unchanged","required":false,"rollback":"user_managed_external_rollback","runtime_entries":[],"storage_owner":"user"},{"compatibility":["openai-compatible-model-list-and-chat-v1"],"distribution":"third-party-service","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"remote_service","model_management":"provider_managed","owner":"provider","profile_id":"remote_openai_compatible_service","removal":"leave_remote_service_unchanged","required":false,"rollback":"revoke_session_consent_and_clear_selection","runtime_entries":[],"storage_owner":"provider"},{"compatibility":["anthropic-models-and-messages-v1"],"distribution":"third-party-service","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"remote_service","model_management":"provider_managed","owner":"provider","profile_id":"remote_anthropic_service","removal":"leave_remote_service_unchanged","required":false,"rollback":"revoke_session_consent_and_clear_selection","runtime_entries":[],"storage_owner":"provider"},{"compatibility":["comfyui-frontend-extension-api-v1"],"distribution":"bundled-with-minimax-h3-studio","download_policy":"artifact_only","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"bundled_asset","model_management":"none","owner":"package","profile_id":"frontend_extension","removal":"remove_package_owned_bundle","required":true,"rollback":"reinstall_previous_verified_artifact","runtime_entries":["comfyui_h3_context/web/h3-context-sidebar.js"],"storage_owner":"package"}],"schema":"h3-context-installation-profiles/1","version":1}
|
||||
{"profiles":[{"compatibility":["python>=3.10"],"distribution":"minimax-h3-studio==1.4.1","download_policy":"artifact_only","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"artifact","model_management":"none","owner":"package","profile_id":"core_manual","removal":"remove_package_owned_files","required":true,"rollback":"reinstall_previous_verified_artifact","runtime_entries":["comfyui_h3_context"],"storage_owner":"package"},{"compatibility":["comfyui-native-node-capabilities-v1","comfyui-frontend-extension-api-v1"],"distribution":"host-provided","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"host_reuse","model_management":"host_only","owner":"host","profile_id":"comfyui_native","removal":"leave_host_runtime_unchanged","required":true,"rollback":"restore_previous_verified_node_artifact","runtime_entries":["comfyui_h3_context"],"storage_owner":"host"},{"compatibility":["h3-context-ollama-qualification/1"],"distribution":"external-user-managed","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"external_runtime","model_management":"external_only","owner":"user","profile_id":"external_ollama","removal":"leave_external_runtime_unchanged","required":false,"rollback":"user_managed_external_rollback","runtime_entries":[],"storage_owner":"user"},{"compatibility":["openai-compatible-model-list-and-chat-v1"],"distribution":"external-user-managed","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"external_runtime","model_management":"external_only","owner":"user","profile_id":"external_openai_compatible_loopback","removal":"leave_external_runtime_unchanged","required":false,"rollback":"user_managed_external_rollback","runtime_entries":[],"storage_owner":"user"},{"compatibility":["openai-compatible-model-list-and-chat-v1"],"distribution":"third-party-service","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"remote_service","model_management":"provider_managed","owner":"provider","profile_id":"remote_openai_compatible_service","removal":"leave_remote_service_unchanged","required":false,"rollback":"revoke_session_consent_and_clear_selection","runtime_entries":[],"storage_owner":"provider"},{"compatibility":["anthropic-models-and-messages-v1"],"distribution":"third-party-service","download_policy":"forbidden","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"remote_service","model_management":"provider_managed","owner":"provider","profile_id":"remote_anthropic_service","removal":"leave_remote_service_unchanged","required":false,"rollback":"revoke_session_consent_and_clear_selection","runtime_entries":[],"storage_owner":"provider"},{"compatibility":["comfyui-frontend-extension-api-v1"],"distribution":"bundled-with-minimax-h3-studio","download_policy":"artifact_only","end_user_node_lifecycle":"forbidden","fallback":"none","install_mode":"bundled_asset","model_management":"none","owner":"package","profile_id":"frontend_extension","removal":"remove_package_owned_bundle","required":true,"rollback":"reinstall_previous_verified_artifact","runtime_entries":["comfyui_h3_context/web/h3-context-sidebar.js"],"storage_owner":"package"}],"schema":"h3-context-installation-profiles/1","version":1}
|
||||
|
||||
@@ -116,7 +116,7 @@ def build_default_installation_profiles() -> InstallationProfileManifest:
|
||||
profile_id="core_manual",
|
||||
owner="package",
|
||||
# IMPORTANT: match package and manifest versions; strict decoding rejects drift.
|
||||
distribution="minimax-h3-studio==1.4.0",
|
||||
distribution="minimax-h3-studio==1.4.1",
|
||||
compatibility=("python>=3.10",),
|
||||
required=True,
|
||||
install_mode="artifact",
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -183,7 +183,7 @@ Build a Python source distribution from a Git checkout whose reviewed public inp
|
||||
|
||||
```powershell
|
||||
& .\.venv\Scripts\python.exe -m build --sdist
|
||||
& .\.venv\Scripts\python.exe scripts/sdist_payload.py --archive dist/minimax_h3_studio-1.4.0.tar.gz
|
||||
& .\.venv\Scripts\python.exe scripts/sdist_payload.py --archive dist/minimax_h3_studio-1.4.1.tar.gz
|
||||
```
|
||||
|
||||
The standard build backend copies public tracked files into a fresh temporary tree and respects
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Host appearance compatibility harness</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
#surface {
|
||||
position: relative;
|
||||
margin-left: 58px;
|
||||
width: 1000px;
|
||||
height: 600px;
|
||||
}
|
||||
#panel {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 1100px;
|
||||
}
|
||||
#canvas {
|
||||
position: absolute;
|
||||
left: 234px;
|
||||
width: 478px;
|
||||
height: 500px;
|
||||
}
|
||||
#opposite {
|
||||
position: absolute;
|
||||
left: 712px;
|
||||
width: 288px;
|
||||
height: 500px;
|
||||
}
|
||||
#surface.continuous {
|
||||
display: flex;
|
||||
margin-left: 56px;
|
||||
width: calc(100% - 56px);
|
||||
overflow: hidden;
|
||||
}
|
||||
.continuous #panel {
|
||||
position: relative;
|
||||
flex: 0 0 233px;
|
||||
width: 233px;
|
||||
min-width: 0;
|
||||
}
|
||||
.continuous #main {
|
||||
flex: 1 1 0%;
|
||||
min-width: 0;
|
||||
}
|
||||
.continuous #canvas {
|
||||
position: relative;
|
||||
left: 8px;
|
||||
width: max(0px, calc(100% - 8px));
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="surface">
|
||||
<div id="panel" class="side-bar-panel"><div id="root"></div></div>
|
||||
<div id="canvas" class="graph-canvas-panel"></div>
|
||||
<div id="opposite" class="side-bar-panel"></div>
|
||||
</div>
|
||||
<script type="module" src="/hostAppearance.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,39 @@
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { H3Sidebar } from "../src/components/H3Sidebar";
|
||||
import { createSidebarWidthController } from "../src/host/sidebarWidth";
|
||||
import { initialShellState } from "../src/state/shellState";
|
||||
import "../src/styles/tokens.css";
|
||||
|
||||
const query = new URLSearchParams(location.search);
|
||||
if (query.get("host") !== "none") document.body.classList.add("litegraph");
|
||||
if (query.get("darkClass") === "1")
|
||||
document.documentElement.classList.add("dark-theme");
|
||||
document.documentElement.style.colorScheme = query.get("scheme") ?? "";
|
||||
const surface = document.getElementById("surface")!;
|
||||
if (query.get("shape") === "prime") {
|
||||
surface.className = "p-splitter";
|
||||
surface.dataset.pcName = "splitter";
|
||||
}
|
||||
if (query.get("shape") === "unknown") {
|
||||
document.getElementById("canvas")!.remove();
|
||||
document.getElementById("opposite")!.remove();
|
||||
surface.style.width = "620px";
|
||||
}
|
||||
if (query.get("layout") === "continuous") {
|
||||
surface.classList.add("continuous");
|
||||
const main = document.createElement("div");
|
||||
main.id = "main";
|
||||
main.append(document.getElementById("canvas")!);
|
||||
document.getElementById("opposite")!.remove();
|
||||
surface.append(main);
|
||||
}
|
||||
const mount = document.getElementById("root")!;
|
||||
const root = createRoot(mount);
|
||||
root.render(<H3Sidebar state={initialShellState} locale="en" />);
|
||||
const disposeWidth = createSidebarWidthController(mount);
|
||||
Object.assign(window, {
|
||||
disposeAppearance() {
|
||||
root.unmount();
|
||||
disposeWidth();
|
||||
},
|
||||
});
|
||||
@@ -1,6 +1,37 @@
|
||||
import { app as host } from "../tests/fixtures/entryHostModules";
|
||||
import {
|
||||
app as host,
|
||||
fixtureModalStore,
|
||||
setFixtureModalKeyboardShape,
|
||||
} from "../tests/fixtures/entryHostModules";
|
||||
import type { ModalKeyboardHostShape } from "../tests/support/hostSeamTestDouble";
|
||||
export { app, api } from "../tests/fixtures/entryHostModules";
|
||||
|
||||
let predicateShape: ModalKeyboardHostShape = "data";
|
||||
export function configureHostModalPredicate(shape: ModalKeyboardHostShape) {
|
||||
predicateShape = shape;
|
||||
setFixtureModalKeyboardShape(shape);
|
||||
}
|
||||
|
||||
export function hostModalPredicateActive(): boolean {
|
||||
const predicate =
|
||||
predicateShape === "accessor"
|
||||
? fixtureModalStore.predicate
|
||||
: (Reflect.get(host.constructor, "maskeditor_is_opended") as
|
||||
(() => unknown) | null | undefined);
|
||||
return Boolean(predicate?.call(host.constructor));
|
||||
}
|
||||
|
||||
/** The aria-modal branch of both supported hosts' modalUtil.isModalOpen. */
|
||||
export function hostAriaModalOpen(): boolean {
|
||||
return Array.from(
|
||||
document.querySelectorAll('[role="dialog"][aria-modal="true"]'),
|
||||
).some(
|
||||
(element) =>
|
||||
element.closest('[hidden], [aria-hidden="true"]') === null &&
|
||||
element.checkVisibility({ visibilityProperty: true }),
|
||||
);
|
||||
}
|
||||
|
||||
export type HostKeyWitness = {
|
||||
undoCapture: number;
|
||||
undoActions: number;
|
||||
@@ -18,8 +49,8 @@ export function installHostCapture(
|
||||
canvasKeyups: 0,
|
||||
ghostActions: 0,
|
||||
};
|
||||
// Source-compatible older change-tracker filter; this hermetic mirror is not a native
|
||||
// old-frontend installation. Counts contain no graph, prompt or node payload.
|
||||
// Source-compatible constructor/store readers, plus their shared DOM containment.
|
||||
// This hermetic mirror is not an installed frontend; retain only action counts.
|
||||
window.addEventListener(
|
||||
"keydown",
|
||||
(event) => {
|
||||
@@ -30,17 +61,14 @@ export function installHostCapture(
|
||||
)
|
||||
return;
|
||||
witness.undoCapture += 1;
|
||||
const predicate = Reflect.get(
|
||||
host.constructor,
|
||||
"maskeditor_is_opended",
|
||||
) as (() => boolean) | null;
|
||||
if (predicate?.call(host.constructor)) return;
|
||||
if (hostModalPredicateActive()) return;
|
||||
if (
|
||||
!changeMode &&
|
||||
(event.target instanceof HTMLInputElement ||
|
||||
event.target instanceof HTMLTextAreaElement)
|
||||
)
|
||||
return;
|
||||
if (hostAriaModalOpen()) return;
|
||||
witness.undoActions += 1;
|
||||
},
|
||||
true,
|
||||
|
||||
@@ -1140,7 +1140,7 @@ function ConnectGuidanceHarness() {
|
||||
onChange={(event) => setLocale(event.target.value as Locale)}
|
||||
>
|
||||
<option value="en">English</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
<option value="zh-TW">正體中文</option>
|
||||
<option value="zh-CN">简体中文</option>
|
||||
</select>
|
||||
</label>
|
||||
@@ -1900,7 +1900,7 @@ function ProductionHarness() {
|
||||
onChange={(event) => setLocale(event.target.value as Locale)}
|
||||
>
|
||||
<option value="en">English</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
<option value="zh-TW">正體中文</option>
|
||||
<option value="zh-CN">简体中文</option>
|
||||
</select>
|
||||
</label>
|
||||
@@ -2528,7 +2528,7 @@ function Harness() {
|
||||
onChange={(event) => setLocale(event.target.value as Locale)}
|
||||
>
|
||||
<option value="en">English</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
<option value="zh-TW">正體中文</option>
|
||||
<option value="zh-CN">简体中文</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
@@ -15,7 +15,10 @@ import {
|
||||
import type { AuthoringMediaDecorationLeaseClient } from "../src/host/authoringMediaSourceLease";
|
||||
import { defaultDigest } from "../src/host/authoringMediaLeaseTransport";
|
||||
import type { AuthoringMediaVideoSourceContext } from "../src/runtime/authoringDecorationLeaseRequest";
|
||||
import type { MediaTransportOpen } from "../src/runtime/editorRuntime";
|
||||
import {
|
||||
NATIVE_MEDIA_OPERATION_DEADLINE_MS,
|
||||
type MediaTransportOpen,
|
||||
} from "../src/runtime/editorRuntime";
|
||||
import { validatePublicAssetManifest } from "../src/runtime/publicAssetManifest";
|
||||
|
||||
const geometry = (width: number, height: number): AuthoringMediaGeometry => ({
|
||||
@@ -36,22 +39,23 @@ const geometry = (width: number, height: number): AuthoringMediaGeometry => ({
|
||||
// duplicates the primary's), each with its own element and its own clock, so the asset-keyed
|
||||
// entry is only ever the most recent lease; a journey asking which source time a *clip* presents
|
||||
// reads the clip-keyed entry.
|
||||
// `sourceHandoverReadyStates` records each source element's `readyState` at the moment it is
|
||||
// handed to the runtime, so a journey can prove the hand-over precondition below.
|
||||
declare global {
|
||||
interface Window {
|
||||
__nleMediaDebug?: {
|
||||
videoElementsByAsset: Map<string, HTMLVideoElement>;
|
||||
videoElementsByClip: Map<string, HTMLVideoElement>;
|
||||
sourceHandoverReadyStates: number[];
|
||||
};
|
||||
}
|
||||
}
|
||||
function debugRegistry(): {
|
||||
videoElementsByAsset: Map<string, HTMLVideoElement>;
|
||||
videoElementsByClip: Map<string, HTMLVideoElement>;
|
||||
} {
|
||||
function debugRegistry(): NonNullable<Window["__nleMediaDebug"]> {
|
||||
if (window.__nleMediaDebug === undefined) {
|
||||
window.__nleMediaDebug = {
|
||||
videoElementsByAsset: new Map(),
|
||||
videoElementsByClip: new Map(),
|
||||
sourceHandoverReadyStates: [],
|
||||
};
|
||||
}
|
||||
return window.__nleMediaDebug;
|
||||
@@ -390,29 +394,58 @@ async function still(
|
||||
return { blob, corpus: false };
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits until a source element has metadata, the state the product's own source owner hands over
|
||||
* (`waitForVideoMetadata` in `src/host/authoringMediaSourceLease.ts`), with the same bound.
|
||||
*
|
||||
* IMPORTANT: every source video, generic or corpus, must be handed over only after this wait.
|
||||
* The runtime assigns `currentTime` at once. At HAVE_NOTHING that assignment only records a start
|
||||
* position: no seek, `seeked` or `timeupdate` follows, so the open depends on a single first-frame
|
||||
* frame callback. A busy browser can lose that callback, and the native 3 s presentation deadline
|
||||
* then latches the monitor as "source unavailable" with Play disabled (about 1 open in 30-60 with
|
||||
* the browser held to two CPUs). Returning generic media before metadata, as this harness once
|
||||
* did, is the divergence to avoid.
|
||||
*/
|
||||
async function sourceMetadata(
|
||||
element: HTMLVideoElement,
|
||||
signal: AbortSignal,
|
||||
): Promise<void> {
|
||||
if (signal.aborted) throw new Error("cancelled");
|
||||
if (element.readyState >= 1) return;
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
const finish = (error?: Error) => {
|
||||
element.removeEventListener("loadedmetadata", loaded);
|
||||
element.removeEventListener("error", undecodable);
|
||||
element.removeEventListener("abort", undecodable);
|
||||
signal.removeEventListener("abort", cancelled);
|
||||
clearTimeout(timer);
|
||||
if (error === undefined) resolve();
|
||||
else reject(error);
|
||||
};
|
||||
const loaded = () => finish();
|
||||
const undecodable = () => finish(new Error("synthetic_media_undecodable"));
|
||||
const cancelled = () => finish(new Error("cancelled"));
|
||||
element.addEventListener("loadedmetadata", loaded, { once: true });
|
||||
element.addEventListener("error", undecodable, { once: true });
|
||||
element.addEventListener("abort", undecodable, { once: true });
|
||||
signal.addEventListener("abort", cancelled, { once: true });
|
||||
timer = setTimeout(undecodable, NATIVE_MEDIA_OPERATION_DEADLINE_MS);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The served corpus source's true pixel size for `geometry.sourceWidth`/`sourceHeight`, measured
|
||||
* from the decoded media itself (a transform or crop row's expectation is derived from
|
||||
* `semantic_conformance_media.SOURCE_WIDTH`/`SOURCE_HEIGHT` and the clip's own transform, so the
|
||||
* runtime must present the real source size). Only a response the corpus route marked is
|
||||
* measured; an unmarked response keeps the generic placeholder geometry every other journey
|
||||
* already relies on, whatever asset id it was requested under.
|
||||
* already relies on, whatever asset id it was requested under. Call it after `sourceMetadata`.
|
||||
*/
|
||||
async function measuredVideoGeometry(
|
||||
element: HTMLVideoElement,
|
||||
): Promise<{ width: number; height: number }> {
|
||||
if (element.readyState < 1) {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
element.addEventListener("loadedmetadata", () => resolve(), {
|
||||
once: true,
|
||||
});
|
||||
element.addEventListener(
|
||||
"error",
|
||||
() => reject(new Error("synthetic_media_undecodable")),
|
||||
{ once: true },
|
||||
);
|
||||
});
|
||||
}
|
||||
function measuredVideoGeometry(element: HTMLVideoElement): {
|
||||
width: number;
|
||||
height: number;
|
||||
} {
|
||||
return { width: element.videoWidth, height: element.videoHeight };
|
||||
}
|
||||
|
||||
@@ -562,8 +595,15 @@ const untrackedMediaClient: AuthoringMediaDecorationLeaseClient = {
|
||||
videoElements--;
|
||||
dropRetention();
|
||||
}, "source");
|
||||
try {
|
||||
await sourceMetadata(element, request.signal);
|
||||
} catch (error) {
|
||||
release();
|
||||
throw error;
|
||||
}
|
||||
registry.sourceHandoverReadyStates.push(element.readyState);
|
||||
const { width, height } = corpus
|
||||
? await measuredVideoGeometry(element)
|
||||
? measuredVideoGeometry(element)
|
||||
: { width: 320, height: 180 };
|
||||
return {
|
||||
element,
|
||||
|
||||
@@ -4,11 +4,19 @@ import {
|
||||
initialAppModeDraft,
|
||||
type AppModeDraft,
|
||||
} from "../src/components/H3Sidebar";
|
||||
import { SUPPORTED_LOCALES, type Locale } from "../src/i18n/catalog";
|
||||
import {
|
||||
sidebarCopy,
|
||||
SUPPORTED_LOCALES,
|
||||
type Locale,
|
||||
} from "../src/i18n/catalog";
|
||||
import { ImageCropAction } from "../src/components/ImageCropAction";
|
||||
import { initialShellState } from "../src/state/shellState";
|
||||
import { createImageCropSources } from "../src/host/imageCropSource";
|
||||
import { seamReady } from "../src/host/hostSeams";
|
||||
import { fixtureBackedAppModeApi } from "../tests/support/hostSeamTestDouble";
|
||||
import { acquireModalKeyboardGuard } from "../src/host/modalKeyboardGuard";
|
||||
import { acquireCanvasKeyboardGuard } from "../src/host/canvasKeyboardGuard";
|
||||
import { app as keyboardHost } from "./hostKeyboard";
|
||||
|
||||
const mediaSources = (["image", "video", "audio"] as const).flatMap(
|
||||
(kind, group) =>
|
||||
@@ -21,6 +29,7 @@ const mediaSources = (["image", "video", "audio"] as const).flatMap(
|
||||
);
|
||||
const empty: AppModeDraft = { ...initialAppModeDraft, taskMode: "ref2va" };
|
||||
export function ReferencePickerHarness({ crop = false }: { crop?: boolean }) {
|
||||
const sample = new URLSearchParams(location.search).get("crop-description");
|
||||
const [locale, setLocale] = useState<Locale>("en");
|
||||
const [draft, setDraft] = useState(empty);
|
||||
const [starts, setStarts] = useState(0);
|
||||
@@ -105,55 +114,84 @@ export function ReferencePickerHarness({ crop = false }: { crop?: boolean }) {
|
||||
</>
|
||||
) : null}
|
||||
<div id="reference-picker-sidebar" style={{ width: "100%" }}>
|
||||
<H3Sidebar
|
||||
locale={locale}
|
||||
state={initialShellState}
|
||||
appModeDraft={draft}
|
||||
onAppModeDraftChange={setDraft}
|
||||
appMode={{
|
||||
...(crop
|
||||
? {
|
||||
imageCrop: {
|
||||
available: cropAvailable,
|
||||
actions: cropSources,
|
||||
acquireKeyboardGuard: () => {
|
||||
setLeases((n) => n + 1);
|
||||
let released = false;
|
||||
return seamReady({
|
||||
release() {
|
||||
if (!released) {
|
||||
released = true;
|
||||
setLeases((n) => n - 1);
|
||||
}
|
||||
},
|
||||
});
|
||||
{crop && (sample === "choose" || sample === "useExisting") ? (
|
||||
<section className="h3c" data-crop-description-sample>
|
||||
<div className="h3-frame-source">
|
||||
<span>{sidebarCopy(locale).firstFrameSource}</span>
|
||||
<ImageCropAction
|
||||
id="sample"
|
||||
actions={{
|
||||
crops: {},
|
||||
label: sidebarCopy(locale).crop.action,
|
||||
reason: sidebarCopy(locale).crop[sample],
|
||||
open() {},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<H3Sidebar
|
||||
locale={locale}
|
||||
state={initialShellState}
|
||||
appModeDraft={draft}
|
||||
onAppModeDraftChange={setDraft}
|
||||
appMode={{
|
||||
...(crop
|
||||
? {
|
||||
imageCrop: {
|
||||
available: cropAvailable,
|
||||
actions: cropSources,
|
||||
acquireKeyboardGuard: (onInvalidated) => {
|
||||
const modal = acquireModalKeyboardGuard(keyboardHost);
|
||||
if (modal.status !== "ready") return modal;
|
||||
const canvas = acquireCanvasKeyboardGuard(
|
||||
keyboardHost,
|
||||
onInvalidated,
|
||||
);
|
||||
if (canvas.status !== "ready") {
|
||||
modal.value.release();
|
||||
return canvas;
|
||||
}
|
||||
setLeases((n) => n + 1);
|
||||
let released = false;
|
||||
return seamReady({
|
||||
release() {
|
||||
if (!released) {
|
||||
released = true;
|
||||
canvas.value.release();
|
||||
modal.value.release();
|
||||
setLeases((n) => n - 1);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
capability: { status: "ready" },
|
||||
mediaSources,
|
||||
imageSources: mediaSources.filter(
|
||||
(source) => source.kind === "image",
|
||||
),
|
||||
durationResolution: {
|
||||
status: "resolved",
|
||||
resolution: {
|
||||
schema: "h3.context.duration_resolution.v1",
|
||||
requested_seconds: 5,
|
||||
requested_milliseconds: 5000,
|
||||
effective_milliseconds: 5167,
|
||||
frame_count: 124,
|
||||
snapped: true,
|
||||
}
|
||||
: {}),
|
||||
capability: { status: "ready" },
|
||||
mediaSources,
|
||||
imageSources: mediaSources.filter(
|
||||
(source) => source.kind === "image",
|
||||
),
|
||||
durationResolution: {
|
||||
status: "resolved",
|
||||
resolution: {
|
||||
schema: "h3.context.duration_resolution.v1",
|
||||
requested_seconds: 5,
|
||||
requested_milliseconds: 5000,
|
||||
effective_milliseconds: 5167,
|
||||
frame_count: 124,
|
||||
snapped: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
onStart: (inputs) => {
|
||||
setPayload(JSON.stringify(inputs));
|
||||
setStarts((value) => value + 1);
|
||||
},
|
||||
onCancel: () => {},
|
||||
}}
|
||||
/>
|
||||
onStart: (inputs) => {
|
||||
setPayload(JSON.stringify(inputs));
|
||||
setStarts((value) => value + 1);
|
||||
},
|
||||
onCancel: () => {},
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@comfyui-h3-context/frontend",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@11.3.0",
|
||||
|
||||
@@ -13,7 +13,10 @@ const e2eBaseUrl = `http://127.0.0.1:${e2ePort}`;
|
||||
export default defineConfig({
|
||||
testDir: "tests/e2e",
|
||||
testMatch: [
|
||||
"journeys/hostAppearance.spec.ts",
|
||||
"journeys/harnessBoot.spec.ts",
|
||||
// The closed open diagnostic a failed integrated-shell open attaches for the hermetic CI.
|
||||
"journeys/integratedShellDiagnostics.spec.ts",
|
||||
"journeys/nleWorkspace.spec.ts",
|
||||
// empty-capable V2 authoring, content extent, and the V1 render boundary.
|
||||
"journeys/m25_57ContentExtent.spec.ts",
|
||||
|
||||
@@ -8,7 +8,14 @@ import {
|
||||
PreparedSourceGuidance,
|
||||
} from "./CanvasSourceGuidance";
|
||||
import { referenceCapacity } from "../host/referenceSelection";
|
||||
import { useEffect, useRef, useState, type KeyboardEvent } from "react";
|
||||
import {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
type KeyboardEvent,
|
||||
} from "react";
|
||||
import { createHostThemeController } from "../host/hostTheme";
|
||||
|
||||
import type {
|
||||
AppModeAdmission,
|
||||
@@ -1352,6 +1359,11 @@ export function H3Sidebar({
|
||||
}) {
|
||||
const text = sidebarCopy(locale);
|
||||
const pages = pageCopy(locale);
|
||||
const themeRoot = useRef<HTMLElement>(null);
|
||||
useLayoutEffect(() => {
|
||||
if (themeRoot.current !== null)
|
||||
return createHostThemeController(themeRoot.current);
|
||||
}, []);
|
||||
const [diagnosticsStatus, setDiagnosticsStatus] = useState<
|
||||
"copied" | "fallback" | undefined
|
||||
>();
|
||||
@@ -1533,6 +1545,7 @@ export function H3Sidebar({
|
||||
return (
|
||||
<section
|
||||
className="h3c"
|
||||
ref={themeRoot}
|
||||
// the panel declares its own language. The CJK type variant keys
|
||||
// on `:lang(zh)`, and a screen reader needs the same signal to pick the
|
||||
// right voice -- without this attribute both would silently do nothing.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import type { SeamResult } from "../host/hostSeams";
|
||||
import { createHostThemeController } from "../host/hostTheme";
|
||||
import type {
|
||||
CropSourceImage,
|
||||
ImageCropSourceActions,
|
||||
@@ -67,6 +68,11 @@ export function ImageCropDialog({
|
||||
const titleId = useId();
|
||||
const helpId = useId();
|
||||
const dialog = useRef<HTMLDivElement>(null);
|
||||
const themeRoot = useRef<HTMLDivElement>(null);
|
||||
useLayoutEffect(() => {
|
||||
if (themeRoot.current !== null)
|
||||
return createHostThemeController(themeRoot.current);
|
||||
}, []);
|
||||
const imageBox = useRef<HTMLDivElement>(null);
|
||||
const release = useRef<() => void>(() => {});
|
||||
const [source, setSource] = useState<CropSourceImage>();
|
||||
@@ -153,7 +159,7 @@ export function ImageCropDialog({
|
||||
};
|
||||
return createPortal(
|
||||
<div data-h3-context-mount="" className="h3-crop-portal">
|
||||
<div className="h3c h3-crop-backdrop">
|
||||
<div className="h3c h3-crop-backdrop" ref={themeRoot}>
|
||||
<div
|
||||
ref={dialog}
|
||||
className="h3-crop-dialog"
|
||||
|
||||
@@ -29,7 +29,7 @@ const copy = {
|
||||
language: "Language",
|
||||
auto: "Automatic (ComfyUI locale)",
|
||||
en: "English",
|
||||
"zh-TW": "繁體中文",
|
||||
"zh-TW": "正體中文",
|
||||
"zh-CN": "简体中文",
|
||||
pending: "Saving language preference.",
|
||||
invalid: "The stored language value is invalid.",
|
||||
@@ -43,7 +43,7 @@ const copy = {
|
||||
language: "語言",
|
||||
auto: "自動(ComfyUI 語系)",
|
||||
en: "English",
|
||||
"zh-TW": "繁體中文",
|
||||
"zh-TW": "正體中文",
|
||||
"zh-CN": "简体中文",
|
||||
pending: "正在儲存語言偏好。",
|
||||
invalid: "已儲存的語言值無效。",
|
||||
@@ -57,7 +57,7 @@ const copy = {
|
||||
language: "语言",
|
||||
auto: "自动(ComfyUI 语言)",
|
||||
en: "English",
|
||||
"zh-TW": "繁體中文",
|
||||
"zh-TW": "正體中文",
|
||||
"zh-CN": "简体中文",
|
||||
pending: "正在保存语言偏好。",
|
||||
invalid: "已保存的语言值无效。",
|
||||
|
||||
@@ -164,13 +164,35 @@ export function NleIconGroup({
|
||||
clipTop = Math.max(node.getBoundingClientRect().top, 0);
|
||||
break;
|
||||
}
|
||||
let clipLeft = 0;
|
||||
let clipRight = document.documentElement.clientWidth;
|
||||
for (let node = group.parentElement; node; node = node.parentElement) {
|
||||
if (getComputedStyle(node).overflowX !== "visible") {
|
||||
const box = node.getBoundingClientRect();
|
||||
clipLeft = Math.max(clipLeft, box.left + node.clientLeft);
|
||||
clipRight = Math.min(
|
||||
clipRight,
|
||||
box.left + node.clientLeft + node.clientWidth,
|
||||
);
|
||||
}
|
||||
}
|
||||
// IMPORTANT: a one-action group is only 44px wide. Keep description width independent of
|
||||
// that group, then anchor inside every horizontal clip; inheriting its width splits words.
|
||||
tip.style.maxInlineSize = `min(20rem, ${Math.max(0, clipRight - clipLeft)}px)`;
|
||||
const groupBox = group.getBoundingClientRect();
|
||||
const width = tip.getBoundingClientRect().width;
|
||||
const start = groupBox.left;
|
||||
const end = groupBox.right - width;
|
||||
const left =
|
||||
start + width <= clipRight
|
||||
? Math.max(start, clipLeft)
|
||||
: Math.max(clipLeft, Math.min(end, clipRight - width));
|
||||
tip.style.left = `${left - groupBox.left}px`;
|
||||
// IMPORTANT: placement is presentation-only. Publishing it through React adds a second root
|
||||
// commit to every focused edit action and breaks the <=4 accepted-edit budget; mutate the
|
||||
// already-owned tooltip node after layout instead.
|
||||
tip.dataset.placement =
|
||||
group.getBoundingClientRect().top - clipTop < tip.offsetHeight + 6
|
||||
? "below"
|
||||
: "above";
|
||||
groupBox.top - clipTop < tip.offsetHeight + 6 ? "below" : "above";
|
||||
};
|
||||
const open = (tip: NonNullable<Tip>, target: HTMLElement | null) => {
|
||||
if (visibleGroup !== null && visibleGroup !== owner) visibleGroup.dismiss();
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { createHostThemeController } from "../../host/hostTheme";
|
||||
|
||||
import type { NleCloseReason } from "../../state/nleWorkspaceState";
|
||||
import { saveIndicatorModel } from "../../runtime/nleSaveIndicator";
|
||||
@@ -333,6 +334,7 @@ export function NleOverlay({ binding }: { binding: NleWorkspaceBinding }) {
|
||||
for (const type of ["keydown", "keyup", "keypress"])
|
||||
host.addEventListener(type, contain);
|
||||
document.body.append(host);
|
||||
const disposeTheme = createHostThemeController(host);
|
||||
const topLayer = enterTopLayer(host);
|
||||
attached.current = true;
|
||||
return () => {
|
||||
@@ -345,6 +347,7 @@ export function NleOverlay({ binding }: { binding: NleWorkspaceBinding }) {
|
||||
} catch {
|
||||
// A root already hidden by its removal needs nothing more.
|
||||
}
|
||||
disposeTheme();
|
||||
host.remove();
|
||||
guard.value.release();
|
||||
// IMPORTANT: restore after the release commit has re-enabled the launcher.
|
||||
|
||||
@@ -128,7 +128,7 @@ export const copy = {
|
||||
pillAdded: "Added",
|
||||
pillImported: "Imported",
|
||||
addToTimeline: "Add to timeline",
|
||||
// D-6: "+" states what Add does today ( makes it append to Main).
|
||||
// D-6: Add appends to Main; thumbnail-card activation works in both media bins.
|
||||
addNamed: "Add {name} to the timeline",
|
||||
addTip: "Append to the end of the primary video track",
|
||||
addPrimaryMissing: "Add refused: the primary video track is unavailable.",
|
||||
@@ -273,7 +273,7 @@ export const copy = {
|
||||
selectedSourceOnly: "Selected source only",
|
||||
selectedSourceNone: "Select a clip with a source to preview it.",
|
||||
emptyHint:
|
||||
"Press + on a thumbnail in Media, or drag it to the timeline, to preview it here.",
|
||||
"Click a thumbnail in Media to add it to the timeline and preview it here.",
|
||||
},
|
||||
audio: {
|
||||
title: "Embedded audio",
|
||||
@@ -379,7 +379,7 @@ export const copy = {
|
||||
clip: "{name}, {start}–{end}, {duration}",
|
||||
titleClip: "Title",
|
||||
railLabel: "{name} · {start}–{end}",
|
||||
emptyLane: "Drag media here, or press + on a thumbnail",
|
||||
emptyLane: "Click a thumbnail in Media to add it here",
|
||||
selected: "selected",
|
||||
trimStart: "Trim start of {name}",
|
||||
snap: "Snap edges",
|
||||
@@ -978,8 +978,7 @@ export const copy = {
|
||||
},
|
||||
selectedSourceOnly: "僅顯示所選來源",
|
||||
selectedSourceNone: "選取含來源的片段以預覽。",
|
||||
emptyHint:
|
||||
"按「媒體」中縮圖上的「+」,或將它拖曳到時間軸,即可在此預覽。",
|
||||
emptyHint: "按一下「媒體」中的縮圖,即可放到時間軸上並在此預覽。",
|
||||
},
|
||||
audio: {
|
||||
title: "內嵌音訊",
|
||||
@@ -1077,7 +1076,7 @@ export const copy = {
|
||||
clip: "{name},{start}–{end},{duration}",
|
||||
titleClip: "標題",
|
||||
railLabel: "{name} · {start}–{end}",
|
||||
emptyLane: "將素材拖曳到這裡,或按縮圖上的「+」",
|
||||
emptyLane: "按一下「媒體」中的縮圖,即可加入此處",
|
||||
selected: "已選取",
|
||||
trimStart: "修剪 {name} 的起點",
|
||||
snap: "邊緣吸附",
|
||||
@@ -1655,7 +1654,7 @@ export const copy = {
|
||||
},
|
||||
selectedSourceOnly: "仅显示所选来源",
|
||||
selectedSourceNone: "选择含来源的片段以预览。",
|
||||
emptyHint: "按“媒体”中缩略图上的“+”,或将它拖到时间线,即可在此预览。",
|
||||
emptyHint: "点击“媒体”中的缩略图,即可放到时间线上并在此预览。",
|
||||
},
|
||||
audio: {
|
||||
title: "内嵌音频",
|
||||
@@ -1753,7 +1752,7 @@ export const copy = {
|
||||
clip: "{name},{start}–{end},{duration}",
|
||||
titleClip: "标题",
|
||||
railLabel: "{name} · {start}–{end}",
|
||||
emptyLane: "将素材拖到这里,或按缩略图上的“+”",
|
||||
emptyLane: "点击“媒体”中的缩略图,即可添加到此处",
|
||||
selected: "已选中",
|
||||
trimStart: "修剪 {name} 的起点",
|
||||
snap: "边缘吸附",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { qualifyAppMode } from "./appModeQualification";
|
||||
import { compiledPromptAdmissionFailure } from "./compiledMetadata";
|
||||
import { readImageCropCapability } from "./imageCropCapability";
|
||||
import {
|
||||
createImageCropSources,
|
||||
@@ -763,12 +764,8 @@ export function createAppModeController(
|
||||
)
|
||||
) {
|
||||
await restoreOwnedGraph();
|
||||
throw new AppModeError(
|
||||
adopting ? "incompatible_graph" : "compile_failed",
|
||||
adopting
|
||||
? "the current graph is not a complete H3 flow with one Product Shell and native generation anchor"
|
||||
: "host compilation returned an unqualified H3 prompt envelope",
|
||||
);
|
||||
const failure = compiledPromptAdmissionFailure(compiled, adopting);
|
||||
throw new AppModeError(failure.code, failure.message);
|
||||
}
|
||||
if (
|
||||
options.useExisting === true &&
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// pure validation and identity helpers every App Mode module shares ( split).
|
||||
|
||||
import { sha256Text } from "../contracts/canonicalFingerprint";
|
||||
import { isSafeCompiledMetadata } from "./compiledMetadata";
|
||||
import { referenceCapacity } from "./referenceSelection";
|
||||
import { validateImageCrops, type ImageCrops } from "./imageCropContract";
|
||||
import type {
|
||||
@@ -803,9 +804,7 @@ export function isSafeCompiledPromptEnvelope(
|
||||
export function isSafeCompiledNodeEnvelope(
|
||||
node: Record<string, unknown>,
|
||||
): boolean {
|
||||
// IMPORTANT: ComfyUI's public API envelope includes only class_type, inputs,
|
||||
// and the presentation-only _meta.title. Rejecting other members keeps
|
||||
// private/unknown payloads out of the queue-boundary contract.
|
||||
// IMPORTANT: compiledMetadata owns the closed host metadata contract and bounds.
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(node, "class_type") ||
|
||||
!Object.prototype.hasOwnProperty.call(node, "inputs")
|
||||
@@ -823,15 +822,8 @@ export function isSafeCompiledNodeEnvelope(
|
||||
return false;
|
||||
if (typeof node.class_type !== "string" || record(node.inputs) === undefined)
|
||||
return false;
|
||||
if (node._meta !== undefined) {
|
||||
const meta = record(node._meta);
|
||||
if (
|
||||
meta === undefined ||
|
||||
Object.keys(meta).some((key) => key !== "title") ||
|
||||
(meta.title !== undefined && typeof meta.title !== "string")
|
||||
)
|
||||
return false;
|
||||
}
|
||||
if (node._meta !== undefined && !isSafeCompiledMetadata(node._meta))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// IMPORTANT: admit host title plus the documented zNodePackMetadata members.
|
||||
// Title-only admission breaks Start on frontend 1.56.1+; preserve admitted values.
|
||||
// Keep title undefined or an unbounded string; bounding it like pack members breaks
|
||||
// Start for long user titles. Unknown members and invalid values stay refused.
|
||||
const COMPILED_META_KEYS = new Set(["title", "cnr_id", "aux_id", "ver"]);
|
||||
|
||||
function record(value: unknown): Record<string, unknown> | undefined {
|
||||
return value !== null && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function isSafeCompiledMetadata(value: unknown): boolean {
|
||||
const meta = record(value);
|
||||
return (
|
||||
meta !== undefined &&
|
||||
Object.entries(meta).every(
|
||||
([key, entry]) =>
|
||||
COMPILED_META_KEYS.has(key) &&
|
||||
(key === "title"
|
||||
? entry === undefined || typeof entry === "string"
|
||||
: typeof entry === "string" && entry.length <= 256),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function hasUnrecognizedCompiledMetadata(compiled: unknown): boolean {
|
||||
const output = record(record(compiled)?.output);
|
||||
return (
|
||||
output !== undefined &&
|
||||
Object.values(output).some((value) => {
|
||||
const node = record(value);
|
||||
return node?._meta !== undefined && !isSafeCompiledMetadata(node._meta);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function compiledPromptAdmissionFailure(
|
||||
compiled: unknown,
|
||||
adopting: boolean,
|
||||
): Readonly<{
|
||||
code: "compile_failed" | "incompatible_graph";
|
||||
message: string;
|
||||
}> {
|
||||
if (hasUnrecognizedCompiledMetadata(compiled))
|
||||
return {
|
||||
code: "compile_failed",
|
||||
message: "an unrecognized compiled _meta member",
|
||||
};
|
||||
return {
|
||||
code: adopting ? "incompatible_graph" : "compile_failed",
|
||||
message: adopting
|
||||
? "the current graph is not a complete H3 flow with one Product Shell and native generation anchor"
|
||||
: "host compilation returned an unqualified H3 prompt envelope",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// IMPORTANT: every owned .h3c root, including body portals, needs this lifecycle controller;
|
||||
// the resolved light selector cannot reach an unwired root, which would stay dark on light hosts.
|
||||
/** Follow host palette signals without taking ownership of harness overrides. */
|
||||
export function createHostThemeController(root: HTMLElement): () => void {
|
||||
const document = root.ownerDocument;
|
||||
const html = document.documentElement;
|
||||
const attribute = "data-h3-host-theme";
|
||||
const original = root.getAttribute(attribute);
|
||||
let active = true;
|
||||
const apply = (): void => {
|
||||
if (!active) return;
|
||||
// IMPORTANT: old hosts signal dark with .dark-theme; newer hosts only set color-scheme.
|
||||
// Testing class absence alone turns every newer dark host light. Ambiguous/no host signals
|
||||
// must retain the hermetic dark default; data-theme remains a separate harness override.
|
||||
// body.litegraph is a static index.html marker, not a live signal; observe only html class/style.
|
||||
const scheme = document.defaultView?.getComputedStyle(html).colorScheme;
|
||||
const theme = html.classList.contains("dark-theme")
|
||||
? "dark"
|
||||
: scheme === "light" || scheme === "dark"
|
||||
? scheme
|
||||
: document.body.classList.contains("litegraph")
|
||||
? "light"
|
||||
: undefined;
|
||||
if (theme === undefined) root.removeAttribute(attribute);
|
||||
else root.setAttribute(attribute, theme);
|
||||
};
|
||||
const observer = new MutationObserver(apply);
|
||||
observer.observe(html, {
|
||||
attributes: true,
|
||||
attributeFilter: ["class", "style"],
|
||||
});
|
||||
apply();
|
||||
return () => {
|
||||
if (!active) return;
|
||||
active = false;
|
||||
observer.disconnect();
|
||||
if (original === null) root.removeAttribute(attribute);
|
||||
else root.setAttribute(attribute, original);
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import { seamReady, seamUnavailable, type SeamResult } from "./hostSeams";
|
||||
|
||||
export type ModalKeyboardGuardLease = Readonly<{ release(): void }>;
|
||||
export type ModalKeyboardGuardLease = Readonly<{
|
||||
tier: "data" | "accessor" | "absent";
|
||||
release(): void;
|
||||
}>;
|
||||
type Hook = ((...args: unknown[]) => unknown) | null;
|
||||
type Entry = {
|
||||
count: number;
|
||||
@@ -10,6 +13,17 @@ type Entry = {
|
||||
set(value: unknown): void;
|
||||
};
|
||||
const entries = new WeakMap<object, Entry>();
|
||||
type AccessorEntry = {
|
||||
count: number;
|
||||
original: PropertyDescriptor;
|
||||
saved: Hook;
|
||||
wrapper: (...args: unknown[]) => unknown;
|
||||
};
|
||||
const accessorEntries = new WeakMap<object, AccessorEntry>();
|
||||
const issuedWrappers = new WeakMap<
|
||||
(...args: unknown[]) => unknown,
|
||||
{ count: number }
|
||||
>();
|
||||
const member = "maskeditor_is_opended";
|
||||
const refuse = () => seamUnavailable("modal_keyboard_guard_unavailable");
|
||||
const isHook = (value: unknown): value is Hook =>
|
||||
@@ -44,22 +58,63 @@ function owns(
|
||||
);
|
||||
}
|
||||
|
||||
function admitted(host: unknown): object | null {
|
||||
type Admission = {
|
||||
constructor: object;
|
||||
tier: ModalKeyboardGuardLease["tier"];
|
||||
descriptor: PropertyDescriptor | undefined;
|
||||
};
|
||||
|
||||
function accessorOwns(
|
||||
descriptor: PropertyDescriptor | undefined,
|
||||
original: PropertyDescriptor,
|
||||
): boolean {
|
||||
return descriptor?.get === original.get && descriptor?.set === original.set;
|
||||
}
|
||||
|
||||
function admitted(host: unknown): Admission | null {
|
||||
const constructor = constructorOf(host);
|
||||
if (constructor === null) return null;
|
||||
const descriptor = Reflect.getOwnPropertyDescriptor(constructor, member);
|
||||
const entry = entries.get(constructor);
|
||||
// IMPORTANT: keep identity after a failed restore. An inactive owned trap/value is
|
||||
// not host state: dropping it on every release re-admits frozen traps or chains wrappers.
|
||||
if (entry?.count === 0 && accessorOwns(descriptor, entry)) return null;
|
||||
if (entry !== undefined && entry.count > 0)
|
||||
return owns(descriptor, entry) && descriptor?.configurable === true
|
||||
? constructor
|
||||
? { constructor, tier: "data", descriptor }
|
||||
: null;
|
||||
return descriptor !== undefined &&
|
||||
const accessor = accessorEntries.get(constructor);
|
||||
if (accessor !== undefined && accessor.count > 0)
|
||||
return accessorOwns(descriptor, accessor.original) &&
|
||||
descriptor?.configurable === accessor.original.configurable &&
|
||||
descriptor?.enumerable === accessor.original.enumerable
|
||||
? { constructor, tier: "accessor", descriptor }
|
||||
: null;
|
||||
if (
|
||||
descriptor !== undefined &&
|
||||
"value" in descriptor &&
|
||||
isHook(descriptor.value) &&
|
||||
inactiveWrapper(descriptor.value)
|
||||
)
|
||||
return null;
|
||||
if (
|
||||
descriptor !== undefined &&
|
||||
"value" in descriptor &&
|
||||
descriptor.configurable === true &&
|
||||
descriptor.writable === true &&
|
||||
isHook(descriptor.value)
|
||||
? constructor
|
||||
: null;
|
||||
)
|
||||
return { constructor, tier: "data", descriptor };
|
||||
// IMPORTANT: the host accessor feeds the store that changeTracker reads directly.
|
||||
// Write through its setter; redefining this member would leak canvas undo/redo.
|
||||
if (
|
||||
typeof descriptor?.get === "function" &&
|
||||
typeof descriptor.set === "function"
|
||||
)
|
||||
return { constructor, tier: "accessor", descriptor };
|
||||
// The host also contains rendered aria-modal dialogs. Unknown predicates must not
|
||||
// block mounting; the independent canvas keyboard guard remains mandatory.
|
||||
return { constructor, tier: "absent", descriptor };
|
||||
}
|
||||
|
||||
/** Read-only shape admission; the returned factory re-probes the current host. */
|
||||
@@ -88,13 +143,127 @@ function restore(constructor: object, entry: Entry): void {
|
||||
}
|
||||
}
|
||||
|
||||
function noPredicate(): SeamResult<ModalKeyboardGuardLease> {
|
||||
return seamReady(Object.freeze({ tier: "absent" as const, release() {} }));
|
||||
}
|
||||
|
||||
function inactiveWrapper(value: Hook): boolean {
|
||||
return typeof value === "function" && issuedWrappers.get(value)?.count === 0;
|
||||
}
|
||||
|
||||
function retireData(constructor: object, entry: Entry): void {
|
||||
restore(constructor, entry);
|
||||
try {
|
||||
if (
|
||||
accessorOwns(Reflect.getOwnPropertyDescriptor(constructor, member), entry)
|
||||
)
|
||||
entries.set(constructor, entry);
|
||||
else entries.delete(constructor);
|
||||
} catch {
|
||||
entries.set(constructor, entry);
|
||||
}
|
||||
}
|
||||
|
||||
function acquireAccessor(
|
||||
constructor: object,
|
||||
original: PropertyDescriptor,
|
||||
): SeamResult<ModalKeyboardGuardLease> {
|
||||
let entry = accessorEntries.get(constructor);
|
||||
if (entry !== undefined && entry.count > 0) {
|
||||
if (Reflect.get(constructor, member) !== entry.wrapper) return refuse();
|
||||
entry.count += 1;
|
||||
} else {
|
||||
const saved: unknown = Reflect.get(constructor, member);
|
||||
if (!isHook(saved)) return noPredicate();
|
||||
if (inactiveWrapper(saved)) return refuse();
|
||||
const created: AccessorEntry = {
|
||||
count: 1,
|
||||
original,
|
||||
saved,
|
||||
// Delegate to the saved hook, never a later wrapper that may call us itself.
|
||||
wrapper: (...args) =>
|
||||
created.count > 0
|
||||
? true
|
||||
: saved === null
|
||||
? false
|
||||
: Reflect.apply(saved, constructor, args),
|
||||
};
|
||||
issuedWrappers.set(created.wrapper, created);
|
||||
try {
|
||||
if (
|
||||
!Reflect.set(constructor, member, created.wrapper) ||
|
||||
Reflect.get(constructor, member) !== created.wrapper
|
||||
)
|
||||
throw new TypeError(
|
||||
"Host modal predicate installation is inconsistent",
|
||||
);
|
||||
// IMPORTANT: value identity alone misses a setter/readback getter freezing or
|
||||
// replacing its own descriptor. Refuse before handing out a live lease.
|
||||
const installed = Reflect.getOwnPropertyDescriptor(constructor, member);
|
||||
if (
|
||||
!accessorOwns(installed, original) ||
|
||||
installed?.configurable !== original.configurable ||
|
||||
installed?.enumerable !== original.enumerable
|
||||
)
|
||||
throw new TypeError(
|
||||
"Host modal predicate descriptor changed during installation",
|
||||
);
|
||||
} catch {
|
||||
created.count = 0;
|
||||
try {
|
||||
if (
|
||||
accessorOwns(
|
||||
Reflect.getOwnPropertyDescriptor(constructor, member),
|
||||
original,
|
||||
)
|
||||
)
|
||||
Reflect.set(constructor, member, saved);
|
||||
} catch {
|
||||
// A throwing compatibility setter can only be restored best-effort.
|
||||
}
|
||||
return refuse();
|
||||
}
|
||||
entry = created;
|
||||
accessorEntries.set(constructor, entry);
|
||||
}
|
||||
const ownedEntry = entry;
|
||||
let released = false;
|
||||
return seamReady(
|
||||
Object.freeze({
|
||||
tier: "accessor" as const,
|
||||
release() {
|
||||
if (released) return;
|
||||
released = true;
|
||||
ownedEntry.count -= 1;
|
||||
if (ownedEntry.count !== 0) return;
|
||||
try {
|
||||
if (
|
||||
accessorOwns(
|
||||
Reflect.getOwnPropertyDescriptor(constructor, member),
|
||||
ownedEntry.original,
|
||||
) &&
|
||||
Reflect.get(constructor, member) === ownedEntry.wrapper
|
||||
)
|
||||
Reflect.set(constructor, member, ownedEntry.saved);
|
||||
} catch {
|
||||
// Deactivated handed-out wrappers stay safe even if the host cannot restore.
|
||||
}
|
||||
accessorEntries.delete(constructor);
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/** Temporarily expose the host's callable modal predicate, preserving nested consumers. */
|
||||
export function acquireModalKeyboardGuard(
|
||||
host: unknown,
|
||||
): SeamResult<ModalKeyboardGuardLease> {
|
||||
try {
|
||||
const constructor = admitted(host);
|
||||
if (constructor === null) return refuse();
|
||||
const admission = admitted(host);
|
||||
if (admission === null) return refuse();
|
||||
const { constructor, tier, descriptor } = admission;
|
||||
if (tier === "absent") return noPredicate();
|
||||
if (tier === "accessor") return acquireAccessor(constructor, descriptor!);
|
||||
let entry = entries.get(constructor);
|
||||
if (entry === undefined || entry.count === 0) {
|
||||
const original = Reflect.getOwnPropertyDescriptor(constructor, member)!;
|
||||
@@ -120,6 +289,7 @@ export function acquireModalKeyboardGuard(
|
||||
: originalHook === null
|
||||
? false
|
||||
: Reflect.apply(originalHook, constructor, args);
|
||||
issuedWrappers.set(wrapper, created);
|
||||
let installed = false;
|
||||
try {
|
||||
installed =
|
||||
@@ -135,7 +305,7 @@ export function acquireModalKeyboardGuard(
|
||||
}
|
||||
if (!installed) {
|
||||
created.count = 0;
|
||||
restore(constructor, created);
|
||||
retireData(constructor, created);
|
||||
return refuse();
|
||||
}
|
||||
entry = created;
|
||||
@@ -145,13 +315,13 @@ export function acquireModalKeyboardGuard(
|
||||
let released = false;
|
||||
return seamReady(
|
||||
Object.freeze({
|
||||
tier: "data" as const,
|
||||
release() {
|
||||
if (released) return;
|
||||
released = true;
|
||||
ownedEntry.count -= 1;
|
||||
if (ownedEntry.count !== 0) return;
|
||||
restore(constructor, ownedEntry);
|
||||
entries.delete(constructor);
|
||||
retireData(constructor, ownedEntry);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -196,13 +196,39 @@ function containsGraphCanvas(element: HTMLElement): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function splitterFor(hostOwner: HTMLElement): HTMLElement | undefined {
|
||||
// IMPORTANT: PrimeVue marks its splitter; Reka keeps only sidebar/canvas shapes. Resolving
|
||||
// solely by .p-splitter loses canvas/opposite clamps on newer hosts. Stay in the nearest
|
||||
// shared topology, excluding the document body so unrelated host panels never constrain us.
|
||||
for (
|
||||
let parent = hostOwner.parentElement;
|
||||
parent !== null && parent !== hostOwner.ownerDocument.body;
|
||||
parent = parent.parentElement
|
||||
) {
|
||||
if (
|
||||
parent.matches(splitterSelector) ||
|
||||
[...parent.children].some(
|
||||
(child) =>
|
||||
child instanceof HTMLElement &&
|
||||
!child.contains(hostOwner) &&
|
||||
containsGraphCanvas(child),
|
||||
)
|
||||
)
|
||||
return parent;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function siblingPanel(hostOwner: HTMLElement): HTMLElement | undefined {
|
||||
const splitterRoot = hostOwner.closest<HTMLElement>(splitterSelector);
|
||||
if (splitterRoot === null) return undefined;
|
||||
const splitterRoot = splitterFor(hostOwner);
|
||||
if (splitterRoot === undefined) return undefined;
|
||||
const parent = splitterRoot;
|
||||
const hostBounds = horizontalBounds(hostOwner);
|
||||
if (hostBounds === undefined) return undefined;
|
||||
const hostOnLeft = hostBounds.left <= 1;
|
||||
const canvas =
|
||||
horizontalBounds(siblingCanvas(hostOwner)) ??
|
||||
horizontalBounds(splitterRoot);
|
||||
const hostOnLeft = hostBounds.left <= (canvas?.left ?? 0) + 1;
|
||||
// The pinned host marks persistent sidebar owners explicitly; prefer that seam over the
|
||||
// generic PrimeVue panel class, whose central sibling normally contains the graph canvas.
|
||||
const ownerClass = hostOwner.classList.contains("side-bar-panel")
|
||||
@@ -239,8 +265,8 @@ function siblingPanel(hostOwner: HTMLElement): HTMLElement | undefined {
|
||||
}
|
||||
|
||||
function siblingCanvas(hostOwner: HTMLElement): HTMLElement | undefined {
|
||||
const splitterRoot = hostOwner.closest<HTMLElement>(splitterSelector);
|
||||
if (splitterRoot === null) return undefined;
|
||||
const splitterRoot = splitterFor(hostOwner);
|
||||
if (splitterRoot === undefined) return undefined;
|
||||
for (const child of splitterRoot.children) {
|
||||
if (!(child instanceof HTMLElement) || child === hostOwner) continue;
|
||||
const candidate = child.matches(graphCanvasSelector)
|
||||
@@ -270,7 +296,25 @@ function availableWidthFor(
|
||||
): number {
|
||||
if (hostOwner === undefined) return viewportWidth;
|
||||
const host = horizontalBounds(hostOwner) ?? { left: 0, right: viewportWidth };
|
||||
let canvas = horizontalBounds(siblingCanvas(hostOwner));
|
||||
const splitterRoot = splitterFor(hostOwner);
|
||||
// CRITICAL: a collapsed canvas is not an absent layout. Use its splitter surface when the
|
||||
// canvas is hidden or <=1px; a 0..viewport fallback misclassifies the left owner as right-attached
|
||||
// after shrinking from the floor, leaving a stable overflow by the toolbar width.
|
||||
let canvas =
|
||||
horizontalBounds(siblingCanvas(hostOwner)) ??
|
||||
horizontalBounds(splitterRoot);
|
||||
if (
|
||||
splitterRoot === undefined &&
|
||||
getComputedStyle(hostOwner).position !== "fixed"
|
||||
) {
|
||||
const parent = hostOwner.parentElement;
|
||||
const bounds = horizontalBounds(parent ?? undefined);
|
||||
if (bounds !== undefined && bounds.right > bounds.left)
|
||||
return Math.max(
|
||||
1,
|
||||
Math.min(viewportWidth, bounds.right) - Math.max(0, bounds.left),
|
||||
);
|
||||
}
|
||||
// IMPORTANT: a fixed owner's inline anchor excludes toolbar space when no canvas is visible.
|
||||
// Computed insets resolve `auto` to lengths; using measured width alone prevents desktop growth.
|
||||
if (
|
||||
@@ -327,6 +371,7 @@ export function createSidebarWidthController(
|
||||
const { elements, hostOwner } = targetsFor(mount);
|
||||
const related = [
|
||||
...elements,
|
||||
hostOwner?.parentElement ?? undefined,
|
||||
hostOwner === undefined ? undefined : siblingPanel(hostOwner),
|
||||
hostOwner === undefined ? undefined : siblingCanvas(hostOwner),
|
||||
];
|
||||
|
||||
@@ -440,16 +440,9 @@
|
||||
light mode. Structure comes from elevation and type, not from texture. */
|
||||
font: var(--h3-t-body);
|
||||
}
|
||||
/* the light palette activates on the HOST's own signal, not on an
|
||||
attribute nothing sets. ComfyUI 1.48.7 marks dark with `.dark-theme` on the
|
||||
root element and treats bare `:root` as light, so the trigger is "host is
|
||||
present and is not signalling dark".
|
||||
|
||||
`body.litegraph` (declared in the pinned host's index.html) is what makes the
|
||||
absence of `.dark-theme` unambiguous: without it, "no dark signal" would also
|
||||
match the offline and hermetic case, where AC--02 requires the accepted
|
||||
dark appearance. The `:not([data-theme])` guards let a harness or test force
|
||||
either palette deterministically and win over the host rule.
|
||||
/* The mounted root's host probe resolves old dark-theme and newer color-scheme
|
||||
signals. Without an unambiguous host signal the accepted hermetic dark default
|
||||
stays. The :not([data-theme]) guards preserve explicit harness overrides.
|
||||
|
||||
No host colour variable feeds a rendered colour in this file. On this pinned
|
||||
revision `--comfy-menu-bg`, `--input-text`, `--fg-color`, `--bg-color`,
|
||||
@@ -463,7 +456,7 @@
|
||||
contract in tests/m17_00Static.test.ts. It has no consumer anywhere in
|
||||
this stylesheet, so it cannot affect a rendered colour; folding it away belongs
|
||||
to whichever item owns that contract, not here. */
|
||||
:root:not([data-theme]):not(.dark-theme) body.litegraph .h3c:not([data-theme]),
|
||||
:root:not([data-theme]) .h3c[data-h3-host-theme="light"]:not([data-theme]),
|
||||
.h3c[data-theme="light"],
|
||||
:root[data-theme="light"] .h3c,
|
||||
.light-theme .h3c {
|
||||
@@ -3031,7 +3024,9 @@
|
||||
(WCAG 1.4.13) without leaving the group. */
|
||||
.h3c .h3-icon-tip {
|
||||
position: absolute;
|
||||
inset-inline: 0;
|
||||
left: 0;
|
||||
inline-size: max-content;
|
||||
max-inline-size: 20rem;
|
||||
bottom: calc(100% + 6px);
|
||||
z-index: 10;
|
||||
padding: 6px 8px;
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import {
|
||||
withCompiledPackIdentity,
|
||||
hasSameCompiledMetadata,
|
||||
} from "./support/compiledMetadataFixture";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as canvasOwnedWrite from "../src/host/canvasOwnedWrite";
|
||||
|
||||
import {
|
||||
APP_MODE_MODE_CAPABILITIES,
|
||||
@@ -1114,6 +1119,89 @@ describe("H3 App Mode host seam", () => {
|
||||
expect(host.api.queuePrompt).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("keeps base title compatibility through an adopting queue", async () => {
|
||||
const inputs = {
|
||||
task_mode: "t2va" as const,
|
||||
user_intent: "safe",
|
||||
duration_milliseconds: 8000,
|
||||
frame_count: 192,
|
||||
};
|
||||
let expectedCompiled: AppModeCompiledPrompt | undefined;
|
||||
const host = definitionsExistingHost(inputs, ({ compiled }) => {
|
||||
withCompiledPackIdentity(compiled);
|
||||
for (const value of Object.values(compiled.output)) {
|
||||
const meta = (value as Record<string, unknown>)._meta as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
meta.title = "x".repeat(300);
|
||||
}
|
||||
expectedCompiled = structuredClone(compiled);
|
||||
return compiled;
|
||||
});
|
||||
const result = await createAppModeController(host.app, host.api, {
|
||||
loadTemplate,
|
||||
loadProfile,
|
||||
createDetachedGraph: host.createDetachedGraph,
|
||||
}).start(inputs, { useExisting: true });
|
||||
|
||||
expect(result.route).toBe("existing");
|
||||
expect(host.api.queuePrompt).toHaveBeenCalledOnce();
|
||||
const queued = host.api.queuePrompt.mock.calls[0]![1];
|
||||
expect(
|
||||
expectedCompiled !== undefined &&
|
||||
hasSameCompiledMetadata(queued, expectedCompiled),
|
||||
).toBe(true);
|
||||
expect(
|
||||
expectedCompiled !== undefined &&
|
||||
fingerprint(queued.output) === fingerprint(expectedCompiled.output),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("restores an adopting graph once when compiled pack metadata is refused", async () => {
|
||||
const inputs = {
|
||||
task_mode: "t2va" as const,
|
||||
user_intent: "safe",
|
||||
duration_milliseconds: 8000,
|
||||
frame_count: 192,
|
||||
};
|
||||
const host = definitionsExistingHost(inputs, ({ compiled }) => {
|
||||
withCompiledPackIdentity(compiled);
|
||||
(compiled.output["1"] as Record<string, unknown>)._meta = {
|
||||
undisclosed: "private-value",
|
||||
};
|
||||
return compiled;
|
||||
});
|
||||
// Observe the private restoreOwnedGraph closure at its rollback effect boundary.
|
||||
const restoreOwnedGraph = vi.spyOn(canvasOwnedWrite, "restoreGraph");
|
||||
try {
|
||||
const failure = await createAppModeController(host.app, host.api, {
|
||||
loadTemplate,
|
||||
loadProfile,
|
||||
createDetachedGraph: host.createDetachedGraph,
|
||||
})
|
||||
.start(inputs, { useExisting: true })
|
||||
.then(
|
||||
() => undefined,
|
||||
(error: unknown) => error,
|
||||
);
|
||||
expect(
|
||||
failure instanceof AppModeError &&
|
||||
failure.code === "compile_failed" &&
|
||||
failure.message ===
|
||||
"compile_failed: an unrecognized compiled _meta member",
|
||||
).toBe(true);
|
||||
expect(restoreOwnedGraph).toHaveBeenCalledOnce();
|
||||
expect(host.loadGraphData).toHaveBeenCalledTimes(2);
|
||||
expect(
|
||||
JSON.stringify(host.visible()) === JSON.stringify(host.before),
|
||||
).toBe(true);
|
||||
expect(host.api.queuePrompt).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
restoreOwnedGraph.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it("restores a definitions-carrying existing graph when root compilation throws", async () => {
|
||||
const inputs = {
|
||||
task_mode: "t2va" as const,
|
||||
@@ -2031,17 +2119,18 @@ describe("H3 App Mode host seam", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("materializes in the active workflow without creating a tab", async () => {
|
||||
it("materializes host pack metadata in the active workflow without creating a tab", async () => {
|
||||
const inputs = {
|
||||
task_mode: "t2va" as const,
|
||||
user_intent: "A single canvas remains active across explicit runs.",
|
||||
duration_milliseconds: 5167,
|
||||
frame_count: 124,
|
||||
};
|
||||
const compiled = {
|
||||
const compiled = withCompiledPackIdentity({
|
||||
output: createMaterializedPrompt(inputs),
|
||||
workflow: {},
|
||||
};
|
||||
});
|
||||
const expectedCompiled = structuredClone(compiled);
|
||||
let visibleGraph: Json = { nodes: [], links: [] };
|
||||
const activeWorkflow: object = { path: "workflows/repeated-run.json" };
|
||||
const workflowStore = {
|
||||
@@ -2075,8 +2164,9 @@ describe("H3 App Mode host seam", () => {
|
||||
graph: { serialize: () => visibleGraph },
|
||||
},
|
||||
{
|
||||
queuePrompt: vi.fn(async () =>
|
||||
acceptedQueueResponse(20 + ++promptNumber),
|
||||
queuePrompt: vi.fn(
|
||||
async (_batch: number, _compiled: AppModeCompiledPrompt) =>
|
||||
acceptedQueueResponse(20 + ++promptNumber),
|
||||
),
|
||||
},
|
||||
);
|
||||
@@ -2088,6 +2178,16 @@ describe("H3 App Mode host seam", () => {
|
||||
const materialized = await controller.start(inputs);
|
||||
expect(materialized.route).toBe("new");
|
||||
expect(api.queuePrompt).toHaveBeenCalledOnce();
|
||||
expect(
|
||||
hasSameCompiledMetadata(
|
||||
api.queuePrompt.mock.calls[0]![1] as AppModeCompiledPrompt,
|
||||
expectedCompiled,
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
fingerprint(api.queuePrompt.mock.calls[0]![1].output) ===
|
||||
fingerprint(expectedCompiled.output),
|
||||
).toBe(true);
|
||||
expect(loadGraphData).toHaveBeenCalledOnce();
|
||||
expect(
|
||||
loadGraphData.mock.calls.every((call) => call[3] === activeWorkflow),
|
||||
@@ -2178,6 +2278,8 @@ describe("H3 App Mode host seam", () => {
|
||||
frame_count: 192,
|
||||
};
|
||||
const fixture = existingGraphRouteFixture(inputs);
|
||||
withCompiledPackIdentity(fixture.compiled);
|
||||
const expectedCompiled = structuredClone(fixture.compiled);
|
||||
const visibleGraph = structuredClone(fixture.workflow);
|
||||
const request = (visibleGraph.nodes as Json[]).find(
|
||||
(node) => node.type === H3_NODE_TYPES.request,
|
||||
@@ -2247,6 +2349,16 @@ describe("H3 App Mode host seam", () => {
|
||||
expect(graph.receipt.widgetCallback).not.toHaveBeenCalled();
|
||||
expect(graph.receipt.onWidgetChanged).not.toHaveBeenCalled();
|
||||
expect(api.queuePrompt).toHaveBeenCalledOnce();
|
||||
expect(
|
||||
hasSameCompiledMetadata(
|
||||
api.queuePrompt.mock.calls[0]![1] as AppModeCompiledPrompt,
|
||||
expectedCompiled,
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
fingerprint(api.queuePrompt.mock.calls[0]![1].output) ===
|
||||
fingerprint(expectedCompiled.output),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it.each(["mutate_in_place", "forward_copy"] as const)(
|
||||
@@ -3848,7 +3960,7 @@ describe("H3 App Mode host seam", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps the c44 API envelope closed while allowing _meta.title", () => {
|
||||
it("keeps the c44 API envelope closed while allowing host pack metadata", () => {
|
||||
const output = createQualifiedBasePrompt({
|
||||
task_mode: "t2va",
|
||||
user_intent: "safe",
|
||||
@@ -3857,6 +3969,16 @@ describe("H3 App Mode host seam", () => {
|
||||
}) as Record<string, Record<string, unknown>>;
|
||||
output["1"] = { ...output["1"], _meta: { title: "Request" } };
|
||||
expect(isCompatibleExistingPrompt({ output, workflow: {} })).toBe(true);
|
||||
output["1"] = {
|
||||
...output["1"],
|
||||
_meta: {
|
||||
title: "Request",
|
||||
cnr_id: "pack",
|
||||
aux_id: "owner/pack",
|
||||
ver: "1",
|
||||
},
|
||||
};
|
||||
expect(isCompatibleExistingPrompt({ output, workflow: {} })).toBe(true);
|
||||
expect(
|
||||
isCompatibleExistingPrompt({
|
||||
output: {
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import * as canvasOwnedWrite from "../src/host/canvasOwnedWrite";
|
||||
|
||||
import {
|
||||
compiledOutputNodes,
|
||||
isSafeCompiledNodeEnvelope,
|
||||
} from "../src/host/appModeContract";
|
||||
import { createAppModeController } from "../src/host/appMode";
|
||||
import { isCompatibleExistingPrompt } from "../src/host/appModeExistingRoute";
|
||||
import { isSafeCompiledMetadata } from "../src/host/compiledMetadata";
|
||||
import { createQualifiedBasePrompt } from "./support/qualifiedBasePrompt";
|
||||
import { withCompiledPackIdentity } from "./support/compiledMetadataFixture";
|
||||
import { fixtureBackedAppModeHost } from "./support/hostSeamTestDouble";
|
||||
import { loadAvailableProfile } from "./support/generationProfileFixture";
|
||||
import { loadSyntheticTemplate } from "./support/templateFixture";
|
||||
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
function compiledWithPackIdentity() {
|
||||
const output = createQualifiedBasePrompt({
|
||||
task_mode: "t2va",
|
||||
user_intent: "safe",
|
||||
duration_milliseconds: 5167,
|
||||
frame_count: 124,
|
||||
}) as Record<string, Record<string, unknown>>;
|
||||
return withCompiledPackIdentity({ output, workflow: {} });
|
||||
}
|
||||
|
||||
describe("compiled host pack metadata", () => {
|
||||
it("admits the new host shape through compiledOutputNodes", () => {
|
||||
const compiled = compiledWithPackIdentity();
|
||||
expect(compiledOutputNodes(compiled).length).toBe(
|
||||
Object.keys(compiled.output).length,
|
||||
);
|
||||
});
|
||||
|
||||
it("admits the new host shape through isCompatibleExistingPrompt", () => {
|
||||
expect(isCompatibleExistingPrompt(compiledWithPackIdentity())).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps old shapes and the exact UTF-16 boundary", () => {
|
||||
for (const _meta of [
|
||||
undefined,
|
||||
{},
|
||||
{ title: "Node" },
|
||||
{ title: "x".repeat(256) },
|
||||
{ cnr_id: "", aux_id: "", ver: "" },
|
||||
{ ver: "\u{1f600}".repeat(128) },
|
||||
]) {
|
||||
expect(
|
||||
isSafeCompiledNodeEnvelope({
|
||||
class_type: "Node",
|
||||
inputs: {},
|
||||
...(_meta === undefined ? {} : { _meta }),
|
||||
}),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
["257 units", { title: "x".repeat(257) }],
|
||||
["10000 units", { title: "x".repeat(10000) }],
|
||||
["undefined", { title: undefined }],
|
||||
] as const)("keeps base title compatibility for %s", (_label, _meta) => {
|
||||
expect(isSafeCompiledMetadata(_meta)).toBe(true);
|
||||
expect(
|
||||
isSafeCompiledNodeEnvelope({ class_type: "Node", inputs: {}, _meta }),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
const refused: ReadonlyArray<readonly [string, unknown]> = [
|
||||
["unknown", { title: "Node", undisclosed: "private-value" }],
|
||||
...["__proto__", "prototype", "constructor"].map(
|
||||
(key): readonly [string, unknown] => [
|
||||
"prototype-sensitive",
|
||||
JSON.parse(`{"${key}":"private-value"}`),
|
||||
],
|
||||
),
|
||||
["non-string title", { title: 1 }],
|
||||
...["cnr_id", "aux_id", "ver"].flatMap(
|
||||
(key): ReadonlyArray<readonly [string, unknown]> => [
|
||||
["non-string", { [key]: 1 }],
|
||||
["undefined member", { [key]: undefined }],
|
||||
["oversize", { [key]: "x".repeat(257) }],
|
||||
],
|
||||
),
|
||||
["array", []],
|
||||
["null", null],
|
||||
["scalar", "private-value"],
|
||||
] as const;
|
||||
|
||||
it.each(refused)(
|
||||
"refuses metadata class %s without revealing content",
|
||||
async (_label, _meta) => {
|
||||
// Observe the private restoreOwnedGraph closure at its rollback effect boundary.
|
||||
const restoreOwnedGraph = vi.spyOn(canvasOwnedWrite, "restoreGraph");
|
||||
const compiled = compiledWithPackIdentity();
|
||||
compiled.output["1"]!._meta = _meta;
|
||||
expect(compiledOutputNodes(compiled).length).toBe(0);
|
||||
expect(isCompatibleExistingPrompt(compiled)).toBe(false);
|
||||
const queuePrompt = vi.fn();
|
||||
let visibleGraph: unknown = { nodes: [], links: [] };
|
||||
const { app, api } = fixtureBackedAppModeHost(
|
||||
{
|
||||
loadApiJson: vi.fn(),
|
||||
loadGraphData: vi.fn((workflow: unknown) => {
|
||||
visibleGraph = structuredClone(workflow);
|
||||
}),
|
||||
graphToPrompt: vi.fn().mockResolvedValue(compiled),
|
||||
graph: { serialize: () => visibleGraph },
|
||||
},
|
||||
{ queuePrompt },
|
||||
);
|
||||
const failure = await createAppModeController(app, api, {
|
||||
loadTemplate: (name) => ({
|
||||
...loadSyntheticTemplate(name),
|
||||
id: "compiled-metadata-root",
|
||||
}),
|
||||
loadProfile: loadAvailableProfile,
|
||||
})
|
||||
.start({
|
||||
task_mode: "t2va",
|
||||
user_intent: "safe",
|
||||
duration_milliseconds: 5167,
|
||||
frame_count: 124,
|
||||
})
|
||||
.then(
|
||||
() => undefined,
|
||||
(error: unknown) => error,
|
||||
);
|
||||
expect(
|
||||
failure instanceof Error &&
|
||||
failure.message ===
|
||||
"compile_failed: an unrecognized compiled _meta member",
|
||||
).toBe(true);
|
||||
expect(queuePrompt).not.toHaveBeenCalled();
|
||||
expect(restoreOwnedGraph).toHaveBeenCalledOnce();
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps extra top-level members outside the envelope", () => {
|
||||
expect(
|
||||
isSafeCompiledNodeEnvelope({
|
||||
class_type: "Node",
|
||||
inputs: {},
|
||||
_meta: { ver: "1" },
|
||||
extra: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,13 @@
|
||||
import {
|
||||
withCompiledPackIdentity,
|
||||
hasSameCompiledMetadata,
|
||||
} from "./support/compiledMetadataFixture";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
createAppModeController,
|
||||
type AppModeInputs,
|
||||
type AppModeCompiledPrompt,
|
||||
} from "../src/host/appMode";
|
||||
import {
|
||||
admitCanvasForConnect,
|
||||
@@ -585,18 +590,26 @@ describe("App Mode's connect route", () => {
|
||||
it.each(["mutate", "clone"] as const)(
|
||||
"connects, queues once, and reports the route through a %s wrapper",
|
||||
async (wrapperMode) => {
|
||||
const delegate = vi.fn().mockResolvedValue(acceptedQueueResponse(1));
|
||||
const delegate = vi.fn(
|
||||
async (_batch: number, _compiled: AppModeCompiledPrompt) =>
|
||||
acceptedQueueResponse(1),
|
||||
);
|
||||
const host = hostOn(
|
||||
communityCanvas(),
|
||||
wrapQueuePrompt(delegate, wrapperMode),
|
||||
);
|
||||
host.app.graphToPrompt.mockImplementation(compiledFor(t2va));
|
||||
const compiled = withCompiledPackIdentity(await compiledFor(t2va)());
|
||||
const expectedCompiled = structuredClone(compiled);
|
||||
host.app.graphToPrompt.mockResolvedValue(compiled);
|
||||
const result = await createAppModeController(host.app, host.api, {
|
||||
loadTemplate,
|
||||
loadProfile,
|
||||
}).start(t2va, { connectExisting: {} });
|
||||
expect(result.route).toBe("connect");
|
||||
expect(delegate).toHaveBeenCalledTimes(1);
|
||||
expect(
|
||||
hasSameCompiledMetadata(delegate.mock.calls[0]![1], expectedCompiled),
|
||||
).toBe(true);
|
||||
expect(host.app.loadGraphData.mock.calls[0]?.[3]).toBe(
|
||||
host.workflowStore.activeWorkflow,
|
||||
);
|
||||
|
||||
@@ -98,12 +98,24 @@ export async function harnessBootDiagnostics(page: Page) {
|
||||
};
|
||||
}
|
||||
|
||||
test.afterEach(async ({ page }, info) => {
|
||||
if (info.status === info.expectedStatus) return;
|
||||
const facts = await harnessBootDiagnostics(page);
|
||||
if (!facts) return;
|
||||
await info.attach("harness-boot-diagnostics", {
|
||||
contentType: "application/json",
|
||||
body: Buffer.from(JSON.stringify(facts)),
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Attaches the boot facts to the running test. `openIntegratedShell` calls it where a boot
|
||||
* failure is caught, before rethrowing. It never throws.
|
||||
*
|
||||
* IMPORTANT: do not turn this back into a `test.afterEach` at the top level of this module.
|
||||
* Playwright adds a hook to the spec file that is loading when the call runs, and Node evaluates
|
||||
* this shared module once per worker, so only the first spec file loaded in each worker had the
|
||||
* hook. Every other spec file's failure was reported with no diagnostic at all.
|
||||
*/
|
||||
export async function attachHarnessBootDiagnostics(page: Page): Promise<void> {
|
||||
try {
|
||||
const facts = await harnessBootDiagnostics(page);
|
||||
if (!facts) return;
|
||||
await test.info().attach("harness-boot-diagnostics", {
|
||||
contentType: "application/json",
|
||||
body: Buffer.from(JSON.stringify(facts)),
|
||||
});
|
||||
} catch {
|
||||
// A diagnostic must never replace the failure it describes.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
import { test, type Page, type Request } from "@playwright/test";
|
||||
|
||||
import { nleCopy } from "../../../src/components/nle/nleCopy";
|
||||
|
||||
/**
|
||||
* Closed facts about the integrated shell's open, attached when the Play wait fails.
|
||||
*
|
||||
* The hermetic CI profile retains no trace (traces disclose absolute source paths), so this
|
||||
* attachment is the only record of which state the monitor stopped in. Every value is a fixed
|
||||
* enum, a code token, a boolean or a bounded number. No URL, query, body, console text or copy
|
||||
* text leaves the page, and `scripts/browser_ci_evidence.py` (`open_diagnostic`) refuses any other
|
||||
* shape. Change both together.
|
||||
*/
|
||||
export const OPEN_DIAGNOSTICS_NAME = "integrated-shell-open-diagnostics";
|
||||
|
||||
const REQUEST_CAP = 64;
|
||||
const VIDEO_CAP = 8;
|
||||
const OVERLAY_CAP = 4;
|
||||
const COLLECT_TIMEOUT_MS = 2_000;
|
||||
const TOKEN = /^[a-z][a-z0-9_-]{0,47}$/;
|
||||
|
||||
export type MonitorState =
|
||||
| "closed"
|
||||
| "opening"
|
||||
| "paused"
|
||||
| "playing"
|
||||
| "closing"
|
||||
| "blocked"
|
||||
| "cleanup_pending"
|
||||
| "fallback"
|
||||
| "absent"
|
||||
| "unknown";
|
||||
export type MonitorBlocker =
|
||||
| "source_unavailable"
|
||||
| "canvas_unavailable"
|
||||
| "invalid_contract"
|
||||
| "resource_limit"
|
||||
| "unknown";
|
||||
export type RequestLabel =
|
||||
| "media:video"
|
||||
| "media:image"
|
||||
| "media:font"
|
||||
| "media:audio"
|
||||
| "media:other"
|
||||
| "fixture:bootstrap"
|
||||
| "fixture:transaction";
|
||||
export type RequestRow = {
|
||||
label: RequestLabel;
|
||||
startMs: number;
|
||||
endMs: number | null;
|
||||
status: number | null;
|
||||
/** `aborted` is the page cancelling its own request; `failed` is any other network failure. */
|
||||
outcome: "ok" | "failed" | "aborted" | "pending";
|
||||
};
|
||||
export type VideoRow = {
|
||||
readyState: number;
|
||||
networkState: number;
|
||||
seeking: boolean;
|
||||
paused: boolean;
|
||||
currentTimeMs: number;
|
||||
errorCode: number;
|
||||
};
|
||||
export type OpenDiagnostics = {
|
||||
elapsedMs: number;
|
||||
monitor: MonitorState;
|
||||
blocker: MonitorBlocker | null;
|
||||
/** The pre-composition fallback region's code; `monitor` is then `fallback`. */
|
||||
fallback: string | null;
|
||||
overlays: string[];
|
||||
playDisabled: boolean | null;
|
||||
presentedFrame: boolean;
|
||||
timelineReady: boolean;
|
||||
audioState: string | null;
|
||||
audioReason: string | null;
|
||||
surface: string | null;
|
||||
ownership: {
|
||||
leaseOpens: number;
|
||||
sourceAcquired: number;
|
||||
sourceLive: number;
|
||||
acquisitionAttempts: number;
|
||||
acquisitionsInFlight: number;
|
||||
videoElements: number;
|
||||
} | null;
|
||||
preparation: {
|
||||
attempts: number;
|
||||
inFlight: number;
|
||||
aborted: number;
|
||||
released: number;
|
||||
} | null;
|
||||
videos: VideoRow[];
|
||||
requests: RequestRow[];
|
||||
requestsOmitted: number;
|
||||
pageErrors: number;
|
||||
consoleErrors: number;
|
||||
consoleWarnings: number;
|
||||
};
|
||||
|
||||
export type ShellOpenObserver = Readonly<{
|
||||
/** Called immediately before the open gesture; request and elapsed times are relative to it. */
|
||||
markOpen(): void;
|
||||
collect(page: Page): Promise<OpenDiagnostics>;
|
||||
}>;
|
||||
|
||||
function requestLabel(url: string): RequestLabel | null {
|
||||
const path = new URL(url).pathname;
|
||||
if (path.startsWith("/nle-media/")) {
|
||||
const kind = path.slice("/nle-media/".length);
|
||||
return kind === "video" ||
|
||||
kind === "image" ||
|
||||
kind === "font" ||
|
||||
kind === "audio"
|
||||
? `media:${kind}`
|
||||
: "media:other";
|
||||
}
|
||||
if (path.startsWith("/__nle_fixture/"))
|
||||
return path === "/__nle_fixture/bootstrap"
|
||||
? "fixture:bootstrap"
|
||||
: "fixture:transaction";
|
||||
return null;
|
||||
}
|
||||
|
||||
const count = (value: unknown): number =>
|
||||
typeof value === "number" && Number.isSafeInteger(value) && value >= 0
|
||||
? Math.min(value, 1_000_000)
|
||||
: 0;
|
||||
const ms = (value: number): number => Math.round(value * 10) / 10;
|
||||
const token = (value: unknown): string | null =>
|
||||
value === null || value === undefined
|
||||
? null
|
||||
: typeof value === "string" && TOKEN.test(value)
|
||||
? value
|
||||
: "unrecognized";
|
||||
|
||||
/**
|
||||
* Maps the monitor chip's sentence back to the status it was rendered from, through the product's
|
||||
* own English copy table, so the attachment carries the state and never the sentence.
|
||||
*/
|
||||
export function monitorStateFromText(
|
||||
text: string | null,
|
||||
): Readonly<{ monitor: MonitorState; blocker: MonitorBlocker | null }> {
|
||||
if (text === null) return { monitor: "absent", blocker: null };
|
||||
const status = nleCopy("en").monitor.status;
|
||||
for (const state of [
|
||||
"closed",
|
||||
"opening",
|
||||
"paused",
|
||||
"playing",
|
||||
"closing",
|
||||
"cleanup_pending",
|
||||
] as const)
|
||||
if (text === status[state]) return { monitor: state, blocker: null };
|
||||
const [head, tail] = status.blocked.split("{reason}");
|
||||
if (text.startsWith(head) && text.endsWith(tail)) {
|
||||
const reason = text.slice(head.length, text.length - tail.length);
|
||||
const blockers = nleCopy("en").monitor.blocker;
|
||||
for (const key of [
|
||||
"source_unavailable",
|
||||
"canvas_unavailable",
|
||||
"invalid_contract",
|
||||
"resource_limit",
|
||||
] as const)
|
||||
if (reason === blockers[key]) return { monitor: "blocked", blocker: key };
|
||||
return { monitor: "blocked", blocker: "unknown" };
|
||||
}
|
||||
return { monitor: "unknown", blocker: null };
|
||||
}
|
||||
|
||||
type PageFacts = {
|
||||
monitorText: string | null;
|
||||
fallback: string | null;
|
||||
overlays: string[];
|
||||
playDisabled: boolean | null;
|
||||
presentedFrame: boolean;
|
||||
timelineReady: boolean;
|
||||
audioState: string | null;
|
||||
audioReason: string | null;
|
||||
surface: string | null;
|
||||
ownership: Record<string, unknown> | null;
|
||||
preparation: Record<string, unknown> | null;
|
||||
videos: VideoRow[];
|
||||
};
|
||||
|
||||
async function pageFacts(page: Page): Promise<PageFacts> {
|
||||
return page.evaluate(
|
||||
({ overlayCap, videoCap }) => {
|
||||
const monitor = document.querySelector('[data-h3-nle-status="monitor"]');
|
||||
const audio = document.querySelector('[data-h3-nle-status="audio"]');
|
||||
const play = document.querySelector(
|
||||
'[data-h3-nle-control="transport.play"]',
|
||||
) as HTMLButtonElement | null;
|
||||
const overlays = [...document.querySelectorAll("[data-h3-nle-overlay]")]
|
||||
.map((node) => node.getAttribute("data-h3-nle-overlay") ?? "")
|
||||
.slice(0, overlayCap);
|
||||
let snapshot: Record<string, unknown> | null = null;
|
||||
try {
|
||||
const harness = (
|
||||
window as unknown as {
|
||||
nleShellHarness?: { snapshot(): Record<string, unknown> };
|
||||
}
|
||||
).nleShellHarness;
|
||||
snapshot = harness?.snapshot() ?? null;
|
||||
} catch {
|
||||
snapshot = null;
|
||||
}
|
||||
const debug = (
|
||||
window as unknown as {
|
||||
__nleMediaDebug?: {
|
||||
videoElementsByAsset: Map<string, HTMLVideoElement>;
|
||||
videoElementsByClip: Map<string, HTMLVideoElement>;
|
||||
};
|
||||
}
|
||||
).__nleMediaDebug;
|
||||
const elements = debug
|
||||
? [
|
||||
...new Set([
|
||||
...debug.videoElementsByClip.values(),
|
||||
...debug.videoElementsByAsset.values(),
|
||||
]),
|
||||
]
|
||||
: [];
|
||||
return {
|
||||
monitorText: monitor?.textContent ?? null,
|
||||
// The monitor's fallback region carries the same status hook as the chip, before the
|
||||
// composition mounts; its code says which region it is.
|
||||
fallback: monitor?.getAttribute("data-h3-nle-fallback") ?? null,
|
||||
overlays,
|
||||
playDisabled: play === null ? null : play.disabled,
|
||||
presentedFrame:
|
||||
document
|
||||
.querySelector('canvas[data-h3-nle-canvas="composition"]')
|
||||
?.hasAttribute("data-h3-nle-presented-frame") ?? false,
|
||||
timelineReady:
|
||||
document
|
||||
.querySelector('[data-h3-nle-status="timeline"]')
|
||||
?.getAttribute("data-h3-nle-authoring") === "ready",
|
||||
audioState: audio?.getAttribute("data-h3-nle-audio-state") ?? null,
|
||||
audioReason: audio?.getAttribute("data-h3-nle-audio-reason") ?? null,
|
||||
surface:
|
||||
typeof snapshot?.surfaceStatus === "string"
|
||||
? snapshot.surfaceStatus
|
||||
: null,
|
||||
ownership:
|
||||
(snapshot?.mediaOwnership as Record<string, unknown> | undefined) ??
|
||||
null,
|
||||
preparation:
|
||||
(snapshot?.mediaPreparation as Record<string, unknown> | undefined) ??
|
||||
null,
|
||||
videos: elements.slice(0, videoCap).map((element) => ({
|
||||
readyState: element.readyState,
|
||||
networkState: element.networkState,
|
||||
seeking: element.seeking,
|
||||
paused: element.paused,
|
||||
currentTimeMs: Number.isFinite(element.currentTime)
|
||||
? Math.round(element.currentTime * 1000)
|
||||
: 0,
|
||||
errorCode: element.error?.code ?? 0,
|
||||
})),
|
||||
};
|
||||
},
|
||||
{ overlayCap: OVERLAY_CAP, videoCap: VIDEO_CAP },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Observes the open's requests and console from before navigation. Install it before `goto`.
|
||||
*/
|
||||
export function observeShellOpen(page: Page): ShellOpenObserver {
|
||||
let openedAt: number | null = null;
|
||||
const began = performance.now();
|
||||
const origin = () => openedAt ?? began;
|
||||
const rows = new Map<Request, RequestRow>();
|
||||
let omitted = 0;
|
||||
let pageErrors = 0;
|
||||
let consoleErrors = 0;
|
||||
let consoleWarnings = 0;
|
||||
page.on("request", (request) => {
|
||||
const label = requestLabel(request.url());
|
||||
if (label === null) return;
|
||||
if (rows.size >= REQUEST_CAP) {
|
||||
omitted += 1;
|
||||
return;
|
||||
}
|
||||
rows.set(request, {
|
||||
label,
|
||||
startMs: ms(performance.now() - origin()),
|
||||
endMs: null,
|
||||
status: null,
|
||||
outcome: "pending",
|
||||
});
|
||||
});
|
||||
page.on("requestfinished", (request) => {
|
||||
const row = rows.get(request);
|
||||
if (row === undefined) return;
|
||||
row.endMs = ms(performance.now() - origin());
|
||||
row.outcome = "ok";
|
||||
});
|
||||
page.on("requestfailed", (request) => {
|
||||
const row = rows.get(request);
|
||||
if (row === undefined) return;
|
||||
row.endMs = ms(performance.now() - origin());
|
||||
// Only the closed class is kept, never the browser's error text.
|
||||
row.outcome = request.failure()?.errorText.includes("ERR_ABORTED")
|
||||
? "aborted"
|
||||
: "failed";
|
||||
});
|
||||
page.on("response", (response) => {
|
||||
const row = rows.get(response.request());
|
||||
if (row !== undefined) row.status = response.status();
|
||||
});
|
||||
page.on("pageerror", () => {
|
||||
pageErrors = Math.min(1_000_000, pageErrors + 1);
|
||||
});
|
||||
page.on("console", (message) => {
|
||||
if (message.type() === "error")
|
||||
consoleErrors = Math.min(1_000_000, consoleErrors + 1);
|
||||
else if (message.type() === "warning")
|
||||
consoleWarnings = Math.min(1_000_000, consoleWarnings + 1);
|
||||
});
|
||||
return {
|
||||
markOpen() {
|
||||
if (openedAt !== null) return;
|
||||
// Times recorded before the gesture are rebased, so every row shares the gesture's origin.
|
||||
const now = performance.now();
|
||||
for (const row of rows.values()) {
|
||||
row.startMs = ms(row.startMs - (now - began));
|
||||
if (row.endMs !== null) row.endMs = ms(row.endMs - (now - began));
|
||||
}
|
||||
openedAt = now;
|
||||
},
|
||||
async collect(target) {
|
||||
const facts = await pageFacts(target);
|
||||
const { monitor, blocker } =
|
||||
facts.fallback === null
|
||||
? monitorStateFromText(facts.monitorText)
|
||||
: { monitor: "fallback" as const, blocker: null };
|
||||
const own = facts.ownership;
|
||||
const prep = facts.preparation;
|
||||
return {
|
||||
elapsedMs: ms(performance.now() - origin()),
|
||||
monitor,
|
||||
blocker,
|
||||
fallback: token(facts.fallback),
|
||||
overlays: facts.overlays.map((value) => token(value) ?? "unrecognized"),
|
||||
playDisabled: facts.playDisabled,
|
||||
presentedFrame: facts.presentedFrame,
|
||||
timelineReady: facts.timelineReady,
|
||||
audioState: token(facts.audioState),
|
||||
audioReason: token(facts.audioReason),
|
||||
surface: token(facts.surface),
|
||||
ownership:
|
||||
own === null
|
||||
? null
|
||||
: {
|
||||
leaseOpens: count(own.leaseOpens),
|
||||
sourceAcquired: count(own.sourceAcquired),
|
||||
sourceLive: count(own.sourceLive),
|
||||
acquisitionAttempts: count(own.acquisitionAttempts),
|
||||
acquisitionsInFlight: count(own.acquisitionsInFlight),
|
||||
videoElements: count(own.videoElements),
|
||||
},
|
||||
preparation:
|
||||
prep === null
|
||||
? null
|
||||
: {
|
||||
attempts: count(prep.attempts),
|
||||
inFlight: count(prep.inFlight),
|
||||
aborted: count(prep.aborted),
|
||||
released: count(prep.released),
|
||||
},
|
||||
videos: facts.videos.map((video) => ({
|
||||
readyState: count(video.readyState),
|
||||
networkState: count(video.networkState),
|
||||
seeking: video.seeking === true,
|
||||
paused: video.paused === true,
|
||||
currentTimeMs: count(video.currentTimeMs),
|
||||
errorCode: count(video.errorCode),
|
||||
})),
|
||||
requests: [...rows.values()].map((row) => ({ ...row })),
|
||||
requestsOmitted: omitted,
|
||||
pageErrors,
|
||||
consoleErrors,
|
||||
consoleWarnings,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the open diagnostics to the running test. It never throws and never waits longer than
|
||||
* a short bound, so the caller can rethrow the original failure unchanged.
|
||||
*
|
||||
* IMPORTANT: call this where the failure is caught, as `openIntegratedShell` does. Do not move it
|
||||
* into a `test.afterEach` registered at the top level of a shared helper: Playwright adds such a
|
||||
* hook only to the spec file that is loading when the call runs, and Node evaluates a shared
|
||||
* module once per worker, so every later spec file in that worker would silently lose it. That is
|
||||
* exactly how a Hosted failure of this wait once kept no diagnostic at all.
|
||||
*/
|
||||
export async function attachOpenDiagnostics(
|
||||
page: Page,
|
||||
observer: ShellOpenObserver,
|
||||
): Promise<void> {
|
||||
try {
|
||||
const facts = await Promise.race([
|
||||
observer.collect(page),
|
||||
new Promise<null>((resolve) =>
|
||||
setTimeout(() => resolve(null), COLLECT_TIMEOUT_MS).unref(),
|
||||
),
|
||||
]);
|
||||
if (facts === null) return;
|
||||
await test.info().attach(OPEN_DIAGNOSTICS_NAME, {
|
||||
contentType: "application/json",
|
||||
body: Buffer.from(JSON.stringify(facts)),
|
||||
});
|
||||
} catch {
|
||||
// A diagnostic must never replace the failure it describes.
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,15 @@ import { createInterface } from "node:readline";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { join } from "node:path";
|
||||
import { fixturePython } from "../../../e2e/fixturePython";
|
||||
import { observeHarnessBoot, requireHarnessBoot } from "./harnessBoot";
|
||||
import {
|
||||
attachHarnessBootDiagnostics,
|
||||
observeHarnessBoot,
|
||||
requireHarnessBoot,
|
||||
} from "./harnessBoot";
|
||||
import {
|
||||
attachOpenDiagnostics,
|
||||
observeShellOpen,
|
||||
} from "./integratedShellDiagnostics";
|
||||
|
||||
import {
|
||||
routeGenericFixtureMedia,
|
||||
@@ -243,6 +251,11 @@ export type IntegratedShellOptions = Readonly<{
|
||||
* and runs `beforeOpen` without opening the editor or waiting for its transport.
|
||||
*/
|
||||
expandOverlay?: boolean;
|
||||
/**
|
||||
* Bounds the wait for an enabled Play after the open gesture. It defaults to the configured
|
||||
* expect timeout; a journey proving the open-failure diagnostic sets a short one.
|
||||
*/
|
||||
openTimeoutMs?: number;
|
||||
}>;
|
||||
|
||||
type Oracle = Readonly<{
|
||||
@@ -418,6 +431,7 @@ export async function openIntegratedShell(
|
||||
options: IntegratedShellOptions = {},
|
||||
): Promise<ShellOracle> {
|
||||
observeHarnessBoot(page);
|
||||
const opening = observeShellOpen(page);
|
||||
const root = fileURLToPath(new URL("../../../../", import.meta.url));
|
||||
if (
|
||||
shape === "reference" ||
|
||||
@@ -491,18 +505,36 @@ export async function openIntegratedShell(
|
||||
for (const [key, value] of Object.entries(options.extraParams ?? {}))
|
||||
params.set(key, value);
|
||||
await page.goto(`/nleShell.html?${params.toString()}`);
|
||||
await requireHarnessBoot(page);
|
||||
// IMPORTANT: the diagnostics are attached here, where each failure is caught, and never by a
|
||||
// module-level hook in a shared helper (see `attachOpenDiagnostics`). The hermetic CI profile
|
||||
// keeps no trace, so without them a failed open says only "Play was disabled".
|
||||
try {
|
||||
await requireHarnessBoot(page);
|
||||
} catch (error) {
|
||||
await attachHarnessBootDiagnostics(page);
|
||||
throw error;
|
||||
}
|
||||
await options.beforeOpen?.(page);
|
||||
if (options.expandOverlay !== false) {
|
||||
opening.markOpen();
|
||||
if (options.open) await options.open(page);
|
||||
else
|
||||
await page
|
||||
.locator("#root")
|
||||
.getByRole("button", { name: "Open full editor" })
|
||||
.click();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Play", exact: true }),
|
||||
).toBeEnabled();
|
||||
try {
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Play", exact: true }),
|
||||
).toBeEnabled(
|
||||
options.openTimeoutMs === undefined
|
||||
? undefined
|
||||
: { timeout: options.openTimeoutMs },
|
||||
);
|
||||
} catch (error) {
|
||||
await attachOpenDiagnostics(page, opening);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return {
|
||||
transactions,
|
||||
|
||||
@@ -585,14 +585,16 @@ export function installM2508ManagedExecutionProjection(
|
||||
: (structuredClone(actual) as Record<string, unknown>);
|
||||
if (normalized !== null && "_meta" in normalized) {
|
||||
const meta = normalized._meta;
|
||||
const metaKeys =
|
||||
meta !== null && typeof meta === "object" && !Array.isArray(meta)
|
||||
? Object.keys(meta as Record<string, unknown>).sort()
|
||||
: [];
|
||||
if (
|
||||
JSON.stringify(metaKeys) !== JSON.stringify(["title"]) ||
|
||||
typeof (meta as { title?: unknown }).title !== "string" ||
|
||||
(meta as { title: string }).title.length > 256
|
||||
meta === null ||
|
||||
typeof meta !== "object" ||
|
||||
Array.isArray(meta) ||
|
||||
Object.entries(meta).some(
|
||||
([key, value]) =>
|
||||
!["title", "cnr_id", "aux_id", "ver"].includes(key) ||
|
||||
typeof value !== "string" ||
|
||||
value.length > 256,
|
||||
)
|
||||
)
|
||||
throw new Error(
|
||||
"M25-08 model-free execution projection is not exact",
|
||||
@@ -600,7 +602,7 @@ export function installM2508ManagedExecutionProjection(
|
||||
delete normalized._meta;
|
||||
}
|
||||
// CRITICAL: class/type equality is not an execution allowlist. Compare the complete bounded
|
||||
// JSON node after removing only ComfyUI's closed title metadata, so a same-class locator or
|
||||
// JSON node after removing only ComfyUI's closed presentation/pack metadata, so a same-class locator or
|
||||
// link rewrite cannot cross the pre-fingerprint seam.
|
||||
if (
|
||||
normalized === null ||
|
||||
|
||||
@@ -101,26 +101,76 @@ test("unhandled editor keys stay inside the portal and host keys resume after cl
|
||||
expect(oracle.transactions).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("older callable undo capture is masked before editor undo and resumes after close", async ({
|
||||
page,
|
||||
}) => {
|
||||
await openIntegratedShell(page, "smoke", {
|
||||
beforeOpen: (target) => installHostCapture(target, false),
|
||||
});
|
||||
const clip = page.locator(
|
||||
'[data-h3-nle-clip="clip-0"] [data-h3-nle-control="selection.set"]',
|
||||
for (const shape of ["data", "accessor", "absent"] as const)
|
||||
test(
|
||||
shape === "data"
|
||||
? "older callable undo capture is masked before editor undo and resumes after close"
|
||||
: `${shape} predicate contains editor undo and resumes after close`,
|
||||
async ({ page }) => {
|
||||
await openIntegratedShell(page, "smoke", {
|
||||
beforeOpen: async (target) => {
|
||||
await target.route("**/scripts/app.js", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "text/javascript",
|
||||
body: 'export { app } from "/hostKeyboard.ts";',
|
||||
}),
|
||||
);
|
||||
await target.route("**/scripts/api.js", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "text/javascript",
|
||||
body: 'export { api } from "/hostKeyboard.ts";',
|
||||
}),
|
||||
);
|
||||
await target.evaluate(async (shape) => {
|
||||
const modulePath = "/hostKeyboard.ts";
|
||||
const fixture = (await import(
|
||||
/* @vite-ignore */ modulePath
|
||||
)) as typeof import("../../../e2e/hostKeyboard");
|
||||
fixture.configureHostModalPredicate(shape);
|
||||
}, shape);
|
||||
const probe = await target.evaluate(observeFrontendHostSeamsInPage);
|
||||
expect(probe.modalKeyboardTier).toBe(shape);
|
||||
expect(
|
||||
probe.observations.find(
|
||||
(row) => row.seam_id === "frontend.app.modal_keyboard_guard",
|
||||
)?.readiness_state,
|
||||
).toBe("ready");
|
||||
await installHostCapture(target, false);
|
||||
},
|
||||
});
|
||||
const containment = await page.evaluate(async () => {
|
||||
const modulePath = "/hostKeyboard.ts";
|
||||
const fixture = (await import(
|
||||
/* @vite-ignore */ modulePath
|
||||
)) as typeof import("../../../e2e/hostKeyboard");
|
||||
return {
|
||||
predicate: fixture.hostModalPredicateActive(),
|
||||
modal: fixture.hostAriaModalOpen(),
|
||||
};
|
||||
});
|
||||
expect(containment).toEqual({
|
||||
predicate: shape !== "absent",
|
||||
modal: true,
|
||||
});
|
||||
const clip = page.locator(
|
||||
'[data-h3-nle-clip="clip-0"] [data-h3-nle-control="selection.set"]',
|
||||
);
|
||||
await clip.click();
|
||||
await expect
|
||||
.poll(async () => (await shellSnapshot(page)).receipts)
|
||||
.toBe(1);
|
||||
await page.keyboard.press("Control+z");
|
||||
expect((await hostWitness(page)).undoActions).toBe(0);
|
||||
expect((await hostWitness(page)).undoCapture).toBe(1);
|
||||
await expect
|
||||
.poll(async () => (await shellSnapshot(page)).receipts)
|
||||
.toBe(2);
|
||||
await page.locator('[data-h3-nle-action="close"]').click();
|
||||
await expect(page.locator(shellSurface)).toHaveCount(0);
|
||||
await page.keyboard.press("Control+z");
|
||||
expect((await hostWitness(page)).undoActions).toBe(1);
|
||||
},
|
||||
);
|
||||
await clip.click();
|
||||
await expect.poll(async () => (await shellSnapshot(page)).receipts).toBe(1);
|
||||
await page.keyboard.press("Control+z");
|
||||
expect((await hostWitness(page)).undoActions).toBe(0);
|
||||
expect((await hostWitness(page)).undoCapture).toBe(1);
|
||||
await expect.poll(async () => (await shellSnapshot(page)).receipts).toBe(2);
|
||||
await page.locator('[data-h3-nle-action="close"]').click();
|
||||
await expect(page.locator(shellSurface)).toHaveCount(0);
|
||||
await page.keyboard.press("Control+z");
|
||||
expect((await hostWitness(page)).undoActions).toBe(1);
|
||||
});
|
||||
|
||||
test("canonical ghost Delete and keyup stay suspended until the editor closes", async ({
|
||||
page,
|
||||
|
||||
@@ -35,10 +35,22 @@ for (const failure of ["module404", "evaluation"] as const) {
|
||||
).__h3HarnessBoot,
|
||||
);
|
||||
expect(JSON.stringify(boot)).not.toContain("private-message");
|
||||
await info.attach("harness-boot-diagnostics", {
|
||||
contentType: "application/json",
|
||||
body: Buffer.from(JSON.stringify(await harnessBootDiagnostics(page))),
|
||||
});
|
||||
// The helper attaches the boot facts itself, where it catches the boot failure.
|
||||
const attached = info.attachments.filter(
|
||||
(item) => item.name === "harness-boot-diagnostics",
|
||||
);
|
||||
expect(attached).toHaveLength(1);
|
||||
const facts = JSON.parse(attached[0].body!.toString()) as {
|
||||
phase: string;
|
||||
events: { kind: string }[];
|
||||
};
|
||||
expect(facts.phase).toBe(
|
||||
(await harnessBootDiagnostics(page))?.phase ?? "missing",
|
||||
);
|
||||
expect(facts.events[0]?.kind).toBe(
|
||||
failure === "module404" ? "module-error" : "window-error",
|
||||
);
|
||||
expect(JSON.stringify(facts)).not.toContain("private-message");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -124,13 +124,17 @@ async function prepare(page: Page, mode: "ref2va" | "fl2va") {
|
||||
);
|
||||
const nodes = app.graph.serialize().nodes;
|
||||
return {
|
||||
modal:
|
||||
modal?.configurable === true &&
|
||||
(("value" in modal &&
|
||||
modal.writable === true &&
|
||||
(modal.value === null || typeof modal.value === "function")) ||
|
||||
(typeof modal.get === "function" &&
|
||||
typeof modal.set === "function")),
|
||||
modalTier:
|
||||
modal !== undefined &&
|
||||
"value" in modal &&
|
||||
modal.configurable === true &&
|
||||
modal.writable === true &&
|
||||
(modal.value === null || typeof modal.value === "function")
|
||||
? "data"
|
||||
: typeof modal?.get === "function" &&
|
||||
typeof modal.set === "function"
|
||||
? "accessor"
|
||||
: "absent",
|
||||
canvas:
|
||||
canvas?.canvas instanceof HTMLCanvasElement &&
|
||||
canvas.canvas.ownerDocument === document &&
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
import { expect, test, type Locator, type Page } from "@playwright/test";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { openIntegratedShell } from "../helpers/nleShell";
|
||||
import { sidebarCopy } from "../../../src/i18n/catalog";
|
||||
|
||||
const dark = "#0d0f13";
|
||||
const light = "#eceff4";
|
||||
async function palette(page: Page): Promise<string> {
|
||||
return page
|
||||
.locator(".h3c")
|
||||
.evaluate((node) =>
|
||||
getComputedStyle(node).getPropertyValue("--h3-canvas").trim(),
|
||||
);
|
||||
}
|
||||
async function frame(page: Page): Promise<void> {
|
||||
await page.evaluate(
|
||||
() =>
|
||||
new Promise<void>((resolve) => requestAnimationFrame(() => resolve())),
|
||||
);
|
||||
}
|
||||
|
||||
test("new host dark theme uses color-scheme [theme-red]", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await page.goto("/hostAppearance.html?scheme=dark");
|
||||
await expect(page.locator(".h3c")).toBeVisible();
|
||||
await page
|
||||
.locator(".h3c")
|
||||
.screenshot({ path: info.outputPath("host-theme.png") });
|
||||
expect(await palette(page)).toBe(dark);
|
||||
});
|
||||
|
||||
for (const [name, query, expected] of [
|
||||
["new light", "scheme=light", light],
|
||||
["old dark", "darkClass=1", dark],
|
||||
["old light", "", light],
|
||||
["class beats scheme", "darkClass=1&scheme=light", dark],
|
||||
["hermetic", "host=none", dark],
|
||||
["hermetic ambiguous scheme", "host=none&scheme=light%20dark", dark],
|
||||
] as const) {
|
||||
test(`theme precedence: ${name}`, async ({ page }) => {
|
||||
await page.goto(`/hostAppearance.html?${query}`);
|
||||
await expect(page.locator(".h3c")).toBeVisible();
|
||||
expect(await palette(page)).toBe(expected);
|
||||
});
|
||||
}
|
||||
|
||||
test("host switches by the next frame and explicit harness overrides win", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/hostAppearance.html?scheme=dark");
|
||||
await expect(page.locator(".h3c")).toBeVisible();
|
||||
for (const [signal, expected] of [
|
||||
["light", light],
|
||||
["dark", dark],
|
||||
["class", dark],
|
||||
["old-light", light],
|
||||
] as const) {
|
||||
await page.evaluate((value) => {
|
||||
const html = document.documentElement;
|
||||
html.classList.toggle("dark-theme", value === "class");
|
||||
html.style.colorScheme =
|
||||
value === "class" || value === "old-light" ? "" : value;
|
||||
}, signal);
|
||||
await frame(page);
|
||||
expect(await palette(page)).toBe(expected);
|
||||
}
|
||||
for (const [target, theme, expected] of [
|
||||
["html", "dark", dark],
|
||||
[".h3c", "dark", dark],
|
||||
["html", "light", light],
|
||||
[".h3c", "light", light],
|
||||
] as const) {
|
||||
await page.evaluate(
|
||||
({ target, theme }) => {
|
||||
document.documentElement.removeAttribute("data-theme");
|
||||
document.querySelector(".h3c")!.removeAttribute("data-theme");
|
||||
document.documentElement.style.colorScheme =
|
||||
theme === "light" ? "dark" : "light";
|
||||
document.querySelector(target)!.setAttribute("data-theme", theme);
|
||||
},
|
||||
{ target, theme },
|
||||
);
|
||||
await frame(page);
|
||||
expect(await palette(page)).toBe(expected);
|
||||
}
|
||||
await page.evaluate(() => {
|
||||
document.documentElement.removeAttribute("data-theme");
|
||||
document.querySelector(".h3c")!.removeAttribute("data-theme");
|
||||
document.documentElement.style.colorScheme = "dark";
|
||||
document.body.classList.add("light-theme");
|
||||
});
|
||||
await frame(page);
|
||||
expect(await palette(page)).toBe(light);
|
||||
});
|
||||
|
||||
for (const shape of ["reka", "prime"] as const) {
|
||||
test(`${shape} clamps stale width to canvas, opposite panel and viewport [width-red]`, async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await page.goto(`/hostAppearance.html?shape=${shape}`);
|
||||
await expect(page.locator(".h3c")).toBeVisible();
|
||||
await page
|
||||
.locator("#surface")
|
||||
.screenshot({ path: info.outputPath(`${shape}-width.png`) });
|
||||
expect(
|
||||
await page
|
||||
.locator("#panel")
|
||||
.evaluate((node) => node.getBoundingClientRect().width),
|
||||
).toBe(712);
|
||||
await page.setViewportSize({ width: 700, height: 900 });
|
||||
await frame(page);
|
||||
expect(
|
||||
await page
|
||||
.locator("#panel")
|
||||
.evaluate((node) => node.getBoundingClientRect().width),
|
||||
).toBe(642);
|
||||
expect(
|
||||
await page
|
||||
.locator("#root")
|
||||
.evaluate((node) => getComputedStyle(node).minWidth),
|
||||
).toBe("642px");
|
||||
});
|
||||
}
|
||||
|
||||
for (const shape of ["reka", "prime"] as const) {
|
||||
test(`${shape} continuous shrink clamps a collapsed canvas and grows back`, async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await page.setViewportSize({ width: 1920, height: 900 });
|
||||
await page.goto(`/hostAppearance.html?shape=${shape}&layout=continuous`);
|
||||
await expect(page.locator(".h3c")).toBeVisible();
|
||||
for (const [step, width] of [1920, 1100, 800, 650, 800, 1100].entries()) {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await frame(page);
|
||||
await frame(page);
|
||||
const geometry = await page.evaluate(() => {
|
||||
const bounds = (id: string) => {
|
||||
const node = document.getElementById(id)!;
|
||||
const rect = node.getBoundingClientRect();
|
||||
return { left: rect.left, right: rect.right, width: rect.width };
|
||||
};
|
||||
return {
|
||||
surface: bounds("surface"),
|
||||
owner: bounds("panel"),
|
||||
main: bounds("main"),
|
||||
canvas: bounds("canvas"),
|
||||
minimum: Number.parseFloat(
|
||||
getComputedStyle(document.getElementById("panel")!).minWidth,
|
||||
),
|
||||
};
|
||||
});
|
||||
const geometryPath = info.outputPath(`geometry-${step}-${width}.json`);
|
||||
await writeFile(geometryPath, JSON.stringify(geometry, null, 2));
|
||||
await info.attach(`geometry-${step}-${width}`, {
|
||||
path: geometryPath,
|
||||
contentType: "application/json",
|
||||
});
|
||||
await page.screenshot({
|
||||
path: info.outputPath(`${shape}-${step}-${width}.png`),
|
||||
});
|
||||
expect(geometry.owner.left).toBe(56);
|
||||
expect(geometry.surface.right).toBe(width);
|
||||
if (width === 650) {
|
||||
expect(geometry.main.width).toBe(0);
|
||||
expect(geometry.canvas.width).toBe(0);
|
||||
expect.soft(geometry.owner.right).toBeLessThanOrEqual(width);
|
||||
expect.soft(geometry.minimum).toBeLessThanOrEqual(width - 56);
|
||||
} else {
|
||||
expect(geometry.minimum).toBe(704);
|
||||
expect(geometry.owner.width).toBe(704);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test("unknown topology still respects its measured parent", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/hostAppearance.html?shape=unknown");
|
||||
await expect(page.locator(".h3c")).toBeVisible();
|
||||
expect(
|
||||
await page
|
||||
.locator("#panel")
|
||||
.evaluate((node) => node.getBoundingClientRect().width),
|
||||
).toBe(620);
|
||||
});
|
||||
|
||||
async function portalPalettes(page: Page, root: Locator) {
|
||||
// Both harnesses open on a fresh page with no host marker or theme signal.
|
||||
expect(
|
||||
await page
|
||||
.locator("body")
|
||||
.evaluate((node) => node.classList.contains("litegraph")),
|
||||
).toBe(false);
|
||||
expect(
|
||||
await root.evaluate((node) =>
|
||||
getComputedStyle(node).getPropertyValue("--h3-canvas").trim(),
|
||||
),
|
||||
).toBe(dark);
|
||||
for (const [signal, expected] of [
|
||||
["new-dark", dark],
|
||||
["new-light", light],
|
||||
["old-dark", dark],
|
||||
["old-light", light],
|
||||
["hermetic", dark],
|
||||
] as const) {
|
||||
await page.evaluate((signal) => {
|
||||
document.body.classList.toggle("litegraph", signal !== "hermetic");
|
||||
document.documentElement.classList.toggle(
|
||||
"dark-theme",
|
||||
signal === "old-dark",
|
||||
);
|
||||
document.documentElement.style.colorScheme =
|
||||
signal === "new-dark"
|
||||
? "dark"
|
||||
: signal === "new-light"
|
||||
? "light"
|
||||
: signal === "hermetic"
|
||||
? "normal"
|
||||
: "";
|
||||
}, signal);
|
||||
await frame(page);
|
||||
expect(
|
||||
await root.evaluate((node) =>
|
||||
getComputedStyle(node).getPropertyValue("--h3-canvas").trim(),
|
||||
),
|
||||
signal,
|
||||
).toBe(expected);
|
||||
}
|
||||
for (const [theme, expected] of [
|
||||
["light", light],
|
||||
["dark", dark],
|
||||
] as const) {
|
||||
await page.evaluate((theme) => {
|
||||
document.body.classList.add("litegraph");
|
||||
document.documentElement.style.colorScheme =
|
||||
theme === "light" ? "dark" : "light";
|
||||
}, theme);
|
||||
await root.evaluate(
|
||||
(node, theme) => node.setAttribute("data-theme", theme),
|
||||
theme,
|
||||
);
|
||||
await frame(page);
|
||||
expect(
|
||||
await root.evaluate((node) =>
|
||||
getComputedStyle(node).getPropertyValue("--h3-canvas").trim(),
|
||||
),
|
||||
).toBe(expected);
|
||||
}
|
||||
}
|
||||
|
||||
test("crop portal renders both host theme shapes and preserves explicit overrides", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
const image = await page.evaluate(() => {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 640;
|
||||
canvas.height = 480;
|
||||
const context = canvas.getContext("2d")!;
|
||||
context.fillStyle = "#439e86";
|
||||
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||
return canvas.toDataURL("image/png").split(",")[1]!;
|
||||
});
|
||||
await page.route("**/view?*", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "image/png",
|
||||
body: Buffer.from(image, "base64"),
|
||||
}),
|
||||
);
|
||||
const text = sidebarCopy("en");
|
||||
await page.goto("/?mode=image-crop");
|
||||
await page.getByLabel("Picker locale").selectOption("en");
|
||||
await page
|
||||
.getByRole("combobox", { name: text.referenceImages, exact: true })
|
||||
.selectOption("10");
|
||||
await page
|
||||
.getByRole("button", { name: text.crop.action, exact: true })
|
||||
.click();
|
||||
const root = page.locator(".h3-crop-backdrop");
|
||||
await expect(root).toBeVisible();
|
||||
await expect(
|
||||
root.getByRole("group", { name: text.crop.regionLabel }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
await root.locator("img").evaluate((image) => ({
|
||||
width: (image as HTMLImageElement).naturalWidth,
|
||||
height: (image as HTMLImageElement).naturalHeight,
|
||||
})),
|
||||
).toEqual({ width: 640, height: 480 });
|
||||
await portalPalettes(page, root);
|
||||
await root.screenshot({ path: info.outputPath("crop-theme.png") });
|
||||
});
|
||||
|
||||
test("editor portal renders both host theme shapes and preserves explicit overrides", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await openIntegratedShell(page, "smoke");
|
||||
const root = page.locator("[data-h3-nle-root]");
|
||||
await expect(root).toBeVisible();
|
||||
await expect(root.locator('[data-h3-nle-area="timeline"]')).toBeVisible();
|
||||
await portalPalettes(page, root);
|
||||
await root.screenshot({ path: info.outputPath("editor-theme.png") });
|
||||
});
|
||||
@@ -1,5 +1,315 @@
|
||||
import { expect, test } from "../fixtures/h3Page";
|
||||
import { expect, test, type Locator } from "../fixtures/h3Page";
|
||||
import { sidebarCopy, SUPPORTED_LOCALES } from "../../../src/i18n/catalog";
|
||||
import { observeFrontendHostSeamsInPage } from "../../support/hostSeamLiveProbe";
|
||||
|
||||
for (const shape of ["data", "accessor", "absent"] as const)
|
||||
test(`crop contains host undo and canvas keys with ${shape} predicate`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const text = sidebarCopy("en");
|
||||
const image = await page.evaluate(() => {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 640;
|
||||
canvas.height = 480;
|
||||
const context = canvas.getContext("2d")!;
|
||||
context.fillStyle = "#439e86";
|
||||
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||
return canvas.toDataURL("image/png").split(",")[1]!;
|
||||
});
|
||||
await page.route("**/view?*", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "image/png",
|
||||
body: Buffer.from(image, "base64"),
|
||||
}),
|
||||
);
|
||||
await page.goto("/?mode=image-crop");
|
||||
await page.route("**/scripts/app.js", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "text/javascript",
|
||||
body: 'export { app } from "/hostKeyboard.ts";',
|
||||
}),
|
||||
);
|
||||
await page.route("**/scripts/api.js", (route) =>
|
||||
route.fulfill({
|
||||
contentType: "text/javascript",
|
||||
body: 'export { api } from "/hostKeyboard.ts";',
|
||||
}),
|
||||
);
|
||||
await page.evaluate(async (shape) => {
|
||||
const modulePath = "/hostKeyboard.ts";
|
||||
const fixture = (await import(
|
||||
/* @vite-ignore */ modulePath
|
||||
)) as typeof import("../../../e2e/hostKeyboard");
|
||||
fixture.configureHostModalPredicate(shape);
|
||||
(window as any).cropHostKeyWitness = fixture.installHostCapture(true);
|
||||
}, shape);
|
||||
const probe = await page.evaluate(observeFrontendHostSeamsInPage);
|
||||
expect(probe.modalKeyboardTier).toBe(shape);
|
||||
expect(
|
||||
probe.observations.find(
|
||||
(row) => row.seam_id === "frontend.app.modal_keyboard_guard",
|
||||
)?.readiness_state,
|
||||
).toBe("ready");
|
||||
await page
|
||||
.getByRole("combobox", { name: text.referenceImages, exact: true })
|
||||
.selectOption("10");
|
||||
await page
|
||||
.getByRole("button", { name: text.crop.action, exact: true })
|
||||
.click();
|
||||
const dialog = page.getByRole("dialog", { name: text.crop.title });
|
||||
await expect(
|
||||
dialog.getByRole("group", { name: text.crop.regionLabel }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
await dialog
|
||||
.locator("img")
|
||||
.evaluate((image) =>
|
||||
image instanceof HTMLImageElement ? image.naturalWidth : 0,
|
||||
),
|
||||
).toBeGreaterThan(0);
|
||||
const containment = await page.evaluate(async () => {
|
||||
const modulePath = "/hostKeyboard.ts";
|
||||
const fixture = (await import(
|
||||
/* @vite-ignore */ modulePath
|
||||
)) as typeof import("../../../e2e/hostKeyboard");
|
||||
return {
|
||||
predicate: fixture.hostModalPredicateActive(),
|
||||
modal: fixture.hostAriaModalOpen(),
|
||||
};
|
||||
});
|
||||
expect(containment).toEqual({ predicate: shape !== "absent", modal: true });
|
||||
await page.keyboard.press("Control+z");
|
||||
await page.keyboard.press("Control+y");
|
||||
expect(
|
||||
await page.evaluate(() => (window as any).cropHostKeyWitness),
|
||||
).toMatchObject({
|
||||
undoCapture: 2,
|
||||
undoActions: 0,
|
||||
canvasKeyups: 0,
|
||||
ghostActions: 0,
|
||||
});
|
||||
await dialog
|
||||
.getByRole("button", { name: text.crop.cancel, exact: true })
|
||||
.click();
|
||||
await expect(dialog).toHaveCount(0);
|
||||
await expect(page.locator("#crop-guard-leases")).toHaveText("0");
|
||||
await page.keyboard.press("Control+z");
|
||||
await page.keyboard.press("Delete");
|
||||
const witness = await page.evaluate(
|
||||
() => (window as any).cropHostKeyWitness,
|
||||
);
|
||||
expect(witness.undoActions).toBe(1);
|
||||
expect(witness.ghostActions).toBe(1);
|
||||
expect(witness.canvasKeyups).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
async function descriptionGeometry(tip: Locator) {
|
||||
return tip.evaluate((node) => {
|
||||
const box = node.getBoundingClientRect();
|
||||
const style = getComputedStyle(node);
|
||||
const canvas = document.createElement("canvas");
|
||||
const context = canvas.getContext("2d")!;
|
||||
context.font = style.font;
|
||||
const text = node.firstChild!;
|
||||
const words = [...(text.textContent ?? "").matchAll(/[A-Za-z]+/g)];
|
||||
const broken = words.flatMap((word) => {
|
||||
const range = document.createRange();
|
||||
range.setStart(text, word.index!);
|
||||
range.setEnd(text, word.index! + word[0].length);
|
||||
const lines = new Set(
|
||||
[...range.getClientRects()].map((r) => Math.round(r.top)),
|
||||
);
|
||||
return lines.size > 1 ? [word[0]] : [];
|
||||
});
|
||||
let left = 0;
|
||||
let right = document.documentElement.clientWidth;
|
||||
for (
|
||||
let parent = node.parentElement;
|
||||
parent;
|
||||
parent = parent.parentElement
|
||||
) {
|
||||
if (getComputedStyle(parent).overflowX !== "visible") {
|
||||
const clip = parent.getBoundingClientRect();
|
||||
left = Math.max(left, clip.left + parent.clientLeft);
|
||||
right = Math.min(
|
||||
right,
|
||||
clip.left + parent.clientLeft + parent.clientWidth,
|
||||
);
|
||||
}
|
||||
}
|
||||
return {
|
||||
group: node.parentElement!.getAttribute("aria-label"),
|
||||
groupWidth: node.parentElement!.getBoundingClientRect().width,
|
||||
width: box.width,
|
||||
widestWord: Math.max(
|
||||
0,
|
||||
...words.map((word) => context.measureText(word[0]).width),
|
||||
),
|
||||
broken,
|
||||
left: box.left,
|
||||
right: box.right,
|
||||
clipLeft: left,
|
||||
clipRight: right,
|
||||
lines: (box.height - 14) / parseFloat(style.lineHeight),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function expectReadable(
|
||||
measured: Awaited<ReturnType<typeof descriptionGeometry>>,
|
||||
) {
|
||||
const detail = JSON.stringify(measured);
|
||||
expect(measured.width, detail).toBeGreaterThanOrEqual(
|
||||
measured.widestWord + 18,
|
||||
);
|
||||
expect(measured.broken, detail).toEqual([]);
|
||||
expect(measured.left, detail).toBeGreaterThanOrEqual(measured.clipLeft - 1);
|
||||
expect(measured.right, detail).toBeLessThanOrEqual(measured.clipRight + 1);
|
||||
}
|
||||
|
||||
test("narrow crop descriptions remain readable on hover and focus", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
const text = sidebarCopy("en");
|
||||
for (const width of [704, 960]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
await page.goto("/?mode=image-crop");
|
||||
await page.getByLabel(text.taskMode, { exact: true }).selectOption("i2va");
|
||||
const crop = page.getByRole("button", {
|
||||
name: text.crop.action,
|
||||
exact: true,
|
||||
});
|
||||
await expect(crop).toHaveAttribute("aria-disabled", "true");
|
||||
for (const interaction of ["hover", "focus"] as const) {
|
||||
if (interaction === "hover") await crop.hover();
|
||||
else await crop.focus();
|
||||
const tip = page.getByRole("tooltip");
|
||||
await expect(tip).toHaveText(text.crop.choose);
|
||||
await page.screenshot({
|
||||
path: testInfo.outputPath(`crop-${width}-${interaction}.png`),
|
||||
});
|
||||
const measured = await descriptionGeometry(tip);
|
||||
console.log(
|
||||
"crop description",
|
||||
width,
|
||||
interaction,
|
||||
JSON.stringify(measured),
|
||||
);
|
||||
expectReadable(measured);
|
||||
if (interaction === "focus") await page.keyboard.press("Escape");
|
||||
else await page.mouse.move(0, 0);
|
||||
await expect(tip).toHaveCount(0);
|
||||
await crop.blur();
|
||||
await page.mouse.move(0, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("short and long crop descriptions use real props in every locale", async ({
|
||||
page,
|
||||
}) => {
|
||||
for (const width of [704, 960]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
for (const reason of ["choose", "useExisting"] as const) {
|
||||
await page.goto(`/?mode=image-crop&crop-description=${reason}`);
|
||||
for (const locale of SUPPORTED_LOCALES) {
|
||||
await page.getByLabel("Picker locale").selectOption(locale);
|
||||
const text = sidebarCopy(locale);
|
||||
const crop = page.getByRole("button", {
|
||||
name: text.crop.action,
|
||||
exact: true,
|
||||
});
|
||||
for (const interaction of ["hover", "focus"] as const) {
|
||||
if (interaction === "hover") await crop.hover();
|
||||
else await crop.focus();
|
||||
const tip = page.getByRole("tooltip");
|
||||
await expect(tip).toHaveText(text.crop[reason]);
|
||||
const sample = await descriptionGeometry(tip);
|
||||
console.log(
|
||||
"crop sample",
|
||||
locale,
|
||||
reason,
|
||||
width,
|
||||
interaction,
|
||||
JSON.stringify(sample),
|
||||
);
|
||||
expectReadable(sample);
|
||||
expect(sample.lines).toBeLessThanOrEqual(6.1);
|
||||
if (interaction === "focus") await page.keyboard.press("Escape");
|
||||
else await page.mouse.move(0, 0);
|
||||
await expect(tip).toHaveCount(0);
|
||||
await crop.blur();
|
||||
await page.mouse.move(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("every sidebar and editor icon group keeps descriptions readable inside its clip", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
test.setTimeout(180_000);
|
||||
// Non-vacuous minima pinned to the rendered owners: H3Sidebar (one/two frame rows),
|
||||
// ReferenceSourcePicker (three image rows with four actions), NlePlanningSection (five main
|
||||
// actions), and the editor's NleTimelineToolbar (at least undo/redo) / sequence planning.
|
||||
for (const [scenario, route, minimum] of [
|
||||
["first", "/?mode=image-crop", 1],
|
||||
["first-last", "/?mode=image-crop", 2],
|
||||
["references", "/?mode=image-crop", 12],
|
||||
["planning", "/?mode=production&planning=1", 5],
|
||||
["workspace", "/nleWorkspace.html", 2],
|
||||
["sequence", "/nleSequence.html", 5],
|
||||
] as const) {
|
||||
await page.setViewportSize({
|
||||
width: route.startsWith("/?") ? 704 : 1280,
|
||||
height: 1100,
|
||||
});
|
||||
await page.goto(route);
|
||||
if (scenario === "first" || scenario === "first-last")
|
||||
await page
|
||||
.getByLabel(sidebarCopy("en").taskMode, { exact: true })
|
||||
.selectOption(scenario === "first" ? "i2va" : "fl2va");
|
||||
if (scenario === "references")
|
||||
await page.getByLabel("Picker preset").selectOption("sample");
|
||||
if (route.includes("production"))
|
||||
await page
|
||||
.getByRole("button", { name: "Production", exact: true })
|
||||
.click();
|
||||
if (route === "/nleWorkspace.html")
|
||||
await page.getByRole("button", { name: "Open full editor" }).click();
|
||||
const controls = page.locator("button.h3-icon-button");
|
||||
await expect(controls.first()).toBeVisible();
|
||||
let measured = 0;
|
||||
for (let index = 0; index < (await controls.count()); index++) {
|
||||
const button = controls.nth(index);
|
||||
if (!(await button.isVisible())) continue;
|
||||
const slot = button.locator("xpath=..");
|
||||
await slot.hover();
|
||||
const tip = button
|
||||
.locator("xpath=ancestor::*[contains(@class,'h3-icon-group')][1]")
|
||||
.getByRole("tooltip");
|
||||
await expect(tip).toBeVisible();
|
||||
const geometry = await descriptionGeometry(tip);
|
||||
console.log(
|
||||
"icon group sweep",
|
||||
scenario,
|
||||
await button.getAttribute("data-h3-nle-control"),
|
||||
JSON.stringify(geometry),
|
||||
);
|
||||
expectReadable(geometry);
|
||||
if (measured === 0)
|
||||
await page.screenshot({
|
||||
path: testInfo.outputPath(
|
||||
`toolbar-${route.includes("Sequence") ? "sequence" : route.includes("Workspace") ? "workspace" : route.includes("production") ? "planning" : "sidebar"}.png`,
|
||||
),
|
||||
});
|
||||
measured++;
|
||||
await page.mouse.move(0, 0);
|
||||
}
|
||||
expect(measured, scenario).toBeGreaterThanOrEqual(minimum);
|
||||
}
|
||||
});
|
||||
|
||||
test("crop images at the sidebar floor in every locale with exact geometry and keyboard containment", async ({
|
||||
page,
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
import {
|
||||
monitorStateFromText,
|
||||
observeShellOpen,
|
||||
OPEN_DIAGNOSTICS_NAME,
|
||||
type OpenDiagnostics,
|
||||
} from "../helpers/integratedShellDiagnostics";
|
||||
import { openIntegratedShell } from "../helpers/nleShell";
|
||||
|
||||
// The open diagnostic is the only record a hermetic CI failure keeps of where the monitor stopped,
|
||||
// because that profile retains no trace. These cases prove its readings against states the
|
||||
// harness can force, and prove that a failed open attaches it from this file, which is never the
|
||||
// first spec file a worker loads.
|
||||
|
||||
const abortFont = async (page: Page) => {
|
||||
await page.route("**/nle-media/font", (route) => route.abort());
|
||||
};
|
||||
|
||||
const labels = (facts: OpenDiagnostics) =>
|
||||
facts.requests
|
||||
.filter((row) => row.label.startsWith("media:"))
|
||||
.map((row) => `${row.label}:${row.outcome}`)
|
||||
.sort();
|
||||
const answered = (facts: OpenDiagnostics, label: string) =>
|
||||
facts.requests.filter((row) => row.label === label && row.outcome === "ok")
|
||||
.length;
|
||||
|
||||
test("the open diagnostic maps only the product's own status sentences", () => {
|
||||
expect(monitorStateFromText(null)).toEqual({
|
||||
monitor: "absent",
|
||||
blocker: null,
|
||||
});
|
||||
expect(monitorStateFromText("Opening monitor.")).toEqual({
|
||||
monitor: "opening",
|
||||
blocker: null,
|
||||
});
|
||||
expect(
|
||||
monitorStateFromText("Monitor unavailable: source unavailable."),
|
||||
).toEqual({ monitor: "blocked", blocker: "source_unavailable" });
|
||||
expect(monitorStateFromText("Monitor unavailable: anything else.")).toEqual({
|
||||
monitor: "blocked",
|
||||
blocker: "unknown",
|
||||
});
|
||||
expect(monitorStateFromText("D:/clips/take-01.mp4")).toEqual({
|
||||
monitor: "unknown",
|
||||
blocker: null,
|
||||
});
|
||||
});
|
||||
|
||||
test("a healthy open reads paused with every generic source answered", async ({
|
||||
page,
|
||||
}) => {
|
||||
const observer = observeShellOpen(page);
|
||||
await openIntegratedShell(page, "smoke");
|
||||
const facts = await observer.collect(page);
|
||||
expect(facts.monitor).toBe("paused");
|
||||
expect(facts.blocker).toBeNull();
|
||||
expect(facts.playDisabled).toBe(false);
|
||||
expect(facts.timelineReady).toBe(true);
|
||||
// The media bin's decorations also fetch, and the page cancels some of them, so only the
|
||||
// answered sources the composition needs are pinned: the font, the still and both videos.
|
||||
expect(answered(facts, "media:font")).toBeGreaterThanOrEqual(1);
|
||||
expect(answered(facts, "media:image")).toBeGreaterThanOrEqual(1);
|
||||
expect(answered(facts, "media:video")).toBeGreaterThanOrEqual(2);
|
||||
expect(labels(facts)).not.toContain("media:font:failed");
|
||||
expect(facts.pageErrors).toBe(0);
|
||||
});
|
||||
|
||||
// IMPORTANT: the product's source owner hands the runtime a video only after its metadata has
|
||||
// loaded. A harness that hands one over at HAVE_NOTHING makes the runtime's first seek a no-op, so
|
||||
// the open rests on one first-frame callback a busy browser can lose: the monitor then latches
|
||||
// "source unavailable" about once in 30-60 opens on two CPUs. This pins the precondition directly.
|
||||
test("the harness hands every source video over with metadata, as the product does", async ({
|
||||
page,
|
||||
}) => {
|
||||
await openIntegratedShell(page, "smoke");
|
||||
const states = await page.evaluate(
|
||||
() => window.__nleMediaDebug?.sourceHandoverReadyStates ?? null,
|
||||
);
|
||||
expect(states).not.toBeNull();
|
||||
// The smoke open leases the primary video twice: the picture and the audio follower.
|
||||
expect(states!.length).toBeGreaterThanOrEqual(2);
|
||||
expect(states!.filter((state) => state < 1)).toEqual([]);
|
||||
});
|
||||
|
||||
test("an aborted font reads blocked with its reason and the unavailable overlay", async ({
|
||||
page,
|
||||
}) => {
|
||||
const observer = observeShellOpen(page);
|
||||
await openIntegratedShell(page, "smoke", {
|
||||
beforeOpen: abortFont,
|
||||
expandOverlay: false,
|
||||
});
|
||||
await page
|
||||
.locator("#root")
|
||||
.getByRole("button", { name: "Open full editor" })
|
||||
.click();
|
||||
// IMPORTANT: wait on the diagnostic's own reading, not on an "unavailable" overlay. The monitor
|
||||
// shows its pre-composition fallback, which also carries that overlay, for about 50 ms before it
|
||||
// opens, so an overlay wait can read `fallback` or `opening` here.
|
||||
await expect
|
||||
.poll(async () => (await observer.collect(page)).monitor)
|
||||
.toBe("blocked");
|
||||
const facts = await observer.collect(page);
|
||||
expect(facts.fallback).toBeNull();
|
||||
expect(facts.blocker).toBe("source_unavailable");
|
||||
expect(facts.overlays).toContain("unavailable");
|
||||
expect(facts.playDisabled).toBe(true);
|
||||
expect(labels(facts)).toContain("media:font:failed");
|
||||
});
|
||||
|
||||
test("a failed open attaches exactly one closed open diagnostic", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await expect(
|
||||
openIntegratedShell(page, "smoke", {
|
||||
beforeOpen: abortFont,
|
||||
openTimeoutMs: 3_000,
|
||||
}),
|
||||
).rejects.toThrow("toBeEnabled");
|
||||
const attached = info.attachments.filter(
|
||||
(item) => item.name === OPEN_DIAGNOSTICS_NAME,
|
||||
);
|
||||
expect(attached).toHaveLength(1);
|
||||
expect(attached[0].contentType).toBe("application/json");
|
||||
const facts = JSON.parse(attached[0].body!.toString()) as OpenDiagnostics;
|
||||
expect(facts.monitor).toBe("blocked");
|
||||
expect(facts.blocker).toBe("source_unavailable");
|
||||
expect(facts.playDisabled).toBe(true);
|
||||
expect(facts.elapsedMs).toBeGreaterThanOrEqual(3_000);
|
||||
const text = JSON.stringify(facts);
|
||||
for (const forbidden of ["http", "nle-media/", "asset=", "Monitor ", ":/"])
|
||||
expect(text).not.toContain(forbidden);
|
||||
});
|
||||
@@ -792,8 +792,11 @@ test("A62-7: an empty Main lane shows the dashed drop zone instead of a sentence
|
||||
await page.getByRole("button", { name: "Open full editor" }).click();
|
||||
await expect(page.locator(surface)).toBeVisible();
|
||||
const zone = page.locator(surface).locator("[data-h3-nle-empty-lane]");
|
||||
// updated the sentence for the bin's "+".
|
||||
await expect(zone).toHaveText("Drag media here, or press + on a thumbnail");
|
||||
// both media bins add from the thumbnail card. IMPORTANT: this
|
||||
// literal mirrors `emptyLane` in nleCopy.ts and the unit pin in
|
||||
// nleTimelineClipSurface.test.tsx; change all three together. Only the
|
||||
// Hosted browser job runs this journey; the Windows Full Gate does not.
|
||||
await expect(zone).toHaveText("Click a thumbnail in Media to add it here");
|
||||
const lane = page
|
||||
.locator(surface)
|
||||
.locator('[data-h3-nle-track="track-0"] .h3-nle-track-lane');
|
||||
|
||||
@@ -405,8 +405,12 @@ test("A64-1: the empty-timeline overlay is centred, has no action and covers no
|
||||
await expect(overlay.locator("[data-h3-nle-overlay-title]")).toHaveText(
|
||||
"Nothing on the timeline yet",
|
||||
);
|
||||
await expect(overlay.locator("[data-h3-nle-overlay-detail]")).toContainText(
|
||||
"+",
|
||||
// both media bins add from the thumbnail card, so the hint names
|
||||
// the click and no longer the "+". IMPORTANT: this literal mirrors
|
||||
// `monitor.emptyHint` in nleCopy.ts and the unit pin in
|
||||
// nleWorkspaceMonitor.test.tsx; change all three together.
|
||||
await expect(overlay.locator("[data-h3-nle-overlay-detail]")).toHaveText(
|
||||
"Click a thumbnail in Media to add it to the timeline and preview it here.",
|
||||
);
|
||||
await expect(overlay.locator("button")).toHaveCount(0);
|
||||
const header = page.locator(`${OVERLAY} [data-h3-nle-monitor-header]`);
|
||||
|
||||
@@ -311,6 +311,15 @@ test("theme follows the host signal and yields to an explicit override", async (
|
||||
({ present: hostPresent, dark: hostDark, explicit: override }) => {
|
||||
document.body.classList.toggle("litegraph", hostPresent);
|
||||
document.documentElement.classList.toggle("dark-theme", hostDark);
|
||||
// the host theme controller observes only <html> class and
|
||||
// style; body.litegraph is a static marker it reads when <html>
|
||||
// changes. IMPORTANT: write the style on every step so each step
|
||||
// re-resolves, as a host theme change does. Toggling the body class
|
||||
// alone changes nothing. "normal" is the hermetic no-signal value; ""
|
||||
// leaves the old-host class signals to decide.
|
||||
document.documentElement.style.colorScheme = hostPresent
|
||||
? ""
|
||||
: "normal";
|
||||
if (override === null)
|
||||
document.documentElement.removeAttribute("data-theme");
|
||||
else document.documentElement.setAttribute("data-theme", override);
|
||||
|
||||
+21
-5
@@ -512,11 +512,23 @@ class FixtureAppConstructor {
|
||||
registerExtension = registerExtension;
|
||||
ui = { settings: uiSettings };
|
||||
}
|
||||
Object.defineProperty(FixtureAppConstructor, "maskeditor_is_opended", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
export let fixtureModalStore = createModalKeyboardHost("data").store;
|
||||
export function setFixtureModalKeyboardShape(shape: ModalKeyboardHostShape) {
|
||||
const fixture = createModalKeyboardHost(shape);
|
||||
fixtureModalStore = fixture.store;
|
||||
const descriptor = Object.getOwnPropertyDescriptor(
|
||||
fixture.constructor,
|
||||
"maskeditor_is_opended",
|
||||
);
|
||||
if (descriptor !== undefined)
|
||||
Object.defineProperty(
|
||||
FixtureAppConstructor,
|
||||
"maskeditor_is_opended",
|
||||
descriptor,
|
||||
);
|
||||
else Reflect.deleteProperty(FixtureAppConstructor, "maskeditor_is_opended");
|
||||
}
|
||||
setFixtureModalKeyboardShape("data");
|
||||
export const app = new FixtureAppConstructor();
|
||||
|
||||
export const api = {
|
||||
@@ -732,3 +744,7 @@ export function workflowState(): {
|
||||
}
|
||||
import { acquireModalKeyboardGuard } from "../../src/host/modalKeyboardGuard";
|
||||
import { acquireCanvasKeyboardGuard } from "../../src/host/canvasKeyboardGuard";
|
||||
import {
|
||||
createModalKeyboardHost,
|
||||
type ModalKeyboardHostShape,
|
||||
} from "../support/hostSeamTestDouble";
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import { act, cleanup, render } from "@testing-library/react";
|
||||
import { StrictMode } from "react";
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { H3Sidebar } from "../src/components/H3Sidebar";
|
||||
import { ImageCropDialog } from "../src/components/ImageCropDialog";
|
||||
import { NleOverlay } from "../src/components/nle/NleOverlay";
|
||||
import { createHostThemeController } from "../src/host/hostTheme";
|
||||
import { seamReady } from "../src/host/hostSeams";
|
||||
import { sidebarCopy } from "../src/i18n/catalog";
|
||||
import { initialShellState } from "../src/state/shellState";
|
||||
import { bindingFixture } from "./support/nleWorkspaceBinding";
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.unstubAllGlobals();
|
||||
document.documentElement.removeAttribute("class");
|
||||
document.documentElement.removeAttribute("style");
|
||||
document.body.classList.remove("litegraph");
|
||||
});
|
||||
|
||||
function observers() {
|
||||
const NativeObserver = MutationObserver;
|
||||
const active = new Set<MutationObserver>();
|
||||
class TrackedObserver extends NativeObserver {
|
||||
override observe(target: Node, options: MutationObserverInit) {
|
||||
super.observe(target, options);
|
||||
if (target === document.documentElement) active.add(this);
|
||||
}
|
||||
override disconnect() {
|
||||
super.disconnect();
|
||||
active.delete(this);
|
||||
}
|
||||
}
|
||||
vi.stubGlobal("MutationObserver", TrackedObserver);
|
||||
return active;
|
||||
}
|
||||
|
||||
it("restores a prior attribute and disconnects once, including queued changes", async () => {
|
||||
const active = observers();
|
||||
const root = document.createElement("div");
|
||||
root.setAttribute("data-h3-host-theme", "prior");
|
||||
document.documentElement.style.colorScheme = "dark";
|
||||
const dispose = createHostThemeController(root);
|
||||
expect(root.getAttribute("data-h3-host-theme")).toBe("dark");
|
||||
expect(active.size).toBe(1);
|
||||
document.documentElement.style.colorScheme = "light";
|
||||
dispose();
|
||||
dispose();
|
||||
await act(async () => {});
|
||||
expect(active.size).toBe(0);
|
||||
expect(root.getAttribute("data-h3-host-theme")).toBe("prior");
|
||||
});
|
||||
|
||||
for (const kind of ["sidebar", "crop", "editor"] as const) {
|
||||
it(`${kind} owns exactly one native theme observer under StrictMode and releases it`, async () => {
|
||||
const active = observers();
|
||||
const baseline = active.size;
|
||||
document.body.classList.add("litegraph");
|
||||
document.documentElement.style.colorScheme = "light";
|
||||
const binding = bindingFixture();
|
||||
const crop = (
|
||||
<ImageCropDialog
|
||||
sourceId="synthetic"
|
||||
text={sidebarCopy("en").crop}
|
||||
actions={{
|
||||
open: async () => ({
|
||||
url: "/view?synthetic",
|
||||
width: 640,
|
||||
height: 480,
|
||||
}),
|
||||
apply() {},
|
||||
clear() {},
|
||||
}}
|
||||
acquireKeyboardGuard={() => seamReady({ release() {} })}
|
||||
onClose={() => {}}
|
||||
/>
|
||||
);
|
||||
const view = render(
|
||||
<StrictMode>
|
||||
{kind === "sidebar" ? (
|
||||
<H3Sidebar state={initialShellState} locale="en" />
|
||||
) : kind === "crop" ? (
|
||||
crop
|
||||
) : (
|
||||
<NleOverlay binding={binding} />
|
||||
)}
|
||||
</StrictMode>,
|
||||
);
|
||||
await act(async () => {});
|
||||
const root = document.querySelector<HTMLElement>(
|
||||
kind === "editor" ? "[data-h3-nle-root]" : ".h3c",
|
||||
)!;
|
||||
expect(root).not.toBeNull();
|
||||
expect(root.getAttribute("data-h3-host-theme")).toBe("light");
|
||||
expect(active.size).toBe(baseline + 1);
|
||||
await act(async () => {
|
||||
document.documentElement.style.colorScheme = "dark";
|
||||
});
|
||||
expect(root.getAttribute("data-h3-host-theme")).toBe("dark");
|
||||
if (kind === "editor") {
|
||||
view.rerender(
|
||||
<StrictMode>
|
||||
<NleOverlay
|
||||
binding={{
|
||||
...binding,
|
||||
state: {
|
||||
...binding.state,
|
||||
surface: {
|
||||
...binding.state.surface,
|
||||
generation: binding.state.surface.generation + 1,
|
||||
},
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</StrictMode>,
|
||||
);
|
||||
expect(active.size).toBe(baseline + 1);
|
||||
view.rerender(
|
||||
<StrictMode>
|
||||
<NleOverlay
|
||||
binding={{
|
||||
...binding,
|
||||
state: {
|
||||
...binding.state,
|
||||
surface: { ...binding.state.surface, status: "compact_ready" },
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</StrictMode>,
|
||||
);
|
||||
expect(active.size).toBe(baseline);
|
||||
view.rerender(
|
||||
<StrictMode>
|
||||
<NleOverlay binding={binding} />
|
||||
</StrictMode>,
|
||||
);
|
||||
expect(active.size).toBe(baseline + 1);
|
||||
}
|
||||
view.unmount();
|
||||
expect(active.size).toBe(baseline);
|
||||
await act(async () => {
|
||||
document.documentElement.style.colorScheme = "light";
|
||||
});
|
||||
expect(root.hasAttribute("data-h3-host-theme")).toBe(false);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dirname, join, relative, resolve } from "node:path";
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
const sourceRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../src");
|
||||
const expected = [
|
||||
"components/H3Sidebar.tsx",
|
||||
"components/ImageCropDialog.tsx",
|
||||
"components/nle/NleOverlay.tsx",
|
||||
];
|
||||
function files(directory: string): string[] {
|
||||
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) =>
|
||||
entry.isDirectory()
|
||||
? files(join(directory, entry.name))
|
||||
: /\.tsx?$/.test(entry.name)
|
||||
? [join(directory, entry.name)]
|
||||
: [],
|
||||
);
|
||||
}
|
||||
function inspect(source: string) {
|
||||
// Inventory the literal class seams used by product roots, including JSX and DOM construction.
|
||||
const classes = [
|
||||
...source.matchAll(/\bclassName\s*=\s*["']([^"']*)["']/g),
|
||||
...source.matchAll(
|
||||
/\.setAttribute\(\s*["']class["']\s*,\s*["']([^"']*)["']/g,
|
||||
),
|
||||
...source.matchAll(/\.classList\.add\(\s*["']([^"']*)["']/g),
|
||||
];
|
||||
const roots = classes.filter((match) =>
|
||||
match[1]!.split(/\s+/).includes("h3c"),
|
||||
).length;
|
||||
const controllers = [
|
||||
...source.matchAll(
|
||||
/\b(?:return|const\s+\w+\s*=)\s+createHostThemeController\(/g,
|
||||
),
|
||||
].length;
|
||||
return { roots, controllers };
|
||||
}
|
||||
|
||||
it("every product .h3c creation site owns its theme controller, including portals", () => {
|
||||
const inventory = files(sourceRoot).map((path) => ({
|
||||
path: relative(sourceRoot, path).replaceAll("\\", "/"),
|
||||
...inspect(readFileSync(path, "utf8")),
|
||||
}));
|
||||
expect(
|
||||
inventory
|
||||
.filter((row) => row.roots > 0)
|
||||
.map((row) => row.path)
|
||||
.sort(),
|
||||
).toEqual(expected);
|
||||
expect(
|
||||
inventory
|
||||
.filter((row) => row.controllers > 0)
|
||||
.map((row) => row.path)
|
||||
.sort(),
|
||||
).toEqual(expected);
|
||||
for (const row of inventory)
|
||||
expect(row.controllers, row.path).toBe(row.roots);
|
||||
});
|
||||
|
||||
it("finds an unwired fourth root and handles real product LF/CRLF equivalently", () => {
|
||||
expect(inspect('const fourth = <div className="h3c" />;')).toEqual({
|
||||
roots: 1,
|
||||
controllers: 0,
|
||||
});
|
||||
for (const path of expected) {
|
||||
const lf = readFileSync(join(sourceRoot, path), "utf8").replaceAll(
|
||||
"\r\n",
|
||||
"\n",
|
||||
);
|
||||
expect(inspect(lf.replaceAll("\n", "\r\n"))).toEqual(inspect(lf));
|
||||
}
|
||||
});
|
||||
@@ -64,7 +64,7 @@ export const PERMANENT_IDENTIFIERS: ReadonlySet<string> = new Set([
|
||||
// A language option is written in its own language in every locale, which is
|
||||
// the correct behaviour and the reason these are not violations.
|
||||
"English",
|
||||
"繁體中文",
|
||||
"正體中文",
|
||||
"简体中文",
|
||||
]);
|
||||
|
||||
|
||||
@@ -358,37 +358,9 @@ describe("M25-08 supplied-host model-free bootstrap", () => {
|
||||
expect(runtime.__h3HostProjectionTrace).toEqual([]);
|
||||
});
|
||||
|
||||
it("accepts only ComfyUI's closed title metadata before exact projection", () => {
|
||||
const bootstrap = buildM2508HostBootstrap(LOCATOR);
|
||||
installM2508ManagedExecutionProjection(bootstrap.executionPrompt);
|
||||
const project = (
|
||||
window as unknown as {
|
||||
__h3M2508ManagedExecutionProjection: (
|
||||
compiled: Record<string, unknown>,
|
||||
) => Record<string, unknown>;
|
||||
}
|
||||
).__h3M2508ManagedExecutionProjection;
|
||||
const output = Object.fromEntries(
|
||||
Object.entries(bootstrap.executionPrompt).map(([id, node]) => [
|
||||
id,
|
||||
{ ...structuredClone(node), _meta: { title: `Node ${id}` } },
|
||||
]),
|
||||
);
|
||||
output[bootstrap.nativeAnchorNodeId] = {
|
||||
...structuredClone(
|
||||
bootstrap.visiblePrompt[bootstrap.nativeAnchorNodeId]!,
|
||||
),
|
||||
_meta: { title: "Native anchor" },
|
||||
};
|
||||
|
||||
expect(project({ output, workflow: {} })).toMatchObject({
|
||||
output: bootstrap.executionPrompt,
|
||||
});
|
||||
});
|
||||
|
||||
it.each([{ title: "Request", extra: true }, { title: 1 }])(
|
||||
"rejects non-closed ComfyUI metadata: %j",
|
||||
(_meta) => {
|
||||
it.each(["old", "new"] as const)(
|
||||
"accepts the %s closed host metadata shape before exact projection",
|
||||
(shape) => {
|
||||
const bootstrap = buildM2508HostBootstrap(LOCATOR);
|
||||
installM2508ManagedExecutionProjection(bootstrap.executionPrompt);
|
||||
const project = (
|
||||
@@ -398,20 +370,66 @@ describe("M25-08 supplied-host model-free bootstrap", () => {
|
||||
) => Record<string, unknown>;
|
||||
}
|
||||
).__h3M2508ManagedExecutionProjection;
|
||||
const output = structuredClone(bootstrap.executionPrompt) as Record<
|
||||
string,
|
||||
Record<string, unknown>
|
||||
>;
|
||||
output["1"]!._meta = _meta;
|
||||
output[bootstrap.nativeAnchorNodeId] =
|
||||
bootstrap.visiblePrompt[bootstrap.nativeAnchorNodeId]!;
|
||||
|
||||
expect(() => project({ output, workflow: {} })).toThrow(
|
||||
"M25-08 model-free execution projection is not exact",
|
||||
const output = Object.fromEntries(
|
||||
Object.entries(bootstrap.executionPrompt).map(([id, node]) => [
|
||||
id,
|
||||
{
|
||||
...structuredClone(node),
|
||||
_meta: {
|
||||
title: `Node ${id}`,
|
||||
...(shape === "new"
|
||||
? Number(id) % 2 === 0
|
||||
? { cnr_id: "pack", ver: "1" }
|
||||
: { aux_id: "owner/pack", ver: "1" }
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
]),
|
||||
);
|
||||
output[bootstrap.nativeAnchorNodeId] = {
|
||||
...structuredClone(
|
||||
bootstrap.visiblePrompt[bootstrap.nativeAnchorNodeId]!,
|
||||
),
|
||||
_meta: { title: "Native anchor" },
|
||||
};
|
||||
|
||||
expect(
|
||||
JSON.stringify(project({ output, workflow: {} }).output) ===
|
||||
JSON.stringify(bootstrap.executionPrompt),
|
||||
).toBe(true);
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
["unknown", { title: "Request", extra: true }],
|
||||
["type", { title: 1 }],
|
||||
["oversize", { ver: "x".repeat(257) }],
|
||||
["prototype-sensitive", JSON.parse('{"__proto__":"x"}')],
|
||||
["null", null],
|
||||
["array", []],
|
||||
])("rejects non-closed ComfyUI metadata class %s", (_label, _meta) => {
|
||||
const bootstrap = buildM2508HostBootstrap(LOCATOR);
|
||||
installM2508ManagedExecutionProjection(bootstrap.executionPrompt);
|
||||
const project = (
|
||||
window as unknown as {
|
||||
__h3M2508ManagedExecutionProjection: (
|
||||
compiled: Record<string, unknown>,
|
||||
) => Record<string, unknown>;
|
||||
}
|
||||
).__h3M2508ManagedExecutionProjection;
|
||||
const output = structuredClone(bootstrap.executionPrompt) as Record<
|
||||
string,
|
||||
Record<string, unknown>
|
||||
>;
|
||||
output["1"]!._meta = _meta;
|
||||
output[bootstrap.nativeAnchorNodeId] =
|
||||
bootstrap.visiblePrompt[bootstrap.nativeAnchorNodeId]!;
|
||||
|
||||
expect(() => project({ output, workflow: {} })).toThrow(
|
||||
"M25-08 model-free execution projection is not exact",
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["wrong native id", "12", "MiniMaxH3ReferenceToVideo"],
|
||||
["wrong native type", "9", "MiniMaxH3ImageToVideo"],
|
||||
|
||||
@@ -473,8 +473,9 @@ describe("final output placement and empty timeline", () => {
|
||||
const empty = view.container.querySelector("[data-h3-nle-empty=timeline]");
|
||||
// (row #27): the empty-timeline overlay's title and hint.
|
||||
expect(empty?.textContent).toContain("Nothing on the timeline yet");
|
||||
// B-M2563-11: it names the card's visible "+" and drag, not the context menu's command.
|
||||
expect(empty?.textContent).toContain("+");
|
||||
// The thumbnail card is the common add control in both media bins.
|
||||
expect(empty?.textContent).toMatch(/Click.*thumbnail/);
|
||||
expect(empty?.textContent).not.toContain("+");
|
||||
expect(empty?.textContent).toContain("Media");
|
||||
expect(empty?.textContent).not.toContain("Add to timeline");
|
||||
expect(view.container.textContent).not.toContain(
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
acquireModalKeyboardGuard,
|
||||
probeModalKeyboardGuard,
|
||||
} from "../src/host/modalKeyboardGuard";
|
||||
import { createModalKeyboardHost } from "./support/hostSeamTestDouble";
|
||||
|
||||
const member = "maskeditor_is_opended";
|
||||
function acquire(host: object) {
|
||||
const result = acquireModalKeyboardGuard(host);
|
||||
expect(result.status).toBe("ready");
|
||||
if (result.status !== "ready") throw new Error(result.reason);
|
||||
return result.value;
|
||||
}
|
||||
|
||||
describe("store-backed host modal predicate", () => {
|
||||
it("installs through the compatibility setter and contains direct-store undo and redo", () => {
|
||||
const original = vi.fn(() => false);
|
||||
const subject = createModalKeyboardHost("accessor", original);
|
||||
const before = Object.getOwnPropertyDescriptor(
|
||||
subject.constructor,
|
||||
"maskeditor_is_opended",
|
||||
);
|
||||
let undoActions = 0;
|
||||
const changeTracker = (key: "z" | "y") => {
|
||||
if (subject.store.predicate?.()) return;
|
||||
if (["z", "y"].includes(key)) undoActions += 1;
|
||||
};
|
||||
changeTracker("z");
|
||||
expect(undoActions).toBe(1);
|
||||
const result = acquireModalKeyboardGuard(subject.host);
|
||||
expect(result.status).toBe("ready");
|
||||
if (result.status !== "ready") throw new Error(result.reason);
|
||||
expect(subject.store.predicate?.()).toBe(true);
|
||||
changeTracker("z");
|
||||
changeTracker("y");
|
||||
expect(undoActions).toBe(1);
|
||||
expect(
|
||||
Object.getOwnPropertyDescriptor(
|
||||
subject.constructor,
|
||||
"maskeditor_is_opended",
|
||||
),
|
||||
).toEqual(before);
|
||||
result.value.release();
|
||||
expect(subject.store.predicate).toBe(original);
|
||||
changeTracker("y");
|
||||
expect(undoActions).toBe(2);
|
||||
});
|
||||
|
||||
it("probes only the descriptor, then installs a null initial hook through the host setter", () => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
const original = Object.getOwnPropertyDescriptor(
|
||||
subject.constructor,
|
||||
member,
|
||||
)!;
|
||||
const get = vi.fn(original.get!);
|
||||
const set = vi.fn(original.set!);
|
||||
Object.defineProperty(subject.constructor, member, {
|
||||
...original,
|
||||
get,
|
||||
set,
|
||||
});
|
||||
const before = Object.getOwnPropertyDescriptor(subject.constructor, member);
|
||||
expect(probeModalKeyboardGuard(subject.host).status).toBe("ready");
|
||||
expect(get).not.toHaveBeenCalled();
|
||||
expect(set).not.toHaveBeenCalled();
|
||||
const lease = acquire(subject.host);
|
||||
expect(lease.tier).toBe("accessor");
|
||||
expect(subject.store.predicate?.()).toBe(true);
|
||||
const handedOut = subject.store.predicate!;
|
||||
lease.release();
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
expect(handedOut()).toBe(false);
|
||||
expect(set).toHaveBeenCalledTimes(2);
|
||||
expect(
|
||||
Object.getOwnPropertyDescriptor(subject.constructor, member),
|
||||
).toEqual(before);
|
||||
});
|
||||
|
||||
it.each([false, true])(
|
||||
"shares nested leases with reverse order %s and releases once",
|
||||
(reverse) => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
const first = acquire(subject.host);
|
||||
const wrapper = subject.store.predicate;
|
||||
const second = acquire(subject.host);
|
||||
expect(subject.store.predicate).toBe(wrapper);
|
||||
const leases = reverse ? [second, first] : [first, second];
|
||||
leases[0]!.release();
|
||||
leases[0]!.release();
|
||||
expect(subject.store.predicate?.()).toBe(true);
|
||||
leases[1]!.release();
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
acquire(subject.host).release();
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves external replacements and delegates inactive wrappers to the saved receiver", () => {
|
||||
const original = vi.fn(function (this: unknown, argument: unknown) {
|
||||
return { receiver: this, argument };
|
||||
});
|
||||
const subject = createModalKeyboardHost("accessor", original);
|
||||
const lease = acquire(subject.host);
|
||||
const wrapper = subject.store.predicate!;
|
||||
const external = () => wrapper("external");
|
||||
subject.constructor.maskeditor_is_opended = external;
|
||||
expect(acquireModalKeyboardGuard(subject.host).status).toBe("unavailable");
|
||||
expect(external()).toBe(true);
|
||||
lease.release();
|
||||
expect(subject.store.predicate).toBe(external);
|
||||
expect(wrapper.call({}, "argument")).toEqual({
|
||||
receiver: subject.constructor,
|
||||
argument: "argument",
|
||||
});
|
||||
expect(external()).toEqual({
|
||||
receiver: subject.constructor,
|
||||
argument: "external",
|
||||
});
|
||||
});
|
||||
|
||||
it("refuses nesting after an external descriptor freeze and restores through the original setter", () => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
const lease = acquire(subject.host);
|
||||
Object.freeze(subject.constructor);
|
||||
expect(acquireModalKeyboardGuard(subject.host).status).toBe("unavailable");
|
||||
lease.release();
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
});
|
||||
|
||||
it("refuses a constructor frozen by the accessor setter during installation", () => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
let handedOut: (() => unknown) | null = null;
|
||||
Object.defineProperty(subject.constructor, member, {
|
||||
set(value: typeof subject.store.predicate) {
|
||||
subject.store.predicate = value;
|
||||
if (value !== null) {
|
||||
handedOut = value;
|
||||
Object.freeze(subject.constructor);
|
||||
}
|
||||
},
|
||||
});
|
||||
expect(acquireModalKeyboardGuard(subject.host).status).toBe("unavailable");
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
expect(handedOut).not.toBeNull();
|
||||
expect(handedOut!()).toBe(false);
|
||||
});
|
||||
|
||||
it.each(
|
||||
(["setter", "readback"] as const).flatMap((stage) =>
|
||||
(["get", "set", "configurable", "enumerable"] as const).map((part) => ({
|
||||
stage,
|
||||
part,
|
||||
})),
|
||||
),
|
||||
)("refuses descriptor $part replacement during $stage", ({ stage, part }) => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
let foreign: PropertyDescriptor | undefined;
|
||||
let handedOut: (() => unknown) | null = null;
|
||||
const replace = () => {
|
||||
const changed: PropertyDescriptor = {
|
||||
get: () => subject.store.predicate,
|
||||
set: (value: typeof subject.store.predicate) => {
|
||||
subject.store.predicate = value;
|
||||
},
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
};
|
||||
Object.defineProperty(subject.constructor, member, {
|
||||
[part]: changed[part],
|
||||
});
|
||||
foreign = Object.getOwnPropertyDescriptor(subject.constructor, member);
|
||||
};
|
||||
Object.defineProperty(subject.constructor, member, {
|
||||
get() {
|
||||
if (stage === "readback" && handedOut !== null && foreign === undefined)
|
||||
replace();
|
||||
return subject.store.predicate;
|
||||
},
|
||||
set(value: typeof subject.store.predicate) {
|
||||
subject.store.predicate = value;
|
||||
if (value !== null) {
|
||||
handedOut = value;
|
||||
if (stage === "setter") replace();
|
||||
}
|
||||
},
|
||||
});
|
||||
expect(acquireModalKeyboardGuard(subject.host).status).toBe("unavailable");
|
||||
expect(handedOut).not.toBeNull();
|
||||
expect(handedOut!()).toBe(false);
|
||||
expect(
|
||||
Object.getOwnPropertyDescriptor(subject.constructor, member),
|
||||
).toEqual(foreign);
|
||||
expect(subject.store.predicate).toBe(
|
||||
part === "get" || part === "set" ? handedOut : null,
|
||||
);
|
||||
});
|
||||
|
||||
it("refuses a descriptor trap after accessor value readback and restores best-effort", () => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
let failRead = false;
|
||||
let handedOut: (() => unknown) | null = null;
|
||||
Object.defineProperty(subject.constructor, member, {
|
||||
set(value: typeof subject.store.predicate) {
|
||||
subject.store.predicate = value;
|
||||
if (value !== null) {
|
||||
handedOut = value;
|
||||
failRead = true;
|
||||
}
|
||||
},
|
||||
});
|
||||
const constructor = new Proxy(subject.constructor, {
|
||||
getOwnPropertyDescriptor(target, key) {
|
||||
if (key === member && failRead) {
|
||||
failRead = false;
|
||||
throw new Error("descriptor readback");
|
||||
}
|
||||
return Reflect.getOwnPropertyDescriptor(target, key);
|
||||
},
|
||||
});
|
||||
expect(
|
||||
acquireModalKeyboardGuard(Object.create({ constructor })).status,
|
||||
).toBe("unavailable");
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
expect(handedOut!()).toBe(false);
|
||||
});
|
||||
|
||||
it("refuses a data define trap that lies about installing the wrapper", () => {
|
||||
const subject = createModalKeyboardHost("data");
|
||||
let handedOut: (() => unknown) | null = null;
|
||||
const constructor = new Proxy(subject.constructor, {
|
||||
defineProperty(target, key, next) {
|
||||
if (typeof next.get === "function") {
|
||||
handedOut = next.get() as () => unknown;
|
||||
return true;
|
||||
}
|
||||
return Reflect.defineProperty(target, key, next);
|
||||
},
|
||||
});
|
||||
expect(
|
||||
acquireModalKeyboardGuard(Object.create({ constructor })).status,
|
||||
).toBe("unavailable");
|
||||
expect(Reflect.get(subject.constructor, member)).toBeNull();
|
||||
expect(handedOut!()).toBe(false);
|
||||
});
|
||||
|
||||
it.each([false, undefined, {}, 0])(
|
||||
"does not write a non-callable first accessor value %j",
|
||||
(value) => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
Reflect.set(subject.constructor, member, value);
|
||||
const before = Object.getOwnPropertyDescriptor(
|
||||
subject.constructor,
|
||||
member,
|
||||
);
|
||||
const lease = acquire(subject.host);
|
||||
expect(lease.tier).toBe("absent");
|
||||
expect(Reflect.get(subject.constructor, member)).toBe(value);
|
||||
lease.release();
|
||||
expect(
|
||||
Object.getOwnPropertyDescriptor(subject.constructor, member),
|
||||
).toEqual(before);
|
||||
expect(Reflect.get(subject.constructor, member)).toBe(value);
|
||||
},
|
||||
);
|
||||
|
||||
it("refuses a throwing first getter without calling its setter", () => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
const set = vi.fn();
|
||||
Object.defineProperty(subject.constructor, member, {
|
||||
get() {
|
||||
throw new Error("getter");
|
||||
},
|
||||
set,
|
||||
});
|
||||
expect(probeModalKeyboardGuard(subject.host).status).toBe("ready");
|
||||
expect(acquireModalKeyboardGuard(subject.host)).toEqual({
|
||||
status: "unavailable",
|
||||
reason: "modal_keyboard_guard_unavailable",
|
||||
});
|
||||
expect(set).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("restores after a no-op setter causes a read-back mismatch", () => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
const set = vi.fn();
|
||||
Object.defineProperty(subject.constructor, member, { set });
|
||||
expect(acquireModalKeyboardGuard(subject.host).status).toBe("unavailable");
|
||||
expect(set).toHaveBeenCalledTimes(2);
|
||||
expect(set).toHaveBeenLastCalledWith(null);
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
});
|
||||
|
||||
it.each(["setter", "readback"])(
|
||||
"deactivates and restores a partial install after %s throws",
|
||||
(failure) => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
let handedOut: (() => unknown) | null = null;
|
||||
Object.defineProperty(subject.constructor, member, {
|
||||
get() {
|
||||
if (failure === "readback" && subject.store.predicate !== null)
|
||||
throw new Error("readback");
|
||||
return subject.store.predicate;
|
||||
},
|
||||
set(value: typeof subject.store.predicate) {
|
||||
subject.store.predicate = value;
|
||||
if (value !== null) {
|
||||
handedOut = value;
|
||||
if (failure === "setter") throw new Error("setter");
|
||||
}
|
||||
},
|
||||
});
|
||||
expect(acquireModalKeyboardGuard(subject.host).status).toBe(
|
||||
"unavailable",
|
||||
);
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
expect(handedOut).not.toBeNull();
|
||||
expect(handedOut!()).toBe(false);
|
||||
},
|
||||
);
|
||||
|
||||
it("never redefines the accessor, even through a constructor proxy", () => {
|
||||
const subject = createModalKeyboardHost("accessor");
|
||||
const defineProperty = vi.fn(() => {
|
||||
throw new Error("redefine");
|
||||
});
|
||||
const constructor = new Proxy(subject.constructor, { defineProperty });
|
||||
const lease = acquire(Object.create({ constructor }) as object);
|
||||
expect(subject.store.predicate?.()).toBe(true);
|
||||
lease.release();
|
||||
expect(subject.store.predicate).toBeNull();
|
||||
expect(defineProperty).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("never adopts its own inactive wrapper after a store setter starts throwing", () => {
|
||||
const original = vi.fn(() => false);
|
||||
const subject = createModalKeyboardHost("accessor", original);
|
||||
let frozen = false;
|
||||
Object.defineProperty(subject.constructor, member, {
|
||||
set(value: typeof subject.store.predicate) {
|
||||
if (frozen) throw new Error("store frozen");
|
||||
subject.store.predicate = value;
|
||||
},
|
||||
});
|
||||
const lease = acquire(subject.host);
|
||||
const wrapper = subject.store.predicate;
|
||||
frozen = true;
|
||||
expect(() => lease.release()).not.toThrow();
|
||||
expect(subject.store.predicate).toBe(wrapper);
|
||||
expect(wrapper?.()).toBe(false);
|
||||
expect(original).toHaveBeenCalledOnce();
|
||||
expect(acquireModalKeyboardGuard(subject.host).status).toBe("unavailable");
|
||||
expect(subject.store.predicate).toBe(wrapper);
|
||||
expect(original).toHaveBeenCalledOnce();
|
||||
frozen = false;
|
||||
subject.constructor.maskeditor_is_opended = original;
|
||||
acquire(subject.host).release();
|
||||
expect(subject.store.predicate).toBe(original);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,153 @@
|
||||
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { ImageCropDialog } from "../src/components/ImageCropDialog";
|
||||
import { NleOverlay } from "../src/components/nle/NleOverlay";
|
||||
import { acquireCanvasKeyboardGuard } from "../src/host/canvasKeyboardGuard";
|
||||
import { acquireModalKeyboardGuard } from "../src/host/modalKeyboardGuard";
|
||||
import { seamReady } from "../src/host/hostSeams";
|
||||
import { sidebarCopy } from "../src/i18n/catalog";
|
||||
import { bindingFixture } from "./support/nleWorkspaceBinding";
|
||||
import {
|
||||
createModalKeyboardHost,
|
||||
fixtureBackedAppModeHost,
|
||||
} from "./support/hostSeamTestDouble";
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
for (const shape of ["data", "accessor", "absent"] as const)
|
||||
for (const surface of ["editor", "crop"] as const)
|
||||
it(`${surface} contains host undo/redo and canvas keys with the ${shape} predicate`, async () => {
|
||||
const subject = createModalKeyboardHost(shape);
|
||||
const source = Object.defineProperty({}, "constructor", {
|
||||
value: subject.constructor,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
const host = fixtureBackedAppModeHost(source, {}).app as {
|
||||
canvas: { _key_callback: EventListener };
|
||||
};
|
||||
const canvasKey = vi.fn();
|
||||
host.canvas._key_callback = canvasKey;
|
||||
document.addEventListener("keyup", canvasKey, true);
|
||||
const counts = [0, 0];
|
||||
const captures = [0, 0];
|
||||
// JSDOM has no layout/checkVisibility; the browser journey uses the host's
|
||||
// rendered check. Here mirror its hidden/style and aria-modal containment.
|
||||
const modalOpen = () =>
|
||||
Array.from(
|
||||
document.querySelectorAll('[role="dialog"][aria-modal="true"]'),
|
||||
).some(
|
||||
(node) =>
|
||||
node.closest('[hidden], [aria-hidden="true"]') === null &&
|
||||
getComputedStyle(node).display !== "none" &&
|
||||
getComputedStyle(node).visibility !== "hidden",
|
||||
);
|
||||
const readers = [
|
||||
() =>
|
||||
Reflect.get(subject.constructor, "maskeditor_is_opended") as
|
||||
(() => unknown) | undefined,
|
||||
() => subject.store.predicate,
|
||||
];
|
||||
const handlers = readers.map((read, index) => (event: KeyboardEvent) => {
|
||||
if (!event.ctrlKey || !["z", "y"].includes(event.key)) return;
|
||||
captures[index]! += 1;
|
||||
if (read()?.() || modalOpen()) return;
|
||||
counts[index]! += 1;
|
||||
});
|
||||
for (const handler of handlers)
|
||||
window.addEventListener("keydown", handler, true);
|
||||
const tiers: string[] = [];
|
||||
const acquire = vi.fn((invalidated: () => void) => {
|
||||
const modal = acquireModalKeyboardGuard(host);
|
||||
if (modal.status !== "ready") return modal;
|
||||
tiers.push(modal.value.tier);
|
||||
const canvas = acquireCanvasKeyboardGuard(host, invalidated);
|
||||
if (canvas.status !== "ready") {
|
||||
modal.value.release();
|
||||
return canvas;
|
||||
}
|
||||
return seamReady({
|
||||
release() {
|
||||
canvas.value.release();
|
||||
modal.value.release();
|
||||
},
|
||||
});
|
||||
});
|
||||
try {
|
||||
const base = bindingFixture();
|
||||
const binding = {
|
||||
...base,
|
||||
state: {
|
||||
...base.state,
|
||||
surface: { ...base.state.surface, status: "opening" as const },
|
||||
},
|
||||
};
|
||||
const closed = vi.fn();
|
||||
const view = render(
|
||||
surface === "editor" ? (
|
||||
<NleOverlay
|
||||
binding={{
|
||||
...binding,
|
||||
actions: {
|
||||
...binding.actions,
|
||||
acquireKeyboardGuard: acquire,
|
||||
close: closed,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<ImageCropDialog
|
||||
sourceId="17"
|
||||
text={sidebarCopy("en").crop}
|
||||
actions={{
|
||||
open: async () => ({
|
||||
url: "/synthetic-crop.png",
|
||||
width: 640,
|
||||
height: 480,
|
||||
}),
|
||||
apply() {},
|
||||
clear() {},
|
||||
}}
|
||||
acquireKeyboardGuard={acquire}
|
||||
onClose={closed}
|
||||
/>
|
||||
),
|
||||
);
|
||||
const dialog = await screen.findByRole("dialog");
|
||||
expect(dialog.getAttribute("aria-modal")).toBe("true");
|
||||
expect(modalOpen()).toBe(true);
|
||||
expect(acquire).toHaveBeenCalledOnce();
|
||||
expect(tiers).toEqual([shape]);
|
||||
if (surface === "editor")
|
||||
expect(binding.actions.mounted).toHaveBeenCalledOnce();
|
||||
else {
|
||||
await screen.findByRole("group", { name: "Crop rectangle" });
|
||||
expect(dialog.querySelector("img")?.getAttribute("src")).toBe(
|
||||
"/synthetic-crop.png",
|
||||
);
|
||||
}
|
||||
fireEvent.keyDown(dialog, { key: "z", ctrlKey: true });
|
||||
fireEvent.keyDown(dialog, { key: "y", ctrlKey: true });
|
||||
fireEvent.keyUp(dialog, { key: "Delete" });
|
||||
expect(captures).toEqual([2, 2]);
|
||||
expect(counts).toEqual([0, 0]);
|
||||
expect(canvasKey).not.toHaveBeenCalled();
|
||||
fireEvent.click(
|
||||
screen.getByRole("button", {
|
||||
name: surface === "editor" ? "Close full editor" : "Cancel",
|
||||
}),
|
||||
);
|
||||
expect(closed).toHaveBeenCalledOnce();
|
||||
view.unmount();
|
||||
expect(modalOpen()).toBe(false);
|
||||
fireEvent.keyDown(document.body, { key: "z", ctrlKey: true });
|
||||
fireEvent.keyUp(document.body, { key: "Delete" });
|
||||
expect(counts).toEqual([1, 1]);
|
||||
expect(canvasKey).toHaveBeenCalledOnce();
|
||||
} finally {
|
||||
cleanup();
|
||||
for (const handler of handlers)
|
||||
window.removeEventListener("keydown", handler, true);
|
||||
document.removeEventListener("keyup", canvasKey, true);
|
||||
}
|
||||
});
|
||||
@@ -119,20 +119,31 @@ describe("callable modal keyboard guard", () => {
|
||||
});
|
||||
|
||||
it.each([false, undefined, {}, 0])(
|
||||
"refuses incompatible static value %j",
|
||||
"uses DOM containment for formerly refused incompatible static value %j",
|
||||
(value) => {
|
||||
const { host } = fixture(null, { value });
|
||||
expect(acquireModalKeyboardGuard(host).status).toBe("unavailable");
|
||||
expect(probeModalKeyboardGuard(host).status).toBe("unavailable");
|
||||
const { host, constructor } = fixture(null, { value });
|
||||
const before = descriptor(constructor);
|
||||
const lease = acquire(host);
|
||||
expect(lease.tier).toBe("absent");
|
||||
expect(probeModalKeyboardGuard(host).status).toBe("ready");
|
||||
expect(descriptor(constructor)).toEqual(before);
|
||||
lease.release();
|
||||
expect(descriptor(constructor)).toEqual(before);
|
||||
},
|
||||
);
|
||||
|
||||
it.each([{ configurable: false }, { writable: false }])(
|
||||
"refuses immutable shape %j",
|
||||
"uses DOM containment for formerly refused immutable initial shape %j",
|
||||
(flags) => {
|
||||
expect(acquireModalKeyboardGuard(fixture(null, flags).host).status).toBe(
|
||||
"unavailable",
|
||||
);
|
||||
const original = vi.fn(() => false);
|
||||
const { host, constructor } = fixture(original, flags);
|
||||
const before = descriptor(constructor);
|
||||
const lease = acquire(host);
|
||||
expect(lease.tier).toBe("absent");
|
||||
expect(descriptor(constructor)).toEqual(before);
|
||||
lease.release();
|
||||
expect(descriptor(constructor)).toEqual(before);
|
||||
expect(original).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -151,7 +162,13 @@ describe("callable modal keyboard guard", () => {
|
||||
get: staticGetter,
|
||||
});
|
||||
expect(acquireModalKeyboardGuard(accessorHost).status).toBe("unavailable");
|
||||
expect(acquireModalKeyboardGuard(host).status).toBe("unavailable");
|
||||
// A getter-only shape used to refuse; host DOM containment now permits mounting.
|
||||
const before = descriptor(constructor);
|
||||
const lease = acquire(host);
|
||||
expect(lease.tier).toBe("absent");
|
||||
expect(descriptor(constructor)).toEqual(before);
|
||||
lease.release();
|
||||
expect(descriptor(constructor)).toEqual(before);
|
||||
const throwing = new Proxy(
|
||||
{},
|
||||
{
|
||||
@@ -179,7 +196,7 @@ describe("callable modal keyboard guard", () => {
|
||||
expect(hook(target)).toBeNull();
|
||||
});
|
||||
|
||||
it("bounds prototype traversal and rejects inherited static fields", () => {
|
||||
it("bounds prototype traversal and uses DOM containment for formerly refused inherited static fields", () => {
|
||||
const { host, constructor } = fixture();
|
||||
let deep: object = host;
|
||||
for (let index = 0; index < 8; index += 1)
|
||||
@@ -187,10 +204,17 @@ describe("callable modal keyboard guard", () => {
|
||||
expect(acquireModalKeyboardGuard(deep).status).toBe("unavailable");
|
||||
const inherited = function InheritedConstructor() {};
|
||||
Object.setPrototypeOf(inherited, constructor);
|
||||
expect(
|
||||
acquireModalKeyboardGuard(Object.create({ constructor: inherited }))
|
||||
.status,
|
||||
).toBe("unavailable");
|
||||
const original = vi.fn(() => false);
|
||||
Reflect.set(constructor, "maskeditor_is_opended", original);
|
||||
const before = descriptor(constructor);
|
||||
const lease = acquire(Object.create({ constructor: inherited }) as object);
|
||||
expect(lease.tier).toBe("absent");
|
||||
expect(Object.hasOwn(inherited, "maskeditor_is_opended")).toBe(false);
|
||||
expect(descriptor(constructor)).toEqual(before);
|
||||
lease.release();
|
||||
expect(Object.hasOwn(inherited, "maskeditor_is_opended")).toBe(false);
|
||||
expect(descriptor(constructor)).toEqual(before);
|
||||
expect(original).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("refuses an accessor frozen during installation and deactivates the handed-out callable", () => {
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
admitAuthoringPrimaryAppend,
|
||||
NleAuthoringAssetBin,
|
||||
} from "../src/components/nle/NleAuthoringAssetBin";
|
||||
import { nleCopy } from "../src/components/nle/nleCopy";
|
||||
|
||||
afterEach(() => cleanup());
|
||||
|
||||
@@ -82,6 +83,48 @@ function emptyAuthoring(): NleAuthoringStateV2 {
|
||||
}
|
||||
|
||||
describe("NleAuthoringAssetBin", () => {
|
||||
it.each(["en", "zh-TW", "zh-CN"] as const)(
|
||||
"%s media hints name the thumbnail action the authoring bin renders",
|
||||
(locale) => {
|
||||
const text = nleCopy(locale);
|
||||
const clickThumbnail = {
|
||||
en: /Click.*thumbnail/,
|
||||
"zh-TW": /按一下.*縮圖/,
|
||||
"zh-CN": /点击.*缩略图/,
|
||||
}[locale];
|
||||
for (const hint of [text.monitor.emptyHint, text.timeline.emptyLane]) {
|
||||
expect(hint).not.toContain("+");
|
||||
expect(hint).toMatch(clickThumbnail);
|
||||
}
|
||||
const onIntent = vi.fn(async (_intent: AuthoringIntent) => undefined);
|
||||
const { container } = render(
|
||||
<NleAuthoringAssetBin
|
||||
locale={locale}
|
||||
authoring={emptyAuthoring()}
|
||||
highlightedAssetIds={[]}
|
||||
busy={false}
|
||||
runtimeEpoch={1}
|
||||
leaseClient={{} as AuthoringMediaSourceLeaseClient}
|
||||
currentFrame={() => 0}
|
||||
onIntent={onIntent}
|
||||
/>,
|
||||
);
|
||||
expect(container.querySelector(".h3-nle-media-add")).toBeNull();
|
||||
const card = container.querySelector<HTMLButtonElement>(
|
||||
".h3-nle-media-primary",
|
||||
)!;
|
||||
expect(card.disabled).toBe(false);
|
||||
fireEvent.click(card);
|
||||
expect(onIntent).toHaveBeenCalledTimes(1);
|
||||
expect(onIntent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
action: "apply_timeline_commands",
|
||||
commands: [expect.objectContaining({ kind: "insert_asset_clip" })],
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("appends exact 124-frame clips to primary content, not playhead or overlay extent", () => {
|
||||
const source: PublicCompositionAsset = {
|
||||
...video,
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
admitPrimaryAppend,
|
||||
NleMediaBin,
|
||||
} from "../src/components/nle/NleMediaBin";
|
||||
import { nleCopy } from "../src/components/nle/nleCopy";
|
||||
import {
|
||||
mediaBinProjection,
|
||||
mediaDurationPill,
|
||||
@@ -70,6 +71,48 @@ const asset = (
|
||||
});
|
||||
|
||||
describe("M25-48 media-bin model", () => {
|
||||
it.each(["en", "zh-TW", "zh-CN"] as const)(
|
||||
"%s media hints name the thumbnail action the fallback bin renders",
|
||||
(locale) => {
|
||||
const text = nleCopy(locale);
|
||||
const clickThumbnail = {
|
||||
en: /Click.*thumbnail/,
|
||||
"zh-TW": /按一下.*縮圖/,
|
||||
"zh-CN": /点击.*缩略图/,
|
||||
}[locale];
|
||||
for (const hint of [text.monitor.emptyHint, text.timeline.emptyLane]) {
|
||||
expect(hint).not.toContain("+");
|
||||
expect(hint).toMatch(clickThumbnail);
|
||||
}
|
||||
const onIntent = vi.fn(async (_intent: AuthoringIntent) => undefined);
|
||||
const { container } = render(
|
||||
<NleMediaBin
|
||||
locale={locale}
|
||||
snapshot={{ ...snapshotFixture(SMOKE_SHAPE), clips: [] }}
|
||||
highlightedAssetIds={[]}
|
||||
busy={false}
|
||||
runtimeEpoch={1}
|
||||
leaseClient={{} as AuthoringMediaSourceLeaseClient}
|
||||
currentFrame={() => 0}
|
||||
onIntent={onIntent}
|
||||
/>,
|
||||
);
|
||||
expect(container.querySelector(".h3-nle-media-add")).not.toBeNull();
|
||||
const card = container.querySelector<HTMLButtonElement>(
|
||||
".h3-nle-media-primary",
|
||||
)!;
|
||||
expect(card.disabled).toBe(false);
|
||||
fireEvent.click(card);
|
||||
expect(onIntent).toHaveBeenCalledTimes(1);
|
||||
expect(onIntent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
action: "apply_timeline_commands",
|
||||
commands: [expect.objectContaining({ kind: "insert_asset_clip" })],
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("admits primary Add at the primary content end, independent of playhead and overlays", () => {
|
||||
const original = snapshotFixture(SMOKE_SHAPE);
|
||||
const primary = original.tracks.find(
|
||||
|
||||
@@ -63,6 +63,11 @@ describe("workspace fixture retained source authority", () => {
|
||||
vi.spyOn(HTMLMediaElement.prototype, "pause").mockImplementation(
|
||||
() => undefined,
|
||||
);
|
||||
// The fixture hands a source over only at HAVE_METADATA, as the product does. jsdom never
|
||||
// loads media, so the element is presented as having metadata; this case is about rebind.
|
||||
vi.spyOn(HTMLMediaElement.prototype, "readyState", "get").mockReturnValue(
|
||||
HTMLMediaElement.HAVE_METADATA,
|
||||
);
|
||||
const first = binding();
|
||||
const source = await workspaceMediaClient.acquireVideoSource(
|
||||
first.request,
|
||||
|
||||
@@ -384,8 +384,9 @@ describe("M25-62 empty lane (A62-7)", () => {
|
||||
const zone = view.container.querySelector<HTMLElement>(
|
||||
"[data-h3-nle-empty-lane]",
|
||||
)!;
|
||||
// the bin's Add is the "+" on a thumbnail.
|
||||
expect(zone.textContent).toBe("Drag media here, or press + on a thumbnail");
|
||||
// Both media bins add from the thumbnail card.
|
||||
expect(zone.textContent).toBe("Click a thumbnail in Media to add it here");
|
||||
expect(zone.textContent).not.toContain("+");
|
||||
expect(zone.closest('[data-h3-nle-track="track-0"]')).not.toBeNull();
|
||||
expect(zone.getAttribute("aria-hidden")).toBeNull();
|
||||
expect(view.container.textContent).not.toContain(
|
||||
|
||||
@@ -1318,7 +1318,7 @@ describe("M25-64 monitor header and overlays", () => {
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("shows the empty-timeline overlay with a title, the + and drag hint, and no action", () => {
|
||||
it("shows the empty-timeline overlay with a title, the thumbnail-click hint, and no action", () => {
|
||||
monitorHarness();
|
||||
const view = render(
|
||||
<NleMonitor
|
||||
@@ -1344,9 +1344,9 @@ describe("M25-64 monitor header and overlays", () => {
|
||||
const hint = empty.querySelector(
|
||||
"[data-h3-nle-overlay-detail]",
|
||||
)!.textContent!;
|
||||
expect(hint).toContain("+");
|
||||
expect(hint).not.toContain("+");
|
||||
expect(hint).toContain("Media");
|
||||
expect(hint).toContain("drag");
|
||||
expect(hint).toMatch(/Click.*thumbnail/);
|
||||
expect(empty.querySelectorAll("button")).toHaveLength(0);
|
||||
expect(empty.querySelector("svg[aria-hidden='true']")).not.toBeNull();
|
||||
});
|
||||
|
||||
@@ -348,16 +348,16 @@ describe("M25-63 top bar and bin copy", () => {
|
||||
"B-M2563-11: the empty monitor points at the card's visible controls in %s",
|
||||
(locale) => {
|
||||
const copy = nleCopy(locale);
|
||||
// Since a card shows "+" and is dragged; "Add to timeline" is only in its context
|
||||
// menu. The hint names what the card shows, as the empty lane's hint does. moves the
|
||||
// monitor's hint to the empty-timeline overlay's key.
|
||||
for (const hint of [copy.monitor.emptyHint, copy.timeline.emptyLane])
|
||||
expect(hint, locale).toContain("+");
|
||||
// Both bins add from the thumbnail card; the authoring bin has no "+" control.
|
||||
for (const hint of [copy.monitor.emptyHint, copy.timeline.emptyLane]) {
|
||||
expect(hint, locale).not.toContain("+");
|
||||
expect(hint, locale).toMatch(
|
||||
/Click.*thumbnail|按一下.*縮圖|点击.*缩略图/u,
|
||||
);
|
||||
}
|
||||
expect(copy.monitor.emptyHint, locale).not.toContain(
|
||||
copy.assets.addToTimeline,
|
||||
);
|
||||
// "Drag" in each locale: the hint names both ways a card reaches the timeline.
|
||||
expect(copy.monitor.emptyHint, locale).toMatch(/drag|拖曳|拖到/u);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
withCompiledPackIdentity,
|
||||
hasSameCompiledMetadata,
|
||||
} from "./support/compiledMetadataFixture";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
@@ -73,7 +77,10 @@ function environment(
|
||||
mutateLoaded?.(visible);
|
||||
});
|
||||
const graphToPrompt = vi.fn().mockResolvedValue(compiled);
|
||||
const queuePrompt = vi.fn().mockResolvedValue(acceptedQueueResponse(31));
|
||||
const queuePrompt = vi.fn(
|
||||
async (_batch: number, _compiled: AppModeCompiledPrompt) =>
|
||||
acceptedQueueResponse(31),
|
||||
);
|
||||
const bound = fixtureBackedAppModeHost(
|
||||
{
|
||||
extensionManager: {
|
||||
@@ -119,7 +126,9 @@ function environment(
|
||||
|
||||
describe("M26-03 Production canonical graph lowering", () => {
|
||||
it("materializes, compiles and queues the one certified AuditOverride graph", async () => {
|
||||
const subject = environment();
|
||||
const compiled = withCompiledPackIdentity(compiledPreparedPrompt());
|
||||
const expectedCompiled = structuredClone(compiled);
|
||||
const subject = environment(compiled);
|
||||
await expect(
|
||||
createAppModeController(subject.app, subject.api, {
|
||||
loadProfile: loadAvailableProfile,
|
||||
@@ -182,6 +191,12 @@ describe("M26-03 Production canonical graph lowering", () => {
|
||||
expect(subject.onQueueAccepted).toHaveBeenCalledOnce();
|
||||
expect(subject.onQueueFailed).not.toHaveBeenCalled();
|
||||
expect(subject.queuePrompt).toHaveBeenCalledOnce();
|
||||
expect(
|
||||
hasSameCompiledMetadata(
|
||||
subject.queuePrompt.mock.calls[0]![1] as AppModeCompiledPrompt,
|
||||
expectedCompiled,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
||||
@@ -143,19 +143,16 @@ describe("M17-21 presentation redesign", () => {
|
||||
|
||||
describe("M17-22 host theme binding", () => {
|
||||
const lightSelector =
|
||||
":root:not([data-theme]):not(.dark-theme) body.litegraph";
|
||||
':root:not([data-theme]) .h3c[data-h3-host-theme="light"]';
|
||||
const lightBlock = css.slice(
|
||||
css.indexOf(lightSelector),
|
||||
css.indexOf(".h3n {"),
|
||||
);
|
||||
|
||||
it("activates the light palette on the host's own dark signal", () => {
|
||||
// ComfyUI 1.48.7 marks dark with `.dark-theme` on the root element and
|
||||
// treats bare `:root` as light; `body.litegraph` is the host marker that
|
||||
// keeps the offline/hermetic case on the accepted dark palette.
|
||||
expect(css).toContain(
|
||||
":root:not([data-theme]):not(.dark-theme) body.litegraph .h3c:not([data-theme])",
|
||||
);
|
||||
it("activates the light palette on the resolved host signal", () => {
|
||||
// The mounted probe covers both host signals; CSS must not reinterpret a missing class.
|
||||
expect(css).toContain(`${lightSelector}:not([data-theme])`);
|
||||
expect(css).not.toContain(":not(.dark-theme) body.litegraph");
|
||||
// The explicit overrides stay available to harnesses and tests.
|
||||
for (const selector of [
|
||||
'.h3c[data-theme="light"]',
|
||||
|
||||
@@ -7,6 +7,42 @@ import { SettingsPage } from "../src/components/SettingsPage";
|
||||
afterEach(cleanup);
|
||||
|
||||
describe("M17-12 sole local Settings page", () => {
|
||||
it.each(["en", "zh-TW", "zh-CN"] as const)(
|
||||
"%s presents the Traditional Chinese option and preserves its stored value",
|
||||
async (locale) => {
|
||||
const onWrite = vi.fn(async () => true);
|
||||
const { rerender } = render(
|
||||
<SettingsPage
|
||||
locale={locale}
|
||||
snapshot={{ status: "ready", value: "auto", pending: false }}
|
||||
onWrite={onWrite}
|
||||
/>,
|
||||
);
|
||||
const option = screen.getByRole("option", {
|
||||
name: /^正體中文$/,
|
||||
}) as HTMLOptionElement;
|
||||
expect(option.value).toBe("zh-TW");
|
||||
expect(screen.queryByRole("option", { name: /繁體/ })).toBeNull();
|
||||
const select = screen.getByRole("combobox") as HTMLSelectElement;
|
||||
await userEvent.selectOptions(select, option);
|
||||
expect(onWrite).toHaveBeenCalledExactlyOnceWith("zh-TW");
|
||||
rerender(
|
||||
<SettingsPage
|
||||
locale={locale}
|
||||
snapshot={{ status: "ready", value: "zh-TW", pending: false }}
|
||||
onWrite={onWrite}
|
||||
/>,
|
||||
);
|
||||
expect(select.value).toBe("zh-TW");
|
||||
expect(option.selected).toBe(true);
|
||||
expect(select.selectedOptions[0].textContent).toBe("正體中文");
|
||||
expect(screen.getByRole("option", { name: "简体中文" })).toHaveProperty(
|
||||
"value",
|
||||
"zh-CN",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("renders exactly one language row and commits only through the adapter", async () => {
|
||||
const onWrite = vi.fn(async () => true);
|
||||
const { container } = render(
|
||||
|
||||
@@ -54,6 +54,71 @@ function setStyleAwareWidth(element: HTMLElement, naturalWidth: number): void {
|
||||
}
|
||||
|
||||
describe("H3 sidebar width ownership", () => {
|
||||
for (const shape of ["prime", "reka"] as const) {
|
||||
for (const canvasState of ["zero", "one", "hidden", "absent"] as const) {
|
||||
if (shape === "reka" && canvasState === "absent") continue;
|
||||
for (const side of ["left", "left-compact", "right"] as const) {
|
||||
it(`${shape} ${side} owner uses splitter bounds with ${canvasState} canvas and an opposite panel`, () => {
|
||||
const onLeft = side !== "right";
|
||||
const splitter = document.createElement("div");
|
||||
if (shape === "prime") splitter.className = "p-splitter";
|
||||
setHorizontalBounds(splitter, 56, onLeft ? 650 : 620);
|
||||
const host = document.createElement("div");
|
||||
host.className = "side-bar-panel";
|
||||
setHorizontalBounds(
|
||||
host,
|
||||
onLeft ? 56 : 500,
|
||||
side === "left" ? 760 : side === "left-compact" ? 289 : 620,
|
||||
);
|
||||
const content = document.createElement("div");
|
||||
content.className = "sidebar-content-container";
|
||||
const mount = document.createElement("div");
|
||||
content.append(mount);
|
||||
host.append(content);
|
||||
const canvas = document.createElement("div");
|
||||
canvas.className = "graph-canvas-panel";
|
||||
setHorizontalBounds(canvas, 715, canvasState === "one" ? 716 : 715);
|
||||
if (canvasState === "hidden") {
|
||||
setHorizontalBounds(canvas, 300, 500);
|
||||
canvas.style.display = "none";
|
||||
}
|
||||
const opposite = document.createElement("div");
|
||||
opposite.className = "side-bar-panel";
|
||||
setHorizontalBounds(opposite, onLeft ? 600 : 56, onLeft ? 650 : 156);
|
||||
splitter.append(host, opposite);
|
||||
if (canvasState !== "absent") splitter.append(canvas);
|
||||
document.body.append(splitter);
|
||||
const previousInnerWidth = window.innerWidth;
|
||||
Object.defineProperty(window, "innerWidth", {
|
||||
configurable: true,
|
||||
value: 650,
|
||||
});
|
||||
let dispose: (() => void) | undefined;
|
||||
try {
|
||||
dispose = createSidebarWidthController(mount, {
|
||||
schedule: () => 0,
|
||||
cancel: () => undefined,
|
||||
});
|
||||
const expected = onLeft ? "544px" : "464px";
|
||||
for (const owner of [host, content, mount])
|
||||
expect(owner.style.minWidth).toBe(expected);
|
||||
expect(host.style.width).toBe(expected);
|
||||
expect(host.style.flexBasis).toBe(expected);
|
||||
expect(content.style.width).toBe("");
|
||||
expect(mount.style.width).toBe("");
|
||||
} finally {
|
||||
dispose?.();
|
||||
splitter.remove();
|
||||
Object.defineProperty(window, "innerWidth", {
|
||||
configurable: true,
|
||||
value: previousInnerWidth,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it("observes viewport-only resize and removes the owned listener on disposal", () => {
|
||||
const host = document.createElement("div");
|
||||
host.className = "side-bar-panel";
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { AppModeCompiledPrompt } from "../../src/host/appModeContract";
|
||||
|
||||
export function withCompiledPackIdentity<T extends AppModeCompiledPrompt>(
|
||||
compiled: T,
|
||||
): T {
|
||||
Object.values(compiled.output).forEach((value, index) => {
|
||||
const node = value as Record<string, unknown>;
|
||||
node._meta =
|
||||
index % 2 === 0
|
||||
? { title: "Node", cnr_id: "pack", ver: "1" }
|
||||
: { title: "Node", aux_id: "owner/pack", ver: "1" };
|
||||
});
|
||||
return compiled;
|
||||
}
|
||||
|
||||
export function hasSameCompiledMetadata(
|
||||
actual: AppModeCompiledPrompt,
|
||||
expected: AppModeCompiledPrompt,
|
||||
): boolean {
|
||||
return Object.entries(expected.output).every(
|
||||
([id, value]) =>
|
||||
JSON.stringify(
|
||||
(actual.output[id] as Record<string, unknown> | undefined)?._meta,
|
||||
) === JSON.stringify((value as Record<string, unknown>)._meta),
|
||||
);
|
||||
}
|
||||
@@ -37,6 +37,7 @@ export function requireHostHttpAvailability(status: number): void {
|
||||
}
|
||||
|
||||
export type FrontendHostSeamProbeResult = Readonly<{
|
||||
modalKeyboardTier: "data" | "accessor" | "absent" | "unavailable";
|
||||
observations: readonly HostSeamObservationWire[];
|
||||
nodeDefinitionCount: number;
|
||||
inspectionMilliseconds: number;
|
||||
@@ -178,19 +179,29 @@ export async function observeFrontendHostSeamsInPage(): Promise<FrontendHostSeam
|
||||
};
|
||||
// Each capability is independent: a throwing foreign canvas descriptor must not
|
||||
// turn a valid modal predicate into an invented missing capability, or vice versa.
|
||||
let modalKeyboardTier: FrontendHostSeamProbeResult["modalKeyboardTier"] =
|
||||
"unavailable";
|
||||
const modalKeyboardReady = keyboardShape(() => {
|
||||
const constructor = dataDescriptor(app, "constructor")?.value;
|
||||
if (typeof constructor !== "function") return false;
|
||||
const predicate =
|
||||
typeof constructor === "function"
|
||||
? Reflect.getOwnPropertyDescriptor(constructor, "maskeditor_is_opended")
|
||||
: undefined;
|
||||
return (
|
||||
modalKeyboardTier =
|
||||
predicate !== undefined &&
|
||||
"value" in predicate &&
|
||||
predicate.configurable === true &&
|
||||
predicate.writable === true &&
|
||||
(predicate.value === null || typeof predicate.value === "function")
|
||||
);
|
||||
? "data"
|
||||
: typeof predicate?.get === "function" &&
|
||||
typeof predicate.set === "function"
|
||||
? "accessor"
|
||||
: "absent";
|
||||
// The census row represents the guard capability, which includes DOM fallback.
|
||||
// Never call an unknown host getter merely to collect descriptor shape.
|
||||
return true;
|
||||
});
|
||||
const canvasOwner = (): unknown => {
|
||||
// CRITICAL: admit the same descriptor-only canvas shapes as canvasOwner() in
|
||||
@@ -332,6 +343,7 @@ export async function observeFrontendHostSeamsInPage(): Promise<FrontendHostSeam
|
||||
left.seam_id < right.seam_id ? -1 : left.seam_id > right.seam_id ? 1 : 0,
|
||||
);
|
||||
return {
|
||||
modalKeyboardTier,
|
||||
observations,
|
||||
nodeDefinitionCount:
|
||||
registry === undefined ? 0 : Object.keys(registry).length,
|
||||
|
||||
@@ -32,6 +32,34 @@ const FixtureDetachedGraph = function (serialized?: unknown): object {
|
||||
|
||||
const defaultCanvasKey: EventListener = () => undefined;
|
||||
|
||||
export type ModalKeyboardHostShape = "data" | "accessor" | "absent";
|
||||
type ModalHook = ((...args: unknown[]) => unknown) | null;
|
||||
|
||||
/** The new changeTracker reads this store directly, bypassing the constructor. */
|
||||
export function createModalKeyboardHost(
|
||||
shape: ModalKeyboardHostShape,
|
||||
original: ModalHook = null,
|
||||
) {
|
||||
const store = { predicate: original };
|
||||
class Host {
|
||||
static get maskeditor_is_opended(): ModalHook {
|
||||
return store.predicate;
|
||||
}
|
||||
static set maskeditor_is_opended(value: ModalHook) {
|
||||
store.predicate = value;
|
||||
}
|
||||
}
|
||||
if (shape === "data")
|
||||
Object.defineProperty(Host, "maskeditor_is_opended", {
|
||||
value: original,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
else if (shape === "absent")
|
||||
Reflect.deleteProperty(Host, "maskeditor_is_opended");
|
||||
return { host: new Host(), constructor: Host, store };
|
||||
}
|
||||
|
||||
function cloneFixtureApp<App extends object>(
|
||||
source: App,
|
||||
overrides: object,
|
||||
@@ -65,16 +93,14 @@ function cloneFixtureApp<App extends object>(
|
||||
return cloned;
|
||||
}
|
||||
|
||||
function withKeyboardCapabilities<App extends object>(source: App): App {
|
||||
function withKeyboardCapabilities<App extends object>(
|
||||
source: App,
|
||||
shape: ModalKeyboardHostShape = "data",
|
||||
): App {
|
||||
const cloned = cloneFixtureApp(source, {});
|
||||
if (Object.getPrototypeOf(source) !== Object.prototype) return cloned;
|
||||
if (Object.getOwnPropertyDescriptor(source, "constructor") === undefined) {
|
||||
const constructor = function FixtureAppConstructor() {};
|
||||
Object.defineProperty(constructor, "maskeditor_is_opended", {
|
||||
value: null,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
const { constructor } = createModalKeyboardHost(shape);
|
||||
Object.defineProperty(cloned, "constructor", {
|
||||
value: constructor,
|
||||
configurable: true,
|
||||
@@ -223,6 +249,7 @@ export function fixtureBackedAppModeHost<
|
||||
app: App,
|
||||
api: Api,
|
||||
options: Readonly<{
|
||||
modalKeyboardShape?: ModalKeyboardHostShape;
|
||||
workflowVariant?:
|
||||
HostWorkflowBehaviourVariantId | HostWorkflowBehaviourFixture;
|
||||
}> = {},
|
||||
@@ -237,7 +264,10 @@ export function fixtureBackedAppModeHost<
|
||||
: typeof options.workflowVariant === "string"
|
||||
? createHostWorkflowBehaviourFixture(options.workflowVariant)
|
||||
: options.workflowVariant;
|
||||
const keyboardBoundApp = withKeyboardCapabilities(app);
|
||||
const keyboardBoundApp = withKeyboardCapabilities(
|
||||
app,
|
||||
options.modalKeyboardShape,
|
||||
);
|
||||
const variantBoundApp = (
|
||||
workflowBehaviour === undefined
|
||||
? keyboardBoundApp
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
"path": "frontend/src/entry.tsx"
|
||||
}
|
||||
],
|
||||
"fingerprint": "sha256:ef90ef7571ffd24276ecca2bba9fd80b15545671e25a4c97304d137b936f4add",
|
||||
"fingerprint": "sha256:1ad6fda27b0c4d1a6e0e1c04571ff2e58552c414765a6a2955598d3c0349b1b8",
|
||||
"known_violations": [],
|
||||
"modules": [
|
||||
{
|
||||
@@ -9279,6 +9279,7 @@
|
||||
"frontend/src/host/authoringFrameCoordinator.ts",
|
||||
"frontend/src/host/buildProvenanceClient.ts",
|
||||
"frontend/src/host/durationResolutionClient.ts",
|
||||
"frontend/src/host/hostTheme.ts",
|
||||
"frontend/src/host/imageCropContract.ts",
|
||||
"frontend/src/host/languageSettings.ts",
|
||||
"frontend/src/host/productionMediaPreview.ts",
|
||||
@@ -9301,7 +9302,7 @@
|
||||
"frontend/src/state/sidebarWorkspace.ts"
|
||||
],
|
||||
"language": "typescript",
|
||||
"lines": 1945,
|
||||
"lines": 1958,
|
||||
"path": "frontend/src/components/H3Sidebar.tsx",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
@@ -9332,12 +9333,13 @@
|
||||
{
|
||||
"imports": [
|
||||
"frontend/src/host/hostSeams.ts",
|
||||
"frontend/src/host/hostTheme.ts",
|
||||
"frontend/src/host/imageCropGeometry.ts",
|
||||
"frontend/src/host/imageCropSource.ts",
|
||||
"frontend/src/i18n/catalog.ts"
|
||||
],
|
||||
"language": "typescript",
|
||||
"lines": 421,
|
||||
"lines": 427,
|
||||
"path": "frontend/src/components/ImageCropDialog.tsx",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
@@ -9791,7 +9793,7 @@
|
||||
{
|
||||
"imports": [],
|
||||
"language": "typescript",
|
||||
"lines": 601,
|
||||
"lines": 623,
|
||||
"path": "frontend/src/components/nle/NleIconActions.tsx",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
@@ -9947,11 +9949,12 @@
|
||||
"frontend/src/components/nle/nleCopy.ts",
|
||||
"frontend/src/components/nle/nleMonitorChannel.ts",
|
||||
"frontend/src/components/nle/nleWorkspaceBinding.ts",
|
||||
"frontend/src/host/hostTheme.ts",
|
||||
"frontend/src/runtime/nleSaveIndicator.ts",
|
||||
"frontend/src/state/nleWorkspaceState.ts"
|
||||
],
|
||||
"language": "typescript",
|
||||
"lines": 680,
|
||||
"lines": 683,
|
||||
"path": "frontend/src/components/nle/NleOverlay.tsx",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
@@ -10501,7 +10504,7 @@
|
||||
"frontend/src/i18n/catalog.ts"
|
||||
],
|
||||
"language": "typescript",
|
||||
"lines": 2123,
|
||||
"lines": 2122,
|
||||
"path": "frontend/src/components/nle/nleCopy.ts",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
@@ -11724,6 +11727,7 @@
|
||||
"frontend/src/host/appModeRoutes.ts",
|
||||
"frontend/src/host/appModeTemplateSources.ts",
|
||||
"frontend/src/host/canvasOwnedWrite.ts",
|
||||
"frontend/src/host/compiledMetadata.ts",
|
||||
"frontend/src/host/generationProfileClient.ts",
|
||||
"frontend/src/host/graphAdapter.ts",
|
||||
"frontend/src/host/graphSerialization.ts",
|
||||
@@ -11736,7 +11740,7 @@
|
||||
"frontend/src/host/templateMaterialization.ts"
|
||||
],
|
||||
"language": "typescript",
|
||||
"lines": 1200,
|
||||
"lines": 1197,
|
||||
"path": "frontend/src/host/appMode.ts",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
@@ -11806,6 +11810,7 @@
|
||||
"imports": [
|
||||
"frontend/src/contracts/canonicalFingerprint.ts",
|
||||
"frontend/src/contracts/generationProfileCodec.ts",
|
||||
"frontend/src/host/compiledMetadata.ts",
|
||||
"frontend/src/host/graphAdapter.ts",
|
||||
"frontend/src/host/imageCropContract.ts",
|
||||
"frontend/src/host/inputGeometry.ts",
|
||||
@@ -11816,7 +11821,7 @@
|
||||
"frontend/src/host/templateMaterialization.ts"
|
||||
],
|
||||
"language": "typescript",
|
||||
"lines": 1185,
|
||||
"lines": 1177,
|
||||
"path": "frontend/src/host/appModeContract.ts",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
@@ -12262,6 +12267,20 @@
|
||||
"retained_reason": "reachable from a shipped entry point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"imports": [],
|
||||
"language": "typescript",
|
||||
"lines": 56,
|
||||
"path": "frontend/src/host/compiledMetadata.ts",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
"evidence": "product_closure",
|
||||
"owners": [
|
||||
"frontend/src/entry.tsx"
|
||||
],
|
||||
"retained_reason": "reachable from a shipped entry point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"imports": [
|
||||
"frontend/src/contracts/generatedDurationResolution.ts"
|
||||
@@ -12508,6 +12527,20 @@
|
||||
"retained_reason": "reachable from a shipped entry point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"imports": [],
|
||||
"language": "typescript",
|
||||
"lines": 40,
|
||||
"path": "frontend/src/host/hostTheme.ts",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
"evidence": "product_closure",
|
||||
"owners": [
|
||||
"frontend/src/entry.tsx"
|
||||
],
|
||||
"retained_reason": "reachable from a shipped entry point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"imports": [
|
||||
"frontend/src/host/appModeContract.ts",
|
||||
@@ -12774,7 +12807,7 @@
|
||||
"frontend/src/host/hostSeams.ts"
|
||||
],
|
||||
"language": "typescript",
|
||||
"lines": 161,
|
||||
"lines": 331,
|
||||
"path": "frontend/src/host/modalKeyboardGuard.ts",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
@@ -13272,7 +13305,7 @@
|
||||
{
|
||||
"imports": [],
|
||||
"language": "typescript",
|
||||
"lines": 440,
|
||||
"lines": 485,
|
||||
"path": "frontend/src/host/sidebarWidth.ts",
|
||||
"source_reachability": {
|
||||
"class": "product",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"modules": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"maxItems": 640,
|
||||
"maxItems": 704,
|
||||
"items": { "$ref": "#/$defs/module" }
|
||||
},
|
||||
"entrypoints": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -27,7 +27,7 @@
|
||||
},
|
||||
{
|
||||
"path": "comfyui_h3_context/contracts/build_provenance_v1.json",
|
||||
"sha256": "sha256:b60486a8ce56f42ad693c28f57620d2ee067131542313498f31eaefb33c0dc41",
|
||||
"sha256": "sha256:07ee43a95cb59878e2d682898d18833a920fd5fc7b51434ca9fac77ca98995d4",
|
||||
"size": 1712
|
||||
},
|
||||
{
|
||||
@@ -42,7 +42,7 @@
|
||||
},
|
||||
{
|
||||
"path": "comfyui_h3_context/contracts/installation_profiles_v1.json",
|
||||
"sha256": "sha256:8216050601bcbaec1f6918af57fe17c7474c84c81a78e01679cedae667539d14",
|
||||
"sha256": "sha256:dad55125741921f0a363a4351ff2778cce31142c5a63a7559fa9e5f722a8a2b9",
|
||||
"size": 3377
|
||||
},
|
||||
{
|
||||
@@ -67,7 +67,7 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/package.json",
|
||||
"sha256": "sha256:37d9fedc657dbb574d1cac664a7455b0c1251c9a9d9f5ee2023ab1feb9dabc04",
|
||||
"sha256": "sha256:aa528082e76c69e91c28ceb23a5a32278aba9711047cacdb1595f412730e6f3d",
|
||||
"size": 1307
|
||||
},
|
||||
{
|
||||
@@ -107,8 +107,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/H3Sidebar.tsx",
|
||||
"sha256": "sha256:cc8f32b9b702a24605e4c35654ee9eea862635a80f4b25c9fcfbe9ddba210cec",
|
||||
"size": 72381
|
||||
"sha256": "sha256:958cb5827e456d9940032d4d2bb531dcba30692fe1a4b1ff0fe1d053bda6254b",
|
||||
"size": 72672
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/ImageCropAction.tsx",
|
||||
@@ -117,8 +117,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/ImageCropDialog.tsx",
|
||||
"sha256": "sha256:204af55e84ff617f8b287340e2fd0288a9caf7ff8fc2cffe54f5ae0ad3836c00",
|
||||
"size": 14128
|
||||
"sha256": "sha256:993419b6ff43e39a8dbd0c8bbec3483551b4b0ac1e8aea1f2bd531a9ca26d838",
|
||||
"size": 14388
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/MediaToolsCard.tsx",
|
||||
@@ -182,7 +182,7 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/SettingsPage.tsx",
|
||||
"sha256": "sha256:5289bd4a11b611a32d968dbfbb026b6b45bf69c82273bd28a819d1d0f2084d7c",
|
||||
"sha256": "sha256:851cffa347c489a871bd67f66d5c30f0ec67f652851079727b69b9a97b2ba6af",
|
||||
"size": 6502
|
||||
},
|
||||
{
|
||||
@@ -237,8 +237,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/nle/NleIconActions.tsx",
|
||||
"sha256": "sha256:d1cec4d2a02cad389e7302ed627651cd96c0953ba0a22f10ee46a1711589a499",
|
||||
"size": 20098
|
||||
"sha256": "sha256:87484d1039c04b0d333a8c3d71613fc288a16c2a21e43943455067253ff39d39",
|
||||
"size": 21179
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/nle/NleInspectorTabs.tsx",
|
||||
@@ -267,8 +267,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/nle/NleOverlay.tsx",
|
||||
"sha256": "sha256:864fac8d6bd8150febcc0a20bfadbb4b08ab613ff351279e72f990e8b01f29b5",
|
||||
"size": 25407
|
||||
"sha256": "sha256:e8bbfa29c02fd4e81b1ee29817e403f3f39aafd800bf6123f7abb4527d75c8cf",
|
||||
"size": 25553
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/nle/NlePlanningSection.tsx",
|
||||
@@ -387,8 +387,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/nle/nleCopy.ts",
|
||||
"sha256": "sha256:948d940f4d77feae8670bdaa51e8a61d246170aa4e6407f775f345c666c56757",
|
||||
"size": 92204
|
||||
"sha256": "sha256:03e761d8b2b623c34722a43f47abc2da105509bff1d6e1720e3071fe698b89cb",
|
||||
"size": 92183
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/components/nle/nleMediaBinModel.ts",
|
||||
@@ -727,8 +727,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/appMode.ts",
|
||||
"sha256": "sha256:69ad4c28f0a33e8c5135676ae1bb49184f48e6ce36d253380ab158c68874a931",
|
||||
"size": 43629
|
||||
"sha256": "sha256:438b22486c83ae500098cedcbb2406e21a1f1cd8ca18229fcc577c9b0b1ea857",
|
||||
"size": 43532
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/appModeAdmission.ts",
|
||||
@@ -747,8 +747,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/appModeContract.ts",
|
||||
"sha256": "sha256:5a7fdf48a7e66a6352f8470515a85d49420bba7a0c1ed161f3c06bae28af9c83",
|
||||
"size": 40752
|
||||
"sha256": "sha256:bf41b6585721d0dbe9bf231a1ed8d9082b589cd3438130e5244a2cb0ced09e9e",
|
||||
"size": 40503
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/appModeExistingRoute.ts",
|
||||
@@ -865,6 +865,11 @@
|
||||
"sha256": "sha256:7c2464b9578e71c4b8a22976f6a56f9eb97ec50d98375907b50df7b8493c7d1c",
|
||||
"size": 11950
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/compiledMetadata.ts",
|
||||
"sha256": "sha256:a18c99ba64b8cb885a0e9a86cd93459026fcf5b2374eaeccd357a2636380a937",
|
||||
"size": 1947
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/durationResolutionClient.ts",
|
||||
"sha256": "sha256:223c1a16583a677c4e2a20e231957d4ed78151d8a4cabae8c88e81a01f4141d5",
|
||||
@@ -940,6 +945,11 @@
|
||||
"sha256": "sha256:4649306f6a9fc9c1d3965fd39b8af2b2eaca9b1660899bc85b5f757bb9399398",
|
||||
"size": 12770
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/hostTheme.ts",
|
||||
"sha256": "sha256:6e9a61b8ad0020176b339a09525f439ce86f7a8f77c8788740aea95e8c50601b",
|
||||
"size": 1768
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/imageCropBindings.ts",
|
||||
"sha256": "sha256:0f4b8a9fac05524f826fc35add0d3d7f9fcb1a7744c0327694ec3b52bb5c50dd",
|
||||
@@ -1017,8 +1027,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/modalKeyboardGuard.ts",
|
||||
"sha256": "sha256:d1d06bdb29b442a5bd75c89cdbfd4a8428e65ab3c079dfd269f2a4ea9543f0e2",
|
||||
"size": 5106
|
||||
"sha256": "sha256:3d97965de37387575d53e5afacad27ddbf68944abaeba969655d55507847c664",
|
||||
"size": 10876
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/nleAudioPeaksCache.ts",
|
||||
@@ -1162,8 +1172,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/sidebarWidth.ts",
|
||||
"sha256": "sha256:54832dc1b8ee5ea7e6de8fcec8b6e7a3475b24bd3630178b821964b98569e496",
|
||||
"size": 15041
|
||||
"sha256": "sha256:96537a9e7ae6d6735f424c8931ca6206a56d520afbc49d962c0f17a245fdf287",
|
||||
"size": 16713
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/host/surroundingsDiff.ts",
|
||||
@@ -1547,8 +1557,8 @@
|
||||
},
|
||||
{
|
||||
"path": "frontend/src/styles/tokens.css",
|
||||
"sha256": "sha256:6135398872cd3a70cfe6ba46f0b9e3f6aad128376f11bc83c9cafa0f62bca103",
|
||||
"size": 85446
|
||||
"sha256": "sha256:a12347cccd25a5aed0fcf453c987e4e9ae73aaccdad9de9d493d5fb9201025cf",
|
||||
"size": 85082
|
||||
},
|
||||
{
|
||||
"path": "frontend/tsconfig.json",
|
||||
@@ -1572,7 +1582,7 @@
|
||||
},
|
||||
{
|
||||
"path": "governance/contracts/sbom.spdx.json",
|
||||
"sha256": "sha256:d06762d9daf39f35728c60464181600f93bda6bb16ed2bf913410030ce1805b9",
|
||||
"sha256": "sha256:f48fe99a84b9c35c4658a082cdb2765d9b63f30824fe2b5ca3050a2e7ee756e6",
|
||||
"size": 80662
|
||||
},
|
||||
{
|
||||
@@ -1582,8 +1592,8 @@
|
||||
},
|
||||
{
|
||||
"path": "pyproject.toml",
|
||||
"sha256": "sha256:56a81f088763b3a26ede0950d63e5b6e4364bdd58128da38ae46ca1ea2cd2753",
|
||||
"size": 4112
|
||||
"sha256": "sha256:afa424335ed50770fe66a296ada52cdf3d25833d1dc4616609fa0b756c9af1b9",
|
||||
"size": 4080
|
||||
},
|
||||
{
|
||||
"path": "scripts/public_build_backend.py",
|
||||
@@ -1605,15 +1615,15 @@
|
||||
"runtime_entries": [
|
||||
{
|
||||
"path": "comfyui_h3_context/web/h3-context-sidebar.js",
|
||||
"sha256": "sha256:a67420d0c60f13801603f4898610d789270e296c3d713f63e2ec02244bea8fe7",
|
||||
"size": 1970766
|
||||
"sha256": "sha256:e437955793c7eb29f2c32af62ff00c1bbc74915d7d99f80a988a0506d5f1630c",
|
||||
"size": 1974807
|
||||
}
|
||||
],
|
||||
"schema": "h3-context-supply-chain/1",
|
||||
"spdx": {
|
||||
"package_count": 176,
|
||||
"path": "governance/contracts/sbom.spdx.json",
|
||||
"sha256": "sha256:d06762d9daf39f35728c60464181600f93bda6bb16ed2bf913410030ce1805b9",
|
||||
"sha256": "sha256:f48fe99a84b9c35c4658a082cdb2765d9b63f30824fe2b5ca3050a2e7ee756e6",
|
||||
"version": "SPDX-2.3"
|
||||
},
|
||||
"version": 1
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@ backend-path = ["."]
|
||||
|
||||
[project]
|
||||
name = "minimax-h3-studio"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
description = "Turn a description into a finished MiniMax H3 video without leaving ComfyUI, prompt, segments, continuity and final cut in one workbench."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
@@ -20,14 +20,14 @@ classifiers = [
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/rookiestar28/ComfyUI-MiniMaxH3-Studio"
|
||||
Documentation = "https://github.com/rookiestar28/ComfyUI-MiniMaxH3-Studio/tree/main/docs"
|
||||
"Bug Tracker" = "https://github.com/rookiestar28/ComfyUI-MiniMaxH3-Studio/issues"
|
||||
Repository = "https://github.com/rookiestar28/MiniMaxH3-Studio"
|
||||
Documentation = "https://github.com/rookiestar28/MiniMaxH3-Studio/tree/main/docs"
|
||||
"Bug Tracker" = "https://github.com/rookiestar28/MiniMaxH3-Studio/issues"
|
||||
|
||||
[tool.comfy]
|
||||
PublisherId = "rookiestar"
|
||||
DisplayName = "ComfyUI-MiniMaxH3-Studio"
|
||||
Icon = "https://raw.githubusercontent.com/rookiestar28/ComfyUI-MiniMaxH3-Studio/main/assets/h3_context.svg"
|
||||
Icon = "https://raw.githubusercontent.com/rookiestar28/MiniMaxH3-Studio/main/assets/h3_context.svg"
|
||||
includes = [
|
||||
"__init__.py",
|
||||
"comfyui_h3_context",
|
||||
|
||||
@@ -241,7 +241,7 @@
|
||||
{
|
||||
"type": "Hex High Entropy String",
|
||||
"filename": "comfyui_h3_context\\contracts\\build_provenance_v1.json",
|
||||
"hashed_secret": "8c761d0debdc5d29c77c382f20216c0eca774c96",
|
||||
"hashed_secret": "c9c8dd1f63f966530fd3fd8e3eedc817e2fdeb1b",
|
||||
"is_verified": false,
|
||||
"line_number": 15,
|
||||
"is_secret": false
|
||||
@@ -249,7 +249,7 @@
|
||||
{
|
||||
"type": "Hex High Entropy String",
|
||||
"filename": "comfyui_h3_context\\contracts\\build_provenance_v1.json",
|
||||
"hashed_secret": "290ca60a9b6230e516284629299c75225169d5c7",
|
||||
"hashed_secret": "86292954cac7ae9ac2c883d9dc616d0cf10b1380",
|
||||
"is_verified": false,
|
||||
"line_number": 17,
|
||||
"is_secret": false
|
||||
|
||||
@@ -25,7 +25,9 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
ARTIFACT_PATH = Path("governance/contracts/architecture_fitness_v1.json")
|
||||
SCHEMA_ID = "h3-context-architecture-fitness/1"
|
||||
MAX_SOURCE_BYTES = 4 * 1024 * 1024
|
||||
MAX_MODULES = 640
|
||||
# IMPORTANT: runaway-scan protection grows in 64-module blocks; schema maxItems must match.
|
||||
# Overflow still refuses; exact membership is pinned by the generated contract and owner-count test.
|
||||
MAX_MODULES = 704
|
||||
|
||||
ROUTE_RESPONSIBILITIES = ("application", "decode", "domain", "response", "store")
|
||||
|
||||
|
||||
@@ -124,6 +124,194 @@ def boot_diagnostic(value: Any) -> dict[str, Any]:
|
||||
return result
|
||||
|
||||
|
||||
OPEN_DIAGNOSTICS_NAME = "integrated-shell-open-diagnostics"
|
||||
OPEN_MONITOR_STATES = {
|
||||
"closed",
|
||||
"opening",
|
||||
"paused",
|
||||
"playing",
|
||||
"closing",
|
||||
"blocked",
|
||||
"cleanup_pending",
|
||||
"fallback",
|
||||
"absent",
|
||||
"unknown",
|
||||
}
|
||||
OPEN_BLOCKERS = {
|
||||
"source_unavailable",
|
||||
"canvas_unavailable",
|
||||
"invalid_contract",
|
||||
"resource_limit",
|
||||
"unknown",
|
||||
}
|
||||
OPEN_REQUEST_LABELS = {
|
||||
"media:video",
|
||||
"media:image",
|
||||
"media:font",
|
||||
"media:audio",
|
||||
"media:other",
|
||||
"fixture:bootstrap",
|
||||
"fixture:transaction",
|
||||
}
|
||||
OPEN_TOKEN = re.compile(r"[a-z][a-z0-9_-]{0,47}")
|
||||
OPEN_LIMIT = 1_000_000
|
||||
|
||||
|
||||
def open_diagnostic(value: Any) -> dict[str, Any]:
|
||||
"""Re-derive the integrated-shell open facts from closed shapes only.
|
||||
|
||||
The frontend writer is `frontend/tests/e2e/helpers/integratedShellDiagnostics.ts`; change both
|
||||
together. Every value is an enum, a code token, a boolean or a bounded number, so no URL,
|
||||
path, host, query or copy text can pass.
|
||||
"""
|
||||
keys = {
|
||||
"elapsedMs",
|
||||
"monitor",
|
||||
"blocker",
|
||||
"fallback",
|
||||
"overlays",
|
||||
"playDisabled",
|
||||
"presentedFrame",
|
||||
"timelineReady",
|
||||
"audioState",
|
||||
"audioReason",
|
||||
"surface",
|
||||
"ownership",
|
||||
"preparation",
|
||||
"videos",
|
||||
"requests",
|
||||
"requestsOmitted",
|
||||
"pageErrors",
|
||||
"consoleErrors",
|
||||
"consoleWarnings",
|
||||
}
|
||||
if not isinstance(value, dict) or set(value) != keys:
|
||||
raise ValueError("malformed open diagnostics")
|
||||
|
||||
def flag(item: Any, nullable: bool = False) -> bool | None:
|
||||
if item is None and nullable:
|
||||
return None
|
||||
if type(item) is not bool:
|
||||
raise ValueError("open diagnostic flags must be booleans")
|
||||
return item
|
||||
|
||||
def count(item: Any) -> int:
|
||||
if type(item) is not int or not 0 <= item <= OPEN_LIMIT:
|
||||
raise ValueError("open diagnostic counts must be bounded nonnegative integers")
|
||||
return item
|
||||
|
||||
def clock(item: Any, nullable: bool = False) -> float | int | None:
|
||||
if item is None and nullable:
|
||||
return None
|
||||
if (
|
||||
type(item) not in (int, float)
|
||||
or not math.isfinite(item)
|
||||
or not -600_000 <= item <= 600_000
|
||||
):
|
||||
raise ValueError("open diagnostic clocks must be bounded finite numbers")
|
||||
number: float | int = item
|
||||
return number
|
||||
|
||||
def code(item: Any) -> str | None:
|
||||
if item is None:
|
||||
return None
|
||||
if not isinstance(item, str) or not OPEN_TOKEN.fullmatch(item):
|
||||
raise ValueError("open diagnostic codes must be closed tokens")
|
||||
return item
|
||||
|
||||
def record(item: Any, fields: tuple[str, ...]) -> dict[str, int] | None:
|
||||
if item is None:
|
||||
return None
|
||||
if not isinstance(item, dict) or set(item) != set(fields):
|
||||
raise ValueError("malformed open diagnostic counters")
|
||||
return {field: count(item[field]) for field in fields}
|
||||
|
||||
if value["monitor"] not in OPEN_MONITOR_STATES:
|
||||
raise ValueError("open diagnostic monitor state is not closed")
|
||||
if value["blocker"] is not None and value["blocker"] not in OPEN_BLOCKERS:
|
||||
raise ValueError("open diagnostic blocker is not closed")
|
||||
overlays = value["overlays"]
|
||||
if not isinstance(overlays, list) or len(overlays) > 4:
|
||||
raise ValueError("open diagnostic overlays must be bounded")
|
||||
videos = value["videos"]
|
||||
if not isinstance(videos, list) or len(videos) > 8:
|
||||
raise ValueError("open diagnostic videos must be bounded")
|
||||
requests = value["requests"]
|
||||
if not isinstance(requests, list) or len(requests) > 64:
|
||||
raise ValueError("open diagnostic requests must be bounded")
|
||||
result: dict[str, Any] = {
|
||||
"elapsedMs": clock(value["elapsedMs"]),
|
||||
"monitor": value["monitor"],
|
||||
"blocker": value["blocker"],
|
||||
"fallback": code(value["fallback"]),
|
||||
"overlays": [code(item) for item in overlays],
|
||||
"playDisabled": flag(value["playDisabled"], nullable=True),
|
||||
"presentedFrame": flag(value["presentedFrame"]),
|
||||
"timelineReady": flag(value["timelineReady"]),
|
||||
"audioState": code(value["audioState"]),
|
||||
"audioReason": code(value["audioReason"]),
|
||||
"surface": code(value["surface"]),
|
||||
"ownership": record(
|
||||
value["ownership"],
|
||||
(
|
||||
"leaseOpens",
|
||||
"sourceAcquired",
|
||||
"sourceLive",
|
||||
"acquisitionAttempts",
|
||||
"acquisitionsInFlight",
|
||||
"videoElements",
|
||||
),
|
||||
),
|
||||
"preparation": record(
|
||||
value["preparation"], ("attempts", "inFlight", "aborted", "released")
|
||||
),
|
||||
"videos": [],
|
||||
"requests": [],
|
||||
"requestsOmitted": count(value["requestsOmitted"]),
|
||||
"pageErrors": count(value["pageErrors"]),
|
||||
"consoleErrors": count(value["consoleErrors"]),
|
||||
"consoleWarnings": count(value["consoleWarnings"]),
|
||||
}
|
||||
if None in result["overlays"]:
|
||||
raise ValueError("open diagnostic overlays must be closed tokens")
|
||||
video_keys = {"readyState", "networkState", "seeking", "paused", "currentTimeMs", "errorCode"}
|
||||
for video in videos:
|
||||
if not isinstance(video, dict) or set(video) != video_keys:
|
||||
raise ValueError("malformed open diagnostic video")
|
||||
result["videos"].append(
|
||||
{
|
||||
"readyState": count(video["readyState"]),
|
||||
"networkState": count(video["networkState"]),
|
||||
"seeking": flag(video["seeking"]),
|
||||
"paused": flag(video["paused"]),
|
||||
"currentTimeMs": count(video["currentTimeMs"]),
|
||||
"errorCode": count(video["errorCode"]),
|
||||
}
|
||||
)
|
||||
request_keys = {"label", "startMs", "endMs", "status", "outcome"}
|
||||
for row in requests:
|
||||
if (
|
||||
not isinstance(row, dict)
|
||||
or set(row) != request_keys
|
||||
or row["label"] not in OPEN_REQUEST_LABELS
|
||||
or row["outcome"] not in ("ok", "failed", "aborted", "pending")
|
||||
):
|
||||
raise ValueError("malformed open diagnostic request")
|
||||
status = row["status"]
|
||||
if status is not None and (type(status) is not int or not 100 <= status <= 599):
|
||||
raise ValueError("open diagnostic request status must be an HTTP status")
|
||||
result["requests"].append(
|
||||
{
|
||||
"label": row["label"],
|
||||
"startMs": clock(row["startMs"]),
|
||||
"endMs": clock(row["endMs"], nullable=True),
|
||||
"status": status,
|
||||
"outcome": row["outcome"],
|
||||
}
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def server_event(line: str) -> dict[str, str] | None:
|
||||
text = ANSI.sub("", line)
|
||||
if "[WebServer]" not in text or "[vite]" not in text:
|
||||
@@ -536,6 +724,26 @@ def sanitize_report(report: Any) -> dict[str, Any]:
|
||||
).decode(),
|
||||
}
|
||||
)
|
||||
if (
|
||||
attachment.get("name") == OPEN_DIAGNOSTICS_NAME
|
||||
and attachment.get("contentType") == "application/json"
|
||||
and "body" in attachment
|
||||
and "path" not in attachment
|
||||
):
|
||||
# CRITICAL: only the closed open facts pass; the validator re-derives every value
|
||||
# and refuses free text, so no URL, path or copy text reaches the public artifact.
|
||||
facts = open_diagnostic(
|
||||
json.loads(base64.b64decode(attachment["body"], validate=True))
|
||||
)
|
||||
result["attachments"].append(
|
||||
{
|
||||
"name": attachment["name"],
|
||||
"contentType": "application/json",
|
||||
"body": base64.b64encode(
|
||||
json.dumps(facts, allow_nan=False).encode()
|
||||
).decode("ascii"),
|
||||
}
|
||||
)
|
||||
if (
|
||||
attachment.get("name") == "harness-boot-diagnostics"
|
||||
and attachment.get("contentType") == "application/json"
|
||||
|
||||
@@ -26,13 +26,15 @@ EXPECTED_NAME = "minimax-h3-studio"
|
||||
EXPECTED_AUTHOR = "rookiestar28"
|
||||
EXPECTED_PUBLISHER = "rookiestar"
|
||||
EXPECTED_DISPLAY_NAME = "ComfyUI-MiniMaxH3-Studio"
|
||||
EXPECTED_REPOSITORY = "https://github.com/rookiestar28/ComfyUI-MiniMaxH3-Studio"
|
||||
EXPECTED_REPOSITORY = "https://github.com/rookiestar28/MiniMaxH3-Studio"
|
||||
EXPECTED_CLASSIFIERS = [
|
||||
"Operating System :: Microsoft :: Windows",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Programming Language :: Python :: 3",
|
||||
]
|
||||
EXPECTED_ICON_URL = "https://raw.githubusercontent.com/rookiestar28/ComfyUI-MiniMaxH3-Studio/main/assets/h3_context.svg"
|
||||
EXPECTED_ICON_URL = (
|
||||
"https://raw.githubusercontent.com/rookiestar28/MiniMaxH3-Studio/main/assets/h3_context.svg"
|
||||
)
|
||||
EXPECTED_INCLUDES = frozenset(
|
||||
{
|
||||
"__init__.py",
|
||||
|
||||
+2
-2
@@ -2,13 +2,13 @@
|
||||
"schema": "h3-context-release-matrix/1",
|
||||
"package": {
|
||||
"name": "minimax-h3-studio",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"author": "rookiestar28",
|
||||
"dependencies": []
|
||||
},
|
||||
"artifact": {
|
||||
"required": ["wheel", "sdist"],
|
||||
"prefix": "minimax_h3_studio-1.4.0",
|
||||
"prefix": "minimax_h3_studio-1.4.1",
|
||||
"forbidden_path_markers": [
|
||||
"AGENTS.md",
|
||||
"ROADMAP.md",
|
||||
|
||||
@@ -145,7 +145,8 @@ def test_inventory_covers_both_stacks_and_the_shipped_entrypoint() -> None:
|
||||
# Canvas preparation adds bounded sources, source guidance and write-bound state.
|
||||
# Reference cropping adds two UI owners and six bounded host geometry/contract owners.
|
||||
# Title admission shares the exact packaged coverage between insertion and Inspector.
|
||||
assert len([row for row in document["modules"] if row["language"] == "typescript"]) == 291
|
||||
# Compiled metadata admission and host theme detection each add one frontend owner.
|
||||
assert len([row for row in document["modules"] if row["language"] == "typescript"]) == 293
|
||||
assert document["entrypoints"] == [
|
||||
{
|
||||
"kind": "shipped_frontend_runtime",
|
||||
|
||||
@@ -141,6 +141,189 @@ def test_boot_diagnostics_refuse_nonclosed_payloads(bad: dict[str, Any]) -> None
|
||||
boot_diagnostic(facts)
|
||||
|
||||
|
||||
def open_facts() -> dict[str, Any]:
|
||||
"""The shape `helpers/integratedShellDiagnostics.ts` writes when the Play wait fails."""
|
||||
return {
|
||||
"elapsedMs": 15023.4,
|
||||
"monitor": "opening",
|
||||
"blocker": None,
|
||||
"fallback": None,
|
||||
"overlays": [],
|
||||
"playDisabled": True,
|
||||
"presentedFrame": False,
|
||||
"timelineReady": True,
|
||||
"audioState": "seeking",
|
||||
"audioReason": "opening",
|
||||
"surface": "expanded",
|
||||
"ownership": {
|
||||
"leaseOpens": 2,
|
||||
"sourceAcquired": 2,
|
||||
"sourceLive": 2,
|
||||
"acquisitionAttempts": 2,
|
||||
"acquisitionsInFlight": 0,
|
||||
"videoElements": 2,
|
||||
},
|
||||
"preparation": {"attempts": 1, "inFlight": 0, "aborted": 0, "released": 0},
|
||||
"videos": [
|
||||
{
|
||||
"readyState": 4,
|
||||
"networkState": 1,
|
||||
"seeking": False,
|
||||
"paused": True,
|
||||
"currentTimeMs": 0,
|
||||
"errorCode": 0,
|
||||
}
|
||||
],
|
||||
"requests": [
|
||||
{
|
||||
"label": "fixture:bootstrap",
|
||||
"startMs": -812.5,
|
||||
"endMs": -640.1,
|
||||
"status": 200,
|
||||
"outcome": "ok",
|
||||
},
|
||||
{
|
||||
"label": "media:image",
|
||||
"startMs": 120.2,
|
||||
"endMs": 131.0,
|
||||
"status": 200,
|
||||
"outcome": "ok",
|
||||
},
|
||||
{
|
||||
"label": "media:image",
|
||||
"startMs": 121.0,
|
||||
"endMs": 125.5,
|
||||
"status": None,
|
||||
"outcome": "aborted",
|
||||
},
|
||||
{
|
||||
"label": "media:video",
|
||||
"startMs": 140.7,
|
||||
"endMs": None,
|
||||
"status": None,
|
||||
"outcome": "pending",
|
||||
},
|
||||
],
|
||||
"requestsOmitted": 0,
|
||||
"pageErrors": 0,
|
||||
"consoleErrors": 0,
|
||||
"consoleWarnings": 1,
|
||||
}
|
||||
|
||||
|
||||
def test_open_attachment_survives_the_actual_report_sanitizer_unchanged() -> None:
|
||||
report = raw_report()
|
||||
facts = open_facts()
|
||||
attachment = {
|
||||
"name": "integrated-shell-open-diagnostics",
|
||||
"contentType": "application/json",
|
||||
"body": base64.b64encode(json.dumps(facts).encode()).decode(),
|
||||
}
|
||||
report["suites"][0]["specs"][0]["tests"][0]["results"][0]["attachments"] = [attachment]
|
||||
safe = browser_ci.sanitize_report(report)
|
||||
retained = safe["suites"][0]["specs"][0]["tests"][0]["results"][0]["attachments"]
|
||||
assert [item["name"] for item in retained] == ["integrated-shell-open-diagnostics"]
|
||||
assert json.loads(base64.b64decode(retained[0]["body"])) == facts
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"damage",
|
||||
[
|
||||
"extra-key",
|
||||
"missing-key",
|
||||
"free-text-monitor",
|
||||
"free-text-blocker",
|
||||
"path-token",
|
||||
"url-token",
|
||||
"dotted-token",
|
||||
"uppercase-token",
|
||||
"negative-count",
|
||||
"boolean-count",
|
||||
"huge-count",
|
||||
"nan-clock",
|
||||
"far-clock",
|
||||
"too-many-requests",
|
||||
"too-many-videos",
|
||||
"too-many-overlays",
|
||||
"unknown-label",
|
||||
"request-url",
|
||||
"bad-status",
|
||||
"unknown-outcome",
|
||||
"counter-extra",
|
||||
],
|
||||
)
|
||||
def test_open_diagnostics_refuse_nonclosed_payloads(damage: str) -> None:
|
||||
from scripts.browser_ci_evidence import open_diagnostic
|
||||
|
||||
facts = open_facts()
|
||||
if damage == "extra-key":
|
||||
facts["message"] = "private"
|
||||
elif damage == "missing-key":
|
||||
del facts["surface"]
|
||||
elif damage == "free-text-monitor":
|
||||
facts["monitor"] = "Monitor unavailable: source unavailable."
|
||||
elif damage == "free-text-blocker":
|
||||
facts["blocker"] = "a clip's source could not be read"
|
||||
elif damage == "path-token":
|
||||
facts["fallback"] = "src/private"
|
||||
elif damage == "url-token":
|
||||
facts["surface"] = "http://private"
|
||||
elif damage == "dotted-token":
|
||||
facts["overlays"] = ["private.host"]
|
||||
elif damage == "uppercase-token":
|
||||
facts["audioState"] = "Seeking"
|
||||
elif damage == "negative-count":
|
||||
facts["pageErrors"] = -1
|
||||
elif damage == "boolean-count":
|
||||
facts["ownership"]["sourceLive"] = True
|
||||
elif damage == "huge-count":
|
||||
facts["consoleErrors"] = 1_000_001
|
||||
elif damage == "nan-clock":
|
||||
facts["elapsedMs"] = float("nan")
|
||||
elif damage == "far-clock":
|
||||
facts["requests"][0]["startMs"] = -600_001
|
||||
elif damage == "too-many-requests":
|
||||
facts["requests"] = facts["requests"][1:2] * 65
|
||||
elif damage == "too-many-videos":
|
||||
facts["videos"] = facts["videos"] * 9
|
||||
elif damage == "too-many-overlays":
|
||||
facts["overlays"] = ["unavailable"] * 5
|
||||
elif damage == "unknown-label":
|
||||
facts["requests"][1]["label"] = "media:secret"
|
||||
elif damage == "request-url":
|
||||
facts["requests"][1]["url"] = "/nle-media/image?asset=private"
|
||||
elif damage == "bad-status":
|
||||
facts["requests"][1]["status"] = 99
|
||||
elif damage == "unknown-outcome":
|
||||
facts["requests"][2]["outcome"] = "net::ERR_ABORTED"
|
||||
else:
|
||||
facts["preparation"]["path"] = 1
|
||||
with pytest.raises(ValueError):
|
||||
open_diagnostic(facts)
|
||||
|
||||
|
||||
def test_open_diagnostics_admit_every_closed_state_and_null_member() -> None:
|
||||
from scripts.browser_ci_evidence import OPEN_BLOCKERS, OPEN_MONITOR_STATES, open_diagnostic
|
||||
|
||||
for state in sorted(OPEN_MONITOR_STATES):
|
||||
for blocker in [None, *sorted(OPEN_BLOCKERS)]:
|
||||
facts = open_facts()
|
||||
facts.update(
|
||||
monitor=state,
|
||||
blocker=blocker,
|
||||
fallback="selected_source_only" if state == "fallback" else None,
|
||||
playDisabled=None,
|
||||
audioState=None,
|
||||
audioReason=None,
|
||||
surface=None,
|
||||
ownership=None,
|
||||
preparation=None,
|
||||
videos=[],
|
||||
requests=[],
|
||||
)
|
||||
assert open_diagnostic(facts) == facts
|
||||
|
||||
|
||||
def test_vite_events_keep_kind_and_time_without_payload() -> None:
|
||||
from scripts.browser_ci_evidence import server_event
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
# IMPORTANT: move this pin only with the rebuilt bundle and supply-chain manifest; otherwise HEAD
|
||||
# fails its own deterministic runtime-parity contract.
|
||||
RUNTIME_BUNDLE_SHA256 = (
|
||||
"a67420d0c60f13801603f4898610d789270e296c3d713f63e2ec02244bea8fe7" # pragma: allowlist secret
|
||||
"e437955793c7eb29f2c32af62ff00c1bbc74915d7d99f80a988a0506d5f1630c" # pragma: allowlist secret
|
||||
)
|
||||
RUNTIME_BUNDLE_SIZE = 1970766
|
||||
RUNTIME_BUNDLE_SIZE = 1974807
|
||||
|
||||
|
||||
def supply_chain() -> ModuleType:
|
||||
|
||||
Reference in New Issue
Block a user