From e08ee1a8b55b5c000d679814123b8468375cc3a5 Mon Sep 17 00:00:00 2001 From: jaeone94 <89377375+jaeone94@users.noreply.github.com> Date: Wed, 14 Oct 2026 19:45:41 +0900 Subject: [PATCH 1/4] feat: report DynamicGroup row refusals and remote count mismatches A refused DynamicGroup row change and a remote row count that the live group does not reach were silent. Report both through reportError with node type, operation and counts only, once per session per node type, operation and error type, and only on Cloud or on a Desktop host with telemetry enabled. --- .../widgets/dynamicGroupDiagnostics.test.ts | 273 ++++++++++++++++++ .../graph/widgets/dynamicGroupDiagnostics.ts | 89 ++++++ src/core/graph/widgets/dynamicGroupWidget.ts | 22 +- .../extensions/agent/crdt/liveGraphApplier.ts | 11 + 4 files changed, 394 insertions(+), 1 deletion(-) create mode 100644 src/core/graph/widgets/dynamicGroupDiagnostics.test.ts create mode 100644 src/core/graph/widgets/dynamicGroupDiagnostics.ts diff --git a/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts b/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts new file mode 100644 index 00000000000..97329a3e62b --- /dev/null +++ b/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts @@ -0,0 +1,273 @@ +import { nodesMap } from '@comfyorg/comfy-multi-player' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import * as Y from 'yjs' + +import { LGraph, LGraphNode, LiteGraph } from '@/lib/litegraph/src/litegraph' +import { remoteConfig } from '@/platform/remoteConfig/remoteConfig' +import { reportError } from '@/platform/telemetry/reportError' +import { useLitegraphService } from '@/services/litegraphService' +import { useLinkStore } from '@/stores/linkStore' +import { toNodeId } from '@/types/nodeId' +import { followedDoc } from '@/workbench/extensions/agent/crdt/__fixtures__/followedDoc' +import { LiveGraphApplier } from '@/workbench/extensions/agent/crdt/liveGraphApplier' + +const distribution = vi.hoisted(() => ({ isCloud: false })) + +vi.mock(import('@/platform/distribution/types'), () => ({ + get isCloud() { + return distribution.isCloud + } +})) + +vi.mock(import('@/platform/telemetry/reportError')) + +function addGroup(node: LGraphNode, min = 0) { + useLitegraphService().addNodeInput(node, { + name: 'rows', + type: 'COMFY_DYNAMICGROUP_V3', + isOptional: false, + min, + max: 3, + template: { required: { strength: ['FLOAT', { default: 1 }] } } + }) +} + +function group(type: string, { min = 0, count = 2 } = {}) { + const graph = new LGraph() + const node = new LGraphNode('Group', type) + node.serialize_widgets = true + graph.add(node) + addGroup(node, min) + function widget(name: string) { + const found = node.widgets?.find((widget) => widget.name === name) + if (!found) throw new Error(`Missing widget ${name}`) + return found + } + widget('rows').value = count + return { widget } +} + +function refuseInputChanges() { + vi.spyOn(useLinkStore(), 'updateEndpoints').mockReturnValue({ + ok: false, + error: { code: 'unowned-topology', message: 'Rejected' } + }) +} + +function reportsOf(errorType: string) { + return vi + .mocked(reportError) + .mock.calls.filter(([, options]) => options.errorType === errorType) +} + +beforeEach(() => { + remoteConfig.value = { enable_telemetry: true } +}) + +afterEach(() => { + distribution.isCloud = false + remoteConfig.value = {} +}) + +describe('DynamicGroup row refusal reports', () => { + function rowRefusal( + type: string, + operation: string, + requested: number, + actual: number + ) { + return [ + expect.objectContaining({ message: 'Refused a DynamicGroup row change' }), + { + errorType: 'failure_resizing_dynamic_group_rows', + surface: 'graph', + level: 'warning', + tags: { node_type: type, operation, in_subgraph: false }, + context: { requested, actual } + } + ] + } + + type Widget = ReturnType['widget'] + + it.for([ + { + name: 'an added row', + operation: 'add_row', + requested: 3, + change: (widget: Widget) => (widget('rows').value = 3) + }, + { + name: 'a count reduction', + operation: 'remove_row', + requested: 0, + change: (widget: Widget) => (widget('rows').value = 0) + }, + { + name: "a row's remove button", + operation: 'remove_row', + requested: 1, + change: (widget: Widget) => widget('rows.0').callback?.(undefined) + } + ])( + 'reports a refused change from $name with counts only', + ({ name, operation, requested, change }) => { + const { widget } = group(name) + refuseInputChanges() + + change(widget) + + expect(widget('rows').value).toBe(2) + expect(vi.mocked(reportError).mock.calls).toEqual([ + rowRefusal(name, operation, requested, 2) + ]) + } + ) + + it('does not report successful changes or a count clamped up to min', () => { + const { widget } = group('Accepted changes', { min: 1, count: 3 }) + widget('rows').value = -1 + widget('rows.$add').callback?.(undefined) + widget('rows.1').callback?.(undefined) + + expect(widget('rows').value).toBe(1) + expect(reportError).not.toHaveBeenCalled() + }) + + it('reports each node type and operation once per session', () => { + const first = group('Deduped refusal') + const second = group('Deduped refusal') + const other = group('Other refusal') + refuseInputChanges() + + first.widget('rows').value = 3 + first.widget('rows').value = 0 + first.widget('rows').value = 4 + second.widget('rows').value = 3 + other.widget('rows').value = 3 + + expect(vi.mocked(reportError).mock.calls).toEqual([ + rowRefusal('Deduped refusal', 'add_row', 3, 2), + rowRefusal('Deduped refusal', 'remove_row', 0, 2), + rowRefusal('Other refusal', 'add_row', 3, 2) + ]) + }) + + it.for([ + { isCloud: false, enableTelemetry: false, reported: false }, + { isCloud: false, enableTelemetry: true, reported: true }, + { isCloud: true, enableTelemetry: false, reported: true } + ])( + 'sends with cloud=$isCloud and host telemetry=$enableTelemetry: $reported', + ({ isCloud, enableTelemetry, reported }) => { + distribution.isCloud = isCloud + remoteConfig.value = { enable_telemetry: enableTelemetry } + const { widget } = group(`Gated ${isCloud} ${enableTelemetry}`) + refuseInputChanges() + + widget('rows').value = 3 + + expect(vi.mocked(reportError).mock.calls.length > 0).toBe(reported) + } + ) +}) + +describe('remote DynamicGroup row count reports', () => { + class RemoteDynamicGroup extends LGraphNode { + constructor() { + super('Remote Dynamic Group') + this.serialize_widgets = true + addGroup(this) + } + } + + beforeEach(() => { + LiteGraph.registerNodeType('RemoteDynamicGroup', RemoteDynamicGroup) + }) + + function remoteGroup() { + const graph = new LGraph() + const { doc, collector } = followedDoc( + { + nodes: [ + { + id: 1, + type: 'RemoteDynamicGroup', + pos: [0, 0], + size: [210, 100], + widgets_values: [1, 0.5] + } + ], + links: [] + }, + { + types: { + RemoteDynamicGroup: { + widget_order: ['rows', 'rows.0.strength', 'rows.1.strength'] + } + } + } + ) + const applier = new LiveGraphApplier({ getGraph: () => graph }) + const context = { actor: 'agent:test', opIds: ['op-1'] } + applier.applyChanges(doc, collector.take(), context) + const rows = graph + .getNodeById(toNodeId(1)) + ?.widgets?.find((widget) => widget.name === 'rows') + if (!rows) throw new Error('DynamicGroup node 1 was not created') + function setRows(count: number) { + doc.transact(() => { + const widgets = nodesMap(doc).get('1')?.get('widgets') + if (!(widgets instanceof Y.Map)) throw new Error('named storage') + widgets.set('rows', count) + }) + return applier.applyChanges(doc, collector.take(), context).failureCount + } + return { rows, setRows } + } + + it('applies a remote row count without reporting', () => { + const { rows, setRows } = remoteGroup() + + expect([setRows(2), setRows(0)]).toEqual([0, 0]) + expect(rows.value).toBe(0) + expect(reportError).not.toHaveBeenCalled() + }) + + it('reports a remote row count the live group did not reach, once per node type', () => { + const { rows, setRows } = remoteGroup() + refuseInputChanges() + + expect([setRows(3), setRows(2)]).toEqual([1, 1]) + expect(rows.value).toBe(1) + expect(reportsOf('agent_graph_dynamic_group_rows_mismatch')).toEqual([ + [ + expect.objectContaining({ + message: 'Remote DynamicGroup row count did not apply' + }), + { + errorType: 'agent_graph_dynamic_group_rows_mismatch', + surface: 'agent', + tags: { + subsystem: 'agent-crdt', + layer: 'graph-api', + outcome: 'degraded', + node_type: 'RemoteDynamicGroup', + operation: 'remote_apply', + in_subgraph: false + }, + context: { requested: 3, actual: 1 } + } + ] + ]) + }) + + it('counts but does not send a mismatch without telemetry consent', () => { + remoteConfig.value = {} + const { setRows } = remoteGroup() + refuseInputChanges() + + expect(setRows(2)).toBe(1) + expect(reportError).not.toHaveBeenCalled() + }) +}) diff --git a/src/core/graph/widgets/dynamicGroupDiagnostics.ts b/src/core/graph/widgets/dynamicGroupDiagnostics.ts new file mode 100644 index 00000000000..4d686bb63c0 --- /dev/null +++ b/src/core/graph/widgets/dynamicGroupDiagnostics.ts @@ -0,0 +1,89 @@ +import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' +import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' +import { isCloud } from '@/platform/distribution/types' +import { isHostTelemetryEnabled } from '@/platform/telemetry/hostTelemetryEnabled' +import { reportError } from '@/platform/telemetry/reportError' +import { isSubgraph } from '@/utils/typeGuardUtil' + +type RowOperation = 'add_row' | 'remove_row' | 'remote_apply' + +const controllers = new WeakSet() +const reported = new Set() + +export function markDynamicGroupController(widget: IBaseWidget): void { + controllers.add(widget) +} + +/** True for the hidden widget whose value is a DynamicGroup's row count. */ +export function isDynamicGroupController(widget: IBaseWidget): boolean { + return controllers.has(widget) +} + +function reportRowCount( + node: LGraphNode, + operation: RowOperation, + counts: { requested: number | null; actual: number }, + report: { + message: string + errorType: string + surface: 'graph' | 'agent' + level?: 'warning' + tags?: Record + } +): void { + const key = `${report.errorType}:${node.type}:${operation}` + if (!(isCloud || isHostTelemetryEnabled()) || reported.has(key)) return + reported.add(key) + reportError(new Error(report.message), { + errorType: report.errorType, + surface: report.surface, + level: report.level, + tags: { + ...report.tags, + node_type: node.type, + operation, + in_subgraph: isSubgraph(node.graph) + }, + context: counts + }) +} + +/** Reports a local DynamicGroup row change that left a different row count. */ +export function reportDynamicGroupRowRefusal( + node: LGraphNode, + operation: 'add_row' | 'remove_row', + requested: number, + actual: number +): void { + reportRowCount( + node, + operation, + { requested, actual }, + { + message: 'Refused a DynamicGroup row change', + errorType: 'failure_resizing_dynamic_group_rows', + surface: 'graph', + level: 'warning' + } + ) +} + +/** Reports a remote DynamicGroup row count the live group did not reach. */ +export function reportRemoteDynamicGroupRowMismatch( + node: LGraphNode, + requested: unknown, + actual: number, + tags: Record +): void { + reportRowCount( + node, + 'remote_apply', + { requested: typeof requested === 'number' ? requested : null, actual }, + { + message: 'Remote DynamicGroup row count did not apply', + errorType: 'agent_graph_dynamic_group_rows_mismatch', + surface: 'agent', + tags + } + ) +} diff --git a/src/core/graph/widgets/dynamicGroupWidget.ts b/src/core/graph/widgets/dynamicGroupWidget.ts index f1a643aa781..ad087e21ca4 100644 --- a/src/core/graph/widgets/dynamicGroupWidget.ts +++ b/src/core/graph/widgets/dynamicGroupWidget.ts @@ -24,6 +24,11 @@ import { deriveWidgetSurfaces } from '@/types/widgetVisibility' import { mapUniqueNodes } from '@/utils/graphTraversalUtil' import { isSubgraph } from '@/utils/typeGuardUtil' +import { + markDynamicGroupController, + reportDynamicGroupRowRefusal +} from './dynamicGroupDiagnostics' + export function dynamicGroupWidget( node: LGraphNode, inputName: string, @@ -46,6 +51,7 @@ export function dynamicGroupWidget( hidden: true, options: { min, max, socketless: true, serialize: false } }) + markDynamicGroupController(controller) node.addCustomWidget( new DynamicGroupNoticeWidget( { @@ -249,7 +255,14 @@ export function dynamicGroupWidget( callback: () => { if (rows().length <= min) return changeRows(() => { - removeRow(Number(header.name.slice(inputName.length + 1))) + const requested = rows().length - 1 + if (!removeRow(Number(header.name.slice(inputName.length + 1)))) + reportDynamicGroupRowRefusal( + node, + 'remove_row', + requested, + rows().length + ) publish() }) } @@ -381,6 +394,13 @@ export function dynamicGroupWidget( } publish() announceAddedValues(existing) + if (rowCount !== count) + reportDynamicGroupRowRefusal( + node, + rowCount > count ? 'remove_row' : 'add_row', + count, + rowCount + ) } }) controller.value = initialCount diff --git a/src/workbench/extensions/agent/crdt/liveGraphApplier.ts b/src/workbench/extensions/agent/crdt/liveGraphApplier.ts index e53803fd765..f38b679102e 100644 --- a/src/workbench/extensions/agent/crdt/liveGraphApplier.ts +++ b/src/workbench/extensions/agent/crdt/liveGraphApplier.ts @@ -8,6 +8,10 @@ import { isEqual } from 'es-toolkit' import * as Y from 'yjs' import { z } from 'zod' +import { + isDynamicGroupController, + reportRemoteDynamicGroupRowMismatch +} from '@/core/graph/widgets/dynamicGroupDiagnostics' import { growAutogrowInput } from '@/core/graph/widgets/dynamicWidgets' import type { INodeFlags } from '@/lib/litegraph/src/interfaces' import type { INodeInputSlot } from '@/lib/litegraph/src/types/slots' @@ -919,6 +923,13 @@ export class LiveGraphApplier { ) continue this.setWidgetValue(node, widget, value) + if (isDynamicGroupController(widget) && !Object.is(widget.value, value)) { + this.incrementFailureCount() + reportRemoteDynamicGroupRowMismatch(node, value, Number(widget.value), { + ...AGENT_APPLY_TAGS, + outcome: 'degraded' + }) + } resolved = true } return { resolved, unresolved } From 9c8c3652001dae23253622d37de1143adebb1803 Mon Sep 17 00:00:00 2001 From: jaeone94 <89377375+jaeone94@users.noreply.github.com> Date: Thu, 15 Oct 2026 09:31:08 +0900 Subject: [PATCH 2/4] fix: report each DynamicGroup row mismatch once, against the normalized count - The applier marks a remote row count write, and the local refusal report skips it, so a refused remote resize is reported only as the agent mismatch. - Compare a remote count with the value the setter derives (min, trunc, -0) instead of the raw document value. - Give the consent test its own node type so dedupe cannot hide a missing gate, and assert the full report list for the remote refusal. --- .../widgets/dynamicGroupDiagnostics.test.ts | 49 ++++++++++++------- .../graph/widgets/dynamicGroupDiagnostics.ts | 24 +++++++++ .../extensions/agent/crdt/liveGraphApplier.ts | 29 ++++++++--- 3 files changed, 76 insertions(+), 26 deletions(-) diff --git a/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts b/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts index 97329a3e62b..975ba4aa204 100644 --- a/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts +++ b/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts @@ -54,12 +54,6 @@ function refuseInputChanges() { }) } -function reportsOf(errorType: string) { - return vi - .mocked(reportError) - .mock.calls.filter(([, options]) => options.errorType === errorType) -} - beforeEach(() => { remoteConfig.value = { enable_telemetry: true } }) @@ -173,26 +167,30 @@ describe('DynamicGroup row refusal reports', () => { }) describe('remote DynamicGroup row count reports', () => { - class RemoteDynamicGroup extends LGraphNode { - constructor() { - super('Remote Dynamic Group') - this.serialize_widgets = true - addGroup(this) + function remoteNodeType(min: number) { + return class extends LGraphNode { + constructor() { + super('Remote Dynamic Group') + this.serialize_widgets = true + addGroup(this, min) + } } } beforeEach(() => { - LiteGraph.registerNodeType('RemoteDynamicGroup', RemoteDynamicGroup) + LiteGraph.registerNodeType('RemoteDynamicGroup', remoteNodeType(0)) + LiteGraph.registerNodeType('MinOneDynamicGroup', remoteNodeType(1)) + LiteGraph.registerNodeType('ConsentDynamicGroup', remoteNodeType(0)) }) - function remoteGroup() { + function remoteGroup(type = 'RemoteDynamicGroup') { const graph = new LGraph() const { doc, collector } = followedDoc( { nodes: [ { id: 1, - type: 'RemoteDynamicGroup', + type, pos: [0, 0], size: [210, 100], widgets_values: [1, 0.5] @@ -202,7 +200,7 @@ describe('remote DynamicGroup row count reports', () => { }, { types: { - RemoteDynamicGroup: { + [type]: { widget_order: ['rows', 'rows.0.strength', 'rows.1.strength'] } } @@ -215,7 +213,7 @@ describe('remote DynamicGroup row count reports', () => { .getNodeById(toNodeId(1)) ?.widgets?.find((widget) => widget.name === 'rows') if (!rows) throw new Error('DynamicGroup node 1 was not created') - function setRows(count: number) { + function setRows(count: unknown) { doc.transact(() => { const widgets = nodesMap(doc).get('1')?.get('widgets') if (!(widgets instanceof Y.Map)) throw new Error('named storage') @@ -234,13 +232,28 @@ describe('remote DynamicGroup row count reports', () => { expect(reportError).not.toHaveBeenCalled() }) + it.for([ + { type: 'RemoteDynamicGroup', value: 2.5, expected: 2 }, + { type: 'RemoteDynamicGroup', value: -0, expected: 0 }, + { type: 'MinOneDynamicGroup', value: 0, expected: 1 } + ])( + 'does not report a remote $value the $type setter normalizes', + ({ type, value, expected }) => { + const { rows, setRows } = remoteGroup(type) + + expect(setRows(value)).toBe(0) + expect(rows.value).toBe(expected) + expect(reportError).not.toHaveBeenCalled() + } + ) + it('reports a remote row count the live group did not reach, once per node type', () => { const { rows, setRows } = remoteGroup() refuseInputChanges() expect([setRows(3), setRows(2)]).toEqual([1, 1]) expect(rows.value).toBe(1) - expect(reportsOf('agent_graph_dynamic_group_rows_mismatch')).toEqual([ + expect(vi.mocked(reportError).mock.calls).toEqual([ [ expect.objectContaining({ message: 'Remote DynamicGroup row count did not apply' @@ -264,7 +277,7 @@ describe('remote DynamicGroup row count reports', () => { it('counts but does not send a mismatch without telemetry consent', () => { remoteConfig.value = {} - const { setRows } = remoteGroup() + const { setRows } = remoteGroup('ConsentDynamicGroup') refuseInputChanges() expect(setRows(2)).toBe(1) diff --git a/src/core/graph/widgets/dynamicGroupDiagnostics.ts b/src/core/graph/widgets/dynamicGroupDiagnostics.ts index 4d686bb63c0..5abe0a40b3b 100644 --- a/src/core/graph/widgets/dynamicGroupDiagnostics.ts +++ b/src/core/graph/widgets/dynamicGroupDiagnostics.ts @@ -9,6 +9,7 @@ type RowOperation = 'add_row' | 'remove_row' | 'remote_apply' const controllers = new WeakSet() const reported = new Set() +let applyingRemoteRowCount = false export function markDynamicGroupController(widget: IBaseWidget): void { controllers.add(widget) @@ -19,6 +20,28 @@ export function isDynamicGroupController(widget: IBaseWidget): boolean { return controllers.has(widget) } +/** + * Runs a remote row count write. A refusal inside it is reported once, as the + * remote mismatch, not also as a local row change. + */ +export function applyRemoteDynamicGroupRowCount(write: () => void): void { + applyingRemoteRowCount = true + try { + write() + } finally { + applyingRemoteRowCount = false + } +} + +/** Whether a controller holds the row count its setter derives from `value`. */ +export function reachesDynamicGroupRowCount( + widget: IBaseWidget, + value: unknown +): boolean { + if (typeof value !== 'number' || !Number.isFinite(value)) return false + return widget.value === Math.max(widget.options.min ?? 0, Math.trunc(value)) +} + function reportRowCount( node: LGraphNode, operation: RowOperation, @@ -55,6 +78,7 @@ export function reportDynamicGroupRowRefusal( requested: number, actual: number ): void { + if (applyingRemoteRowCount) return reportRowCount( node, operation, diff --git a/src/workbench/extensions/agent/crdt/liveGraphApplier.ts b/src/workbench/extensions/agent/crdt/liveGraphApplier.ts index f38b679102e..bf4c7be9d0e 100644 --- a/src/workbench/extensions/agent/crdt/liveGraphApplier.ts +++ b/src/workbench/extensions/agent/crdt/liveGraphApplier.ts @@ -9,7 +9,9 @@ import * as Y from 'yjs' import { z } from 'zod' import { + applyRemoteDynamicGroupRowCount, isDynamicGroupController, + reachesDynamicGroupRowCount, reportRemoteDynamicGroupRowMismatch } from '@/core/graph/widgets/dynamicGroupDiagnostics' import { growAutogrowInput } from '@/core/graph/widgets/dynamicWidgets' @@ -922,14 +924,9 @@ export class LiveGraphApplier { this.holdsLocalWrite(node, widget.name, value) ) continue - this.setWidgetValue(node, widget, value) - if (isDynamicGroupController(widget) && !Object.is(widget.value, value)) { - this.incrementFailureCount() - reportRemoteDynamicGroupRowMismatch(node, value, Number(widget.value), { - ...AGENT_APPLY_TAGS, - outcome: 'degraded' - }) - } + if (isDynamicGroupController(widget)) + this.applyDynamicGroupRowCount(node, widget, value) + else this.setWidgetValue(node, widget, value) resolved = true } return { resolved, unresolved } @@ -1057,6 +1054,22 @@ export class LiveGraphApplier { ) } + private applyDynamicGroupRowCount( + node: LGraphNode, + widget: IBaseWidget, + value: WidgetValue + ) { + applyRemoteDynamicGroupRowCount(() => + this.setWidgetValue(node, widget, value) + ) + if (reachesDynamicGroupRowCount(widget, value)) return + this.incrementFailureCount() + reportRemoteDynamicGroupRowMismatch(node, value, Number(widget.value), { + ...AGENT_APPLY_TAGS, + outcome: 'degraded' + }) + } + private setWidgetValue( node: LGraphNode, widget: IBaseWidget, From acd1db4502a58daf9feaf43e520417c672e7b83f Mon Sep 17 00:00:00 2001 From: jaeone94 <89377375+jaeone94@users.noreply.github.com> Date: Thu, 15 Oct 2026 10:02:27 +0900 Subject: [PATCH 3/4] fix: scope the remote row count guard to its node and restore it Nested remote writes no longer clear an outer guard, and a local refusal on another DynamicGroup during a remote write is still reported. --- .../widgets/dynamicGroupDiagnostics.test.ts | 22 ++++++++++++++++++- .../graph/widgets/dynamicGroupDiagnostics.ts | 18 +++++++++------ .../extensions/agent/crdt/liveGraphApplier.ts | 2 +- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts b/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts index 975ba4aa204..4cc1304ea58 100644 --- a/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts +++ b/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts @@ -7,6 +7,7 @@ import { remoteConfig } from '@/platform/remoteConfig/remoteConfig' import { reportError } from '@/platform/telemetry/reportError' import { useLitegraphService } from '@/services/litegraphService' import { useLinkStore } from '@/stores/linkStore' +import { applyRemoteDynamicGroupRowCount } from './dynamicGroupDiagnostics' import { toNodeId } from '@/types/nodeId' import { followedDoc } from '@/workbench/extensions/agent/crdt/__fixtures__/followedDoc' import { LiveGraphApplier } from '@/workbench/extensions/agent/crdt/liveGraphApplier' @@ -44,7 +45,7 @@ function group(type: string, { min = 0, count = 2 } = {}) { return found } widget('rows').value = count - return { widget } + return { node, widget } } function refuseInputChanges() { @@ -166,6 +167,25 @@ describe('DynamicGroup row refusal reports', () => { ) }) +describe('remote DynamicGroup row count writes', () => { + it('suppresses only the target node and restores an outer target', () => { + const outer = group('OuterRemoteTarget') + const inner = group('InnerRemoteTarget') + const other = group('LocalDuringRemote') + refuseInputChanges() + + applyRemoteDynamicGroupRowCount(outer.node, () => { + applyRemoteDynamicGroupRowCount(inner.node, () => {}) + outer.widget('rows').value = 3 + other.widget('rows').value = 3 + }) + + expect( + vi.mocked(reportError).mock.calls.map(([, options]) => options.tags) + ).toEqual([expect.objectContaining({ node_type: 'LocalDuringRemote' })]) + }) +}) + describe('remote DynamicGroup row count reports', () => { function remoteNodeType(min: number) { return class extends LGraphNode { diff --git a/src/core/graph/widgets/dynamicGroupDiagnostics.ts b/src/core/graph/widgets/dynamicGroupDiagnostics.ts index 5abe0a40b3b..d837b9188ab 100644 --- a/src/core/graph/widgets/dynamicGroupDiagnostics.ts +++ b/src/core/graph/widgets/dynamicGroupDiagnostics.ts @@ -9,7 +9,7 @@ type RowOperation = 'add_row' | 'remove_row' | 'remote_apply' const controllers = new WeakSet() const reported = new Set() -let applyingRemoteRowCount = false +let remoteRowCountNode: LGraphNode | undefined export function markDynamicGroupController(widget: IBaseWidget): void { controllers.add(widget) @@ -21,15 +21,19 @@ export function isDynamicGroupController(widget: IBaseWidget): boolean { } /** - * Runs a remote row count write. A refusal inside it is reported once, as the - * remote mismatch, not also as a local row change. + * Runs a remote row count write to `node`. A refusal on that node inside it is + * reported once, as the remote mismatch, not also as a local row change. */ -export function applyRemoteDynamicGroupRowCount(write: () => void): void { - applyingRemoteRowCount = true +export function applyRemoteDynamicGroupRowCount( + node: LGraphNode, + write: () => void +): void { + const previous = remoteRowCountNode + remoteRowCountNode = node try { write() } finally { - applyingRemoteRowCount = false + remoteRowCountNode = previous } } @@ -78,7 +82,7 @@ export function reportDynamicGroupRowRefusal( requested: number, actual: number ): void { - if (applyingRemoteRowCount) return + if (remoteRowCountNode === node) return reportRowCount( node, operation, diff --git a/src/workbench/extensions/agent/crdt/liveGraphApplier.ts b/src/workbench/extensions/agent/crdt/liveGraphApplier.ts index bf4c7be9d0e..b80e679501b 100644 --- a/src/workbench/extensions/agent/crdt/liveGraphApplier.ts +++ b/src/workbench/extensions/agent/crdt/liveGraphApplier.ts @@ -1059,7 +1059,7 @@ export class LiveGraphApplier { widget: IBaseWidget, value: WidgetValue ) { - applyRemoteDynamicGroupRowCount(() => + applyRemoteDynamicGroupRowCount(node, () => this.setWidgetValue(node, widget, value) ) if (reachesDynamicGroupRowCount(widget, value)) return From 047d1268dac4d7f30d54a944cc107711286e9412 Mon Sep 17 00:00:00 2001 From: jaeone94 <89377375+jaeone94@users.noreply.github.com> Date: Thu, 15 Oct 2026 12:32:40 +0900 Subject: [PATCH 4/4] test: assert the exact report list for each telemetry gate case --- .../graph/widgets/dynamicGroupDiagnostics.test.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts b/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts index 4cc1304ea58..409210a6bb4 100644 --- a/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts +++ b/src/core/graph/widgets/dynamicGroupDiagnostics.test.ts @@ -148,10 +148,11 @@ describe('DynamicGroup row refusal reports', () => { ]) }) + const resizeRefusal = ['failure_resizing_dynamic_group_rows'] it.for([ - { isCloud: false, enableTelemetry: false, reported: false }, - { isCloud: false, enableTelemetry: true, reported: true }, - { isCloud: true, enableTelemetry: false, reported: true } + { isCloud: false, enableTelemetry: false, reported: [] }, + { isCloud: false, enableTelemetry: true, reported: resizeRefusal }, + { isCloud: true, enableTelemetry: false, reported: resizeRefusal } ])( 'sends with cloud=$isCloud and host telemetry=$enableTelemetry: $reported', ({ isCloud, enableTelemetry, reported }) => { @@ -162,7 +163,11 @@ describe('DynamicGroup row refusal reports', () => { widget('rows').value = 3 - expect(vi.mocked(reportError).mock.calls.length > 0).toBe(reported) + expect( + vi + .mocked(reportError) + .mock.calls.map(([, options]) => options.errorType) + ).toEqual(reported) } ) })