Skip to content

Commit 096d7b6

Browse files
committed
Make Studio node roles, saved wiring, controls and media previews reliable
1 parent 97108a2 commit 096d7b6

46 files changed

Lines changed: 1074 additions & 170 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
3333
with:
3434
repository: sdevil7th/MoDiff
35-
ref: 0ccd0077f7542355783e50f0058deb0e3fcd3bdc
35+
ref: f7c2561fce50931ecbd969eac0b41d8376bd1a2c
3636
path: MoDiff
3737
persist-credentials: false
3838
- name: Verify the pinned backend supports native setup
@@ -91,7 +91,7 @@ jobs:
9191
with:
9292
repository: sdevil7th/MoDiff
9393
# Match the immutable backend revision in the Client quality job.
94-
ref: 0ccd0077f7542355783e50f0058deb0e3fcd3bdc
94+
ref: f7c2561fce50931ecbd969eac0b41d8376bd1a2c
9595
path: MoDiff
9696
persist-credentials: false
9797
- name: Verify the pinned backend supports native setup

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ These rules apply to Codex, Copilot-style agents, and any AI tool editing this r
3636
- Keep search metadata with the backend visual stage catalog. Add modes, action names, familiar aliases and typed roles to an existing stage first. Verify name and action searches, click and wire insertion, model switching and saved graph export before adding another public stage.
3737

3838
- Reuse a task- or modality-generic node for the same user-visible job across models and workflows. Put model-specific execution and schema differences in the declared backend adapter.
39+
- When several modes from one advanced stage appear side by side, title each card for its job and preserve user-authored titles. Inspect file import, canvas drop, the Examples library and saved workflows separately. A generated layout may be fitted after measurement while authored positions and sizes must survive reopening.
3940
- Use an ordinary node for a stage with one executable action. Expose the inputs, effective controls and outputs the user needs. Fold internal preparation or decoding into a stage only when it shares one owner and its intermediate result has no independent consumer.
4041
- Reserve new Blocks for meaningful typed boundaries, such as storyboard shots, reusable compositions, loops or genuine nested control flow. Preserve existing saved Block interfaces and registered definition hashes.
4142
- Keep revised captions and help for existing registered stages in the visual presentation layer. The compiler hashes some stock field metadata. Reproduce the paired catalog with `npm run catalog:block-v2:check` before shipping wording changes.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ application source pair is:
8585
| MoDiff | `1239d1cecd12a7318eb263ca17c34d4fc0445d14` |
8686
| MoDiff-client | `c561a01395044fd71c1918e95fb9e9709d8e7601` |
8787

88-
CI backend contract: `0ccd0077f7542355783e50f0058deb0e3fcd3bdc`.
88+
CI backend contract: `f7c2561fce50931ecbd969eac0b41d8376bd1a2c`.
8989

9090
Both CI jobs use this immutable backend revision. It includes the weight-loading
9191
controls for saved recipes and the model readiness and storage fields used by the

‎docs/modiff-client-architecture.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,13 @@ Existing browser URLs and bundled public assets retain their normal handling.
22292229
Both scalar and picker-array selections project without rewriting saved params;
22302230
clearing the selection also clears stale output-backed input previews on reload.
22312231
Audio references selected from AV files use the backend's soundtrack conversion.
2232+
For a reviewed Gallery video input the player prefers its declared browser-playable
2233+
derivative. If playback fails it tries the original and the managed preview of the
2234+
local input. Downloads and execution continue to use the source recording.
2235+
When a built-in loader includes a dedicated player for the selected file,
2236+
the file field keeps its replace and remove actions. A distinct retained result
2237+
and a newly selected source each keep their own player. File fields shown alone,
2238+
including in the inspector, still display their source media.
22322239

22332240
Video file-picker previews reserve a bounded landscape frame before metadata
22342241
loads. Portrait clips remain fully visible inside that frame through

‎docs/studio-user-flow.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,12 @@ save operation rather than allowing it to save a different instance.
241241
- **Studio** contains guided task/model/form controls and graph-aware readiness.
242242
- **Queue** shows current and recent task progress, cancellation, and errors.
243243
- **Setup** reports backend runtime, capability metadata, model/cache state, and install diagnostics.
244-
- **Setup → Runtime optimizations** shows supported optimization packages, isolated environments, qualification
245-
receipts, activation, and rollback. Install or activate only entries supported by the current backend profile, and
246-
do not treat an unqualified probe as production evidence.
244+
- **Setup → Extra feature packages → Optional runtimes → Optimizations** shows available
245+
accelerators and their requirements. Use **Regional torch.compile → Probe** to test the compiler
246+
before selecting **Regional Compile** in a compatible Expert execution recipe. **Attention Backend**
247+
distinguishes built-in PyTorch flash SDPA, the separate FlashAttention package, and Hub kernels.
248+
The available choices depend on the runtime and the selected model. Auto uses an optimization
249+
after you enable it and review a measured improvement for the same workload.
247250
- **Setup → Template Gallery assets** verifies the installed byte-pinned
248251
payload and offers an explicit app-owned install or repair. It plans the
249252
complete download and staging reservation alongside active model downloads,

‎docs/workflow-authoring-ux.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ On an empty canvas, **Include catalog Blocks** adds prebuilt compositions to the
2424
unfiltered picker. A matching name or compatible wire also finds them. Saved
2525
Blocks stay accessible under their authored names.
2626

27+
After inserting an advanced operation, its card shows the selected action.
28+
For example, **Pipeline Quantization** supplies a quantization configuration
29+
to **Execution Settings**, which collects device, memory and other loading
30+
choices for the model. Search **Runtime Settings** to find both. A custom
31+
heading on a saved node stays visible.
32+
2733
Fresh examples use one Video Input for a file and its normalization, including
2834
when the prepared clip feeds an edge processor. Prepare Mask combines loading
2935
and aligning a mask. Composite can include foreground sizing, padding and cropping.
@@ -34,6 +40,22 @@ its library, adapter, schema and ordered modes still match the current registry.
3440
A separately consumed intermediate remains accessible. Opening an existing user
3541
document respects the presentation saved in that document.
3642

43+
Importing a generated workflow JSON by file picker or drag uses its verified
44+
layout signature. Studio measures the visible cards before spacing them, so a
45+
tall file picker has room beside the next stage. Import keeps the graph's nodes,
46+
connections and order. Moving or resizing a node in the JSON invalidates its
47+
generated geometry. Saved Studio documents, exported workflow packages and
48+
older files without the signature reopen with their authored positions. Use
49+
**Arrange graph** to lay out one of those documents manually.
50+
Dropping workflows in quick succession opens them in that order. An unreadable
51+
file reports its error and the next import can still open.
52+
53+
Older saved model loaders can omit the role of a component output. On
54+
restore, Studio fills that gap from the installed node definition when the
55+
action, socket, direction and type match. This keeps existing wires connected
56+
as the downstream controls load. Changing the model still checks each wire
57+
against the new model's component contract.
58+
3759
Scheduled video recipes load their prompt windows into the Generate stage on
3860
first open. Masked video recipes can place a single Composite stage between
3961
Upscale and Video Output. It takes the original clip, the generated clip, and

‎scripts/bundle-budget.mjs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,9 @@ const MAX_DEFERRED_CHUNK_GZIP_BYTES = 64 * 1024;
12331233
// 357,530 to 361,671 bytes, including the shared workflow-file picker.
12341234
// The template feature, panel layouts and conditional controls are loaded with their existing surfaces. 361671 to 367446 gzip bytes.
12351235
const MAX_DEFERRED_GZIP_BYTES =
1236+
// File pickers, playable media alternatives and role-specific help load on demand.
1237+
// Deferred gzip measured 372668 to 376800 bytes; startup fell by 434 bytes.
1238+
4132 +
12361239
// Contextual help for saved and ungrouped previews. Measured 372145 to 372504 gzip bytes.
12371240
359 +
12381241
// Open-on-demand node help, inspector and Gallery changes, measured 368441 to 372145.

‎scripts/flow-graph-mutations.test.mjs‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,74 @@ test('internal edge removal and connection retain cached leaves when their ownin
304304
assert.deepEqual(store().runtimeCachedNodeIds, [fixture.generateId]);
305305
});
306306

307+
test('saved built-in component outputs keep their wires as current consumer schemas arrive', () => {
308+
const model = 'WanImage2VideoModularPipeline';
309+
const signal = { direction: 'output', origin: 'modiff_pipeline_identity', value: model };
310+
const output = { display: 'output', type: 'diffusers_auto_model', signal };
311+
const input = { display: 'input', type: output.type };
312+
const loader = node(
313+
'wan-loader',
314+
{ vae_out: output },
315+
{ module: 'modules.ModularDiffusers', action: 'ModelsLoader' },
316+
);
317+
const consumer = node('encode-image', { vae: input });
318+
const saved = edge('saved-vae', loader.id, consumer.id, 'vae_out', 'vae');
319+
nodeStoreModule.useNodesStore.setState({
320+
nodesRegistry: {
321+
'modules.ModularDiffusers.ModelsLoader': { params: { vae_out: { ...output, connectionRole: 'vae' } } },
322+
},
323+
});
324+
const flow = () => flowStoreModule.useFlowStore.getState();
325+
const graph = { nodes: [loader, consumer], edges: [saved] };
326+
const requireVae = () =>
327+
flow().replaceNodeParams(consumer.id, {
328+
vae: { ...input, signalCompatibility: { role: 'vae', required: true, values: { [model]: ['vae'] } } },
329+
});
330+
flow().replaceGraph(graph);
331+
requireVae();
332+
assert.deepEqual(
333+
flow().edges.map(({ id }) => id),
334+
[saved.id],
335+
);
336+
assert.deepEqual(flow().historyPast, []);
337+
assert.deepEqual(loader.data.params.vae_out, output);
338+
339+
for (const override of [
340+
{ connectionRole: 'denoiser' },
341+
{ connectionRoleSelector: { field: 'missing', values: { vae: 'vae' } } },
342+
{ type: 'any' },
343+
{ display: 'input' },
344+
]) {
345+
flow().replaceGraph({
346+
...graph,
347+
nodes: [
348+
{
349+
...loader,
350+
data: {
351+
...loader.data,
352+
params: { vae_out: { ...output, ...override } },
353+
},
354+
},
355+
consumer,
356+
],
357+
});
358+
requireVae();
359+
assert.deepEqual(flow().edges, [], JSON.stringify(override));
360+
}
361+
362+
nodeStoreModule.useNodesStore.setState({
363+
nodesRegistry: {
364+
'custom_nodes.OlderLoader': { params: { vae_out: { ...output, connectionRole: 'vae' } } },
365+
},
366+
});
367+
flow().replaceGraph({
368+
...graph,
369+
nodes: [{ ...loader, data: { ...loader.data, module: 'custom_nodes', action: 'OlderLoader' } }, consumer],
370+
});
371+
requireVae();
372+
assert.deepEqual(flow().edges, []);
373+
});
374+
307375
test('connection mutations enforce signal-driven component compatibility', () => {
308376
const schedulerOutput = (modelType) => ({
309377
scheduler: {

‎scripts/graph-visuals.test.mjs‎

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,25 @@ test('custom node help uses authored purpose and port descriptions, and describe
905905
assert.match(render(), /Takes Foreground and produces Composite/);
906906
});
907907

908+
test('saved ACE audio edit starters put the prompt ahead of lyrics and sampler controls', async () => {
909+
const { savedStockControlOrder } = await server.ssrLoadModule('/src/workflow/gatedNodeControls.ts');
910+
const keys = ['prompt', 'negative_prompt', 'lyrics', 'num_inference_steps'];
911+
for (const kind of ['repaint', 'continuation', 'variation']) {
912+
const graph = JSON.parse(
913+
fs.readFileSync(
914+
path.resolve(ROOT, '../MoDiff/data/graphs/studio/ace-step-audio-pipeline/audio-' + kind + '.json'),
915+
'utf8',
916+
),
917+
);
918+
const { data } = graph.nodes.find((node) => node.data.action === 'Generate');
919+
const old = structuredClone(graph);
920+
const registry = Object.fromEntries(keys.filter((key) => data.params[key]).map((key) => [key, data.params[key]]));
921+
const ordered = Object.keys(savedStockControlOrder(data, data.params, registry));
922+
assert.ok(ordered.indexOf('prompt') < ordered.indexOf('lyrics'), kind);
923+
assert.deepEqual(graph, old);
924+
}
925+
});
926+
908927
test('saved CogVideoX and Klein foreground the prompt and AudioLDM2 keeps both 16 kHz controls selectable', async () => {
909928
const { savedStockControlOrder } = await server.ssrLoadModule('/src/workflow/gatedNodeControls.ts');
910929
const { graphNodeControlParams } = await server.ssrLoadModule('/src/studio/graphNodeControls.ts');
@@ -1247,8 +1266,35 @@ test('saved image-only wires hide only unused Preview decoding controls on ordin
12471266
});
12481267

12491268
test('stock port help uses exact media and quantity meanings while custom roles remain author-defined', async () => {
1269+
const { nodeFieldDisplayLabel, nodeHelpDescription } = await server.ssrLoadModule(
1270+
'/src/workflow/nodePresentation.ts',
1271+
);
1272+
assert.match(nodeHelpDescription('modules.ModularDiffusers.DynamicBlockNode', null), /Preview Custom Block Contract/);
1273+
for (const action of ['modules.Audio.Export', 'modules.Primitive.ExportData']) {
1274+
assert.equal(nodeFieldDisplayLabel(action, 'filename', 'File'), 'Output filename');
1275+
assert.equal(nodeFieldDisplayLabel(action, 'file', 'File'), 'Saved file');
1276+
assert.equal(nodeFieldDisplayLabel(action, 'file', 'Master recording'), 'Master recording');
1277+
}
1278+
for (const action of [
1279+
'modules.HuggingFaceSpeech.LoadCTCSpeechRecognitionModel',
1280+
'modules.HuggingFaceTransformers.LoadImageTextToTextModel',
1281+
'modules.HuggingFaceTransformers.LoadDepthEstimationModel',
1282+
]) {
1283+
assert.equal(nodeFieldDisplayLabel(action, 'model_id', 'Model'), 'Model checkpoint');
1284+
assert.equal(
1285+
nodeFieldDisplayLabel(action, action.endsWith('LoadDepthEstimationModel') ? 'pipeline' : 'model', 'Model'),
1286+
'Loaded model',
1287+
);
1288+
}
12501289
const { builtinPortPurpose: purpose } = await server.ssrLoadModule('/src/workflow/nodePortHelp.ts');
12511290
const id = 'modules.VideoConditioning.Normalize';
1291+
assert.match(purpose('modules.Audio.Export', 'file', 'audio', 'output'), /path.*exported WAV/i);
1292+
assert.match(purpose('modules.Audio.Preview', 'file', 'audio', 'output'), /path.*playback/i);
1293+
assert.match(purpose('modules.Video.Export', 'file', 'video', 'output'), /path.*encoded video/i);
1294+
assert.match(purpose('modules.Video.MuxAudioAsset', 'asset', 'video_asset', 'output'), /metadata/i);
1295+
assert.match(purpose('modules.Image.Save', 'output', 'str', 'output'), /saved image files/i);
1296+
assert.match(purpose('modules.Audio.Load', 'audio', 'audio', 'output'), /samples/i);
1297+
assert.equal(purpose('custom.Audio.Export', 'file', 'audio', 'output'), undefined);
12521298
assert.match(purpose(id, 'mask', 'image', 'input'), /regions/);
12531299
assert.match(purpose(id, 'control_video', ['video', 'str'], 'input'), /motion/);
12541300
assert.match(purpose(id, 'height_out', 'int', 'output'), /height in pixels/);
@@ -1705,6 +1751,51 @@ test('text and nested file-path controls associate their labels with distinct in
17051751
}
17061752
});
17071753

1754+
test('a standalone file editor keeps its own source player when the canvas has no matching dedicated preview', async () => {
1755+
const { default: FileBrowserField } = await server.ssrLoadModule('/src/fields/FileBrowserField.tsx');
1756+
for (const [kind, file] of [
1757+
['audio', 'selected.wav'],
1758+
['video', 'selected.mp4'],
1759+
]) {
1760+
const render = (sourcePreview) =>
1761+
renderToStaticMarkup(
1762+
createElement(
1763+
ReactFlowProvider,
1764+
null,
1765+
createElement(FileBrowserField, {
1766+
nodeId: 'source',
1767+
module: 'custom.User',
1768+
action: 'Load',
1769+
fieldKey: 'file',
1770+
dataType: 'string',
1771+
value: file,
1772+
fieldOptions: { fileTypes: [kind] },
1773+
sourcePreview,
1774+
updateStore: () => {},
1775+
}),
1776+
),
1777+
);
1778+
assert.match(render(undefined), new RegExp('<' + kind + '\\b'));
1779+
assert.match(render(kind), /Drop to replace/);
1780+
assert.doesNotMatch(render(kind), new RegExp('<' + kind + '\\b'));
1781+
// A different completed result must remain playable alongside the current selection.
1782+
const initial = studioStoreModule.useStudioStore.getInitialState();
1783+
const slot = studioStoreModule.studioPreviewSlotKey('source', 'preview', initial.activeWorkflowTabId);
1784+
const previousSlots = initial.previewSlots,
1785+
previousOutputs = initial.outputs;
1786+
try {
1787+
initial.previewSlots = { ...previousSlots, [slot]: { status: 'ready', currentOutputId: 'old-result' } };
1788+
initial.outputs = [{ id: 'old-result', displayType: kind, value: ['https://example.test/previous-' + file] }];
1789+
assert.match(render(kind), new RegExp('<' + kind + '\\b'), 'different retained result');
1790+
initial.previewSlots[slot] = { status: 'pending' };
1791+
assert.match(render(kind), new RegExp('<' + kind + '\\b'), 'no playable result yet');
1792+
} finally {
1793+
initial.previewSlots = previousSlots;
1794+
initial.outputs = previousOutputs;
1795+
}
1796+
}
1797+
});
1798+
17081799
test('measurement waiting distinguishes real late bounds from an incomplete timeout', async () => {
17091800
const pending = node('late-controls', 0, 0);
17101801
let reads = 0;
@@ -1816,6 +1907,36 @@ test('fresh layout waits for downloaded controls, stops on failure or a changed
18161907
}
18171908
});
18181909

1910+
test('fresh layout waits for the flow measurement to catch up with a mounted field', async () => {
1911+
const target = node('prompt-with-layout-editor', 0, 0);
1912+
target.measured = { width: 453, height: 479 };
1913+
const previousDocument = Object.getOwnPropertyDescriptor(globalThis, 'document');
1914+
const previousFrame = window.requestAnimationFrame;
1915+
let frame = 0;
1916+
try {
1917+
Object.defineProperty(globalThis, 'document', {
1918+
configurable: true,
1919+
value: {
1920+
getElementById: () => ({
1921+
querySelector: () => null,
1922+
closest: () => ({ offsetWidth: 656, offsetHeight: 789 }),
1923+
}),
1924+
},
1925+
});
1926+
window.requestAnimationFrame = (callback) => {
1927+
if (++frame === 5) target.measured = { width: 656, height: 789 };
1928+
queueMicrotask(() => callback(Date.now()));
1929+
return frame;
1930+
};
1931+
assert.equal(await graphLayout.waitForGraphNodeMeasurements(() => [target]), true);
1932+
assert.ok(frame >= 6, 'the older size can look stable on several frames after the editor mounts');
1933+
} finally {
1934+
window.requestAnimationFrame = previousFrame;
1935+
if (previousDocument) Object.defineProperty(globalThis, 'document', previousDocument);
1936+
else delete globalThis.document;
1937+
}
1938+
});
1939+
18191940
test('late fresh-workflow measurements preserve an intervening layout edit and leave a replacement tab alone', async () => {
18201941
const { settleExampleWorkflowCanvas } = await server.ssrLoadModule('/src/studio/exampleWorkflow.ts');
18211942
const studio = studioStoreModule.useStudioStore;
@@ -1840,6 +1961,19 @@ test('late fresh-workflow measurements preserve an intervening layout edit and l
18401961
finishEditing();
18411962
assert.equal(await editing, true);
18421963
assert.deepEqual(flow.getState().nodes[1].position, { x: 831, y: 733 });
1964+
const dragging = settleExampleWorkflowCanvas();
1965+
const finishDragging = nextFrame;
1966+
nextFrame = null;
1967+
flow.getState().beginHistoryTransaction('Move node');
1968+
try {
1969+
finishDragging();
1970+
// An in-progress gesture must stop the measurement loop before it schedules another frame.
1971+
assert.equal(nextFrame, null);
1972+
assert.equal(await dragging, true);
1973+
assert.deepEqual(flow.getState().nodes[1].position, { x: 831, y: 733 });
1974+
} finally {
1975+
flow.getState().commitHistoryTransaction();
1976+
}
18431977
const switching = settleExampleWorkflowCanvas();
18441978
const finishSwitching = nextFrame;
18451979
studio.getState().createWorkflowTab('Another document');

0 commit comments

Comments
 (0)