From 5d7ca2cdb5170d090daf99536581aeefbefd54bd Mon Sep 17 00:00:00 2001 From: erKam <88717125+erkamyaman@users.noreply.github.com> Date: Sun, 11 Oct 2026 06:16:31 +0300 Subject: [PATCH] fix(signals): keep a dependent unnamed resource apart from the one it reads Resource parts are grouped into one resource when an edge joins two nodes with the same name. Unnamed resources all share the name undefined, and a resource's extRequest node reads the user's params, so when params read another unnamed resource's value the two were merged into one entry. Edges from extRequest no longer join groups; a resource's own parts never need them. --- .../src/__tests__/signal-resources.test.ts | 24 +++++++++++++++++++ packages/devtools/src/signal-resources.ts | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/devtools/src/__tests__/signal-resources.test.ts b/packages/devtools/src/__tests__/signal-resources.test.ts index 6fbcccd8..b1693105 100644 --- a/packages/devtools/src/__tests__/signal-resources.test.ts +++ b/packages/devtools/src/__tests__/signal-resources.test.ts @@ -46,6 +46,30 @@ describe('groupResources', () => { ]); }); + it('keeps an unnamed resource whose params read another unnamed resource apart from it', () => { + const nodes = [ + node('1', 'computed', 'Resource.value', 'Ada'), + node('2', 'linkedSignal', 'Resource.state'), + node('3', 'linkedSignal', 'Resource.extRequest'), + node('4', 'computed', 'Resource.value', ['Ada post']), + node('5', 'linkedSignal', 'Resource.state'), + node('6', 'linkedSignal', 'Resource.extRequest'), + ]; + const edges: SignalGraphEdge[] = [ + { consumer: 0, producer: 1 }, + { consumer: 1, producer: 2 }, + { consumer: 3, producer: 4 }, + { consumer: 4, producer: 5 }, + // The second resource's params read the first resource's value. + { consumer: 5, producer: 0 }, + ]; + const resources = groupResources(nodes, edges, [], serialize); + expect(resources.map((r) => [r.name, r.value, r.nodeIds])).toEqual([ + ['resource 1', 'Ada', ['1', '2', '3']], + ['resource 2', ['Ada post'], ['4', '5', '6']], + ]); + }); + it('derives status from the graph when no instance holds the resource', () => { const nodes = [ node('1', 'computed', 'Resource#trips.value', '(threw an error)'), diff --git a/packages/devtools/src/signal-resources.ts b/packages/devtools/src/signal-resources.ts index 65d91e88..59035e39 100644 --- a/packages/devtools/src/signal-resources.ts +++ b/packages/devtools/src/signal-resources.ts @@ -115,7 +115,8 @@ function groupsOf(nodes: SignalGraphNode[], edges: SignalGraphEdge[]): Group[] { if (!valid(e)) continue; const a = parsed[e.consumer]; const b = parsed[e.producer]; - if (a && b && a.name === b.name) union(e.consumer, e.producer); + // extRequest reads the user's params, which may read another resource. + if (a && b && a.name === b.name && a.part !== 'extRequest') union(e.consumer, e.producer); } // httpResource signals have plain names: `_statusCode` and friends read the // resource's own signals, and its `stream` is read by the resource value.