feat: enhance Comfy API handling and add tests for branded non-Z diffusion models

This commit is contained in:
syntaxbullet
2026-07-09 21:56:25 +02:00
parent c3a75cf0d6
commit 317a7bbf5f
11 changed files with 532 additions and 37 deletions

View File

@@ -44,13 +44,14 @@ export function resolveLayerDrop(options: {
if (isDescendantLayer(sourceInfo.layer, options.target.layer.id)) return undefined;
const verticalRatio = Math.max(0, Math.min(1, options.verticalRatio));
const dropIntoGroup = options.target.layer.type === "group" && verticalRatio >= 0.33 && verticalRatio <= 0.66;
const targetLayer = options.target.layer;
const dropIntoGroup = targetLayer.type === "group" && verticalRatio >= 0.33 && verticalRatio <= 0.66;
if (dropIntoGroup) {
return {
layerId: options.sourceLayerId,
toArtboardId: options.target.artboardId,
toParentGroupId: options.target.layer.id,
toIndex: options.target.layer.children.length,
toParentGroupId: targetLayer.id,
toIndex: targetLayer.children.length,
};
}

View File

@@ -1,6 +1,7 @@
import { describe, expect, test } from "bun:test";
import type { Dispatch } from "@commands/dispatcher";
import { commandIds } from "@commands/ids";
import type { CommandPayloads } from "@commands/payloads";
import type { PointerInputEvent } from "./pointer";
import { createViewportPanInputController } from "./viewport-pan";
@@ -45,25 +46,36 @@ describe("viewport pan store integration", () => {
});
});
type InputToolId = "select" | "brush" | "eraser" | "pan";
type InputToolId = CommandPayloads[typeof commandIds.toolSetActive]["tool"];
type InputInteractionMode =
| { type: "tool"; tool: InputToolId }
| { type: "temporary-pan"; previousTool: InputToolId };
type InputStoreState = {
viewport: { center: { x: number; y: number }; zoom: number };
tools: { activeTool: InputToolId; interactionMode: InputInteractionMode };
};
type InputStore = ReturnType<typeof createInputStore>;
function createInputStore() {
const store = {
state: {
viewport: { center: { x: 0, y: 0 }, zoom: 1 },
tools: {
activeTool: "select" as InputToolId,
interactionMode: { type: "tool" as const, tool: "select" as InputToolId },
},
const state: InputStoreState = {
viewport: { center: { x: 0, y: 0 }, zoom: 1 },
tools: {
activeTool: "select",
interactionMode: { type: "tool", tool: "select" },
},
};
const store = {
state,
dispatch: ((commandId, payload) => {
switch (commandId) {
case commandIds.toolSetActive:
store.state.tools.activeTool = payload.tool;
store.state.tools.interactionMode = { type: "tool", tool: payload.tool };
case commandIds.toolSetActive: {
const next = payload as CommandPayloads[typeof commandIds.toolSetActive];
store.state.tools.activeTool = next.tool;
store.state.tools.interactionMode = { type: "tool", tool: next.tool };
break;
}
case commandIds.toolEnterTemporaryPan:
store.state.tools.interactionMode = { type: "temporary-pan", previousTool: store.state.tools.activeTool };
break;
@@ -75,12 +87,14 @@ function createInputStore() {
}
break;
}
case commandIds.viewportPan:
case commandIds.viewportPan: {
const next = payload as CommandPayloads[typeof commandIds.viewportPan];
store.state.viewport.center = {
x: store.state.viewport.center.x + payload.delta.x,
y: store.state.viewport.center.y + payload.delta.y,
x: store.state.viewport.center.x + next.delta.x,
y: store.state.viewport.center.y + next.delta.y,
};
break;
}
}
return ignoredState;
}) as Dispatch,