From 846bffc1d4d1516188d42320ebbe84b568e89d1b Mon Sep 17 00:00:00 2001 From: shrimbly Date: Sat, 28 Feb 2026 22:47:11 +1300 Subject: [PATCH] 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 --- .../utils/__tests__/dimmingUtils.test.ts | 23 +++++++++++++++++++ src/store/utils/dimmingUtils.ts | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/store/utils/__tests__/dimmingUtils.test.ts b/src/store/utils/__tests__/dimmingUtils.test.ts index fe4fdb15..27fd1e17 100644 --- a/src/store/utils/__tests__/dimmingUtils.test.ts +++ b/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 }]), diff --git a/src/store/utils/dimmingUtils.ts b/src/store/utils/dimmingUtils.ts index 50f609ad..771953d7 100644 --- a/src/store/utils/dimmingUtils.ts +++ b/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); } });