wired-tools: hoist inline editor state (variables + managed holder) to the store

Move the four inline-editor useStates out of WiredCreatorToolsView and
into useWiredCreatorToolsUiStore:

- editingVariable / editingValue — Inspection-tab variables-table
  inline edit (current key being edited + in-flight input text).
- editingManagedHolderVariableId / editingManagedHolderValue — same
  pair for the Variable Manage panel's holder rows (id 0 = none).

WiredInspectionTabView drops three more props (editingVariable,
editingValue, onEditingValueChange) and consumes the store directly
for the read sides + the per-keystroke setEditingValue. The cancel /
keydown / begin handlers stay in the parent because they wrap
shouldPauseVariableSnapshotRefresh-aware logic plus selection
bookkeeping that doesn't belong to a pure tab body.

The shouldPauseVariableSnapshotRefresh derived flag still reads from
the same store now-backed values; no behaviour change on the polling
suppression path.

Tests: three new cases (set+read pair, null-clear, managed-holder
0-as-sentinel reset). 193/193 passing.
This commit is contained in:
simoleo89
2026-05-16 12:37:29 +02:00
parent c1aafffd09
commit 181ca096d0
4 changed files with 97 additions and 17 deletions
@@ -24,7 +24,11 @@ const INITIAL = {
selectedUserLiveState: null,
selectedUserActionVersion: 0,
isVariableHighlightActive: false,
variableHighlightOverlays: []
variableHighlightOverlays: [],
editingVariable: null,
editingValue: '',
editingManagedHolderVariableId: 0,
editingManagedHolderValue: ''
};
describe('useWiredCreatorToolsUiStore', () =>
@@ -60,6 +64,10 @@ describe('useWiredCreatorToolsUiStore', () =>
expect(state.selectedUserActionVersion).toBe(0);
expect(state.isVariableHighlightActive).toBe(false);
expect(state.variableHighlightOverlays).toEqual([]);
expect(state.editingVariable).toBeNull();
expect(state.editingValue).toBe('');
expect(state.editingManagedHolderVariableId).toBe(0);
expect(state.editingManagedHolderValue).toBe('');
});
describe('setIsVisible', () =>
@@ -356,4 +364,44 @@ describe('useWiredCreatorToolsUiStore', () =>
expect(useWiredCreatorToolsUiStore.getState().variableHighlightOverlays).toEqual([ overlay ]);
});
});
describe('inline editor', () =>
{
it('setEditingVariable + setEditingValue track the in-flight edit', () =>
{
useWiredCreatorToolsUiStore.getState().setEditingVariable('@state');
useWiredCreatorToolsUiStore.getState().setEditingValue('3');
expect(useWiredCreatorToolsUiStore.getState().editingVariable).toBe('@state');
expect(useWiredCreatorToolsUiStore.getState().editingValue).toBe('3');
});
it('setEditingVariable(null) clears the edit (commit / cancel path)', () =>
{
useWiredCreatorToolsUiStore.getState().setEditingVariable('@state');
useWiredCreatorToolsUiStore.getState().setEditingValue('3');
useWiredCreatorToolsUiStore.getState().setEditingVariable(null);
useWiredCreatorToolsUiStore.getState().setEditingValue('');
expect(useWiredCreatorToolsUiStore.getState().editingVariable).toBeNull();
expect(useWiredCreatorToolsUiStore.getState().editingValue).toBe('');
});
it('managed-holder editor pair uses 0 as "no row being edited"', () =>
{
useWiredCreatorToolsUiStore.getState().setEditingManagedHolderVariableId(42);
useWiredCreatorToolsUiStore.getState().setEditingManagedHolderValue('15');
expect(useWiredCreatorToolsUiStore.getState().editingManagedHolderVariableId).toBe(42);
expect(useWiredCreatorToolsUiStore.getState().editingManagedHolderValue).toBe('15');
// Reset path used after commit / on blur.
useWiredCreatorToolsUiStore.getState().setEditingManagedHolderVariableId(0);
useWiredCreatorToolsUiStore.getState().setEditingManagedHolderValue('');
expect(useWiredCreatorToolsUiStore.getState().editingManagedHolderVariableId).toBe(0);
expect(useWiredCreatorToolsUiStore.getState().editingManagedHolderValue).toBe('');
});
});
});