Browse Source

fix: dimmed switch with enabled output no longer lets downstream escape dimming

The else-if chain in blockedTypes detection meant that when a switch/
conditionalSwitch node was itself dimmed but had an enabled output,
the finalDimmed.has(source) check was skipped entirely. Changed the
dimmed-source check from else-if to a standalone if so it runs for
all source types, including switch and conditionalSwitch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 5 months ago
parent
commit
846bffc1d4
  1. 23
      src/store/utils/__tests__/dimmingUtils.test.ts
  2. 4
      src/store/utils/dimmingUtils.ts

23
src/store/utils/__tests__/dimmingUtils.test.ts

@ -237,6 +237,29 @@ describe("computeDimmedNodes", () => {
});
});
it("dims nodes downstream of a dimmed switch's enabled output", () => {
// ConditionalSwitch --[unmatched]--> gen1 --> Switch --[enabled]--> gen2
// gen1 is dimmed (unmatched output), Switch is dimmed (input from dimmed gen1),
// gen2 should be dimmed too even though the Switch output is enabled.
const nodes = [
makeConditionalSwitchNode("cs", [
{ id: "rule1", isMatched: false },
]),
makeNode("gen1", "nanoBanana"),
makeSwitchNode("sw", [{ id: "out1", enabled: true }]),
makeNode("gen2", "nanoBanana"),
];
const edges = [
makeEdge("cs", "gen1", { sourceHandle: "rule1" }),
makeEdge("gen1", "sw"),
makeEdge("sw", "gen2", { sourceHandle: "out1" }),
];
const dimmed = computeDimmedNodes(nodes, edges);
expect(dimmed.has("gen1")).toBe(true);
expect(dimmed.has("sw")).toBe(true);
expect(dimmed.has("gen2")).toBe(true);
});
it("does not dim the switch node itself", () => {
const nodes = [
makeSwitchNode("sw", [{ id: "out1", enabled: false }]),

4
src/store/utils/dimmingUtils.ts

@ -111,7 +111,9 @@ export function computeDimmedNodes(
blockedTypes.add(edge.targetHandle);
}
}
} else if (finalDimmed.has(edge.source) && edge.targetHandle) {
}
// Standalone: if source node itself is dimmed, block regardless of output state
if (finalDimmed.has(edge.source) && edge.targetHandle) {
blockedTypes.add(edge.targetHandle);
}
});

Loading…
Cancel
Save