[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
132
application/state/useTerminalSidePanelLayoutState.test.tsx
Normal file
132
application/state/useTerminalSidePanelLayoutState.test.tsx
Normal file
@@ -0,0 +1,132 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import React from 'react';
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer';
|
||||
|
||||
import { collectSidePanelPanes } from '../../domain/sidePanelLayout.ts';
|
||||
import { useTerminalSidePanelLayoutState } from './useTerminalSidePanelLayoutState.ts';
|
||||
|
||||
test('terminal side panel layouts stay isolated and keep one pane per tool', async () => {
|
||||
const actEnvironment = globalThis as typeof globalThis & {
|
||||
IS_REACT_ACT_ENVIRONMENT?: boolean;
|
||||
};
|
||||
const previousActEnvironment = actEnvironment.IS_REACT_ACT_ENVIRONMENT;
|
||||
actEnvironment.IS_REACT_ACT_ENVIRONMENT = true;
|
||||
let state: ReturnType<typeof useTerminalSidePanelLayoutState> | null = null;
|
||||
let renderer: ReactTestRenderer | null = null;
|
||||
|
||||
const Probe = () => {
|
||||
state = useTerminalSidePanelLayoutState();
|
||||
return null;
|
||||
};
|
||||
|
||||
try {
|
||||
await act(async () => {
|
||||
renderer = create(React.createElement(Probe));
|
||||
});
|
||||
await act(async () => {
|
||||
state?.setSidePanelOpenTabs(new Map([
|
||||
['terminal-a', 'notes'],
|
||||
['terminal-b', 'scripts'],
|
||||
]));
|
||||
});
|
||||
|
||||
const layoutA = state?.sidePanelLayouts.get('terminal-a');
|
||||
const layoutB = state?.sidePanelLayouts.get('terminal-b');
|
||||
assert.ok(layoutA);
|
||||
assert.ok(layoutB);
|
||||
|
||||
await act(async () => {
|
||||
state?.splitPane('terminal-a', 'ai', 'vertical', {
|
||||
paneId: 'pane-ai',
|
||||
splitId: 'split-a',
|
||||
}, 400);
|
||||
});
|
||||
assert.deepEqual(
|
||||
collectSidePanelPanes(state!.sidePanelLayouts.get('terminal-a')!.root).map((pane) => pane.tool),
|
||||
['notes', 'ai'],
|
||||
);
|
||||
assert.deepEqual(
|
||||
collectSidePanelPanes(state!.sidePanelLayouts.get('terminal-b')!.root).map((pane) => pane.tool),
|
||||
['scripts'],
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
state?.splitPane('terminal-a', 'notes', 'horizontal', {
|
||||
paneId: 'unused-pane',
|
||||
splitId: 'unused-split',
|
||||
}, 400);
|
||||
});
|
||||
const focused = state!.sidePanelLayouts.get('terminal-a')!;
|
||||
assert.equal(collectSidePanelPanes(focused.root).length, 2);
|
||||
assert.equal(state!.sidePanelOpenTabs.get('terminal-a'), 'notes');
|
||||
|
||||
// External open paths still write the focused-tool map. They must replace
|
||||
// only the focused pane, then focus an existing pane without duplicating it.
|
||||
await act(async () => {
|
||||
state?.setSidePanelOpenTabs((current) => new Map(current).set('terminal-a', 'system'));
|
||||
});
|
||||
assert.deepEqual(
|
||||
collectSidePanelPanes(state!.sidePanelLayouts.get('terminal-a')!.root).map((pane) => pane.tool),
|
||||
['system', 'ai'],
|
||||
);
|
||||
await act(async () => {
|
||||
state?.setSidePanelOpenTabs((current) => new Map(current).set('terminal-a', 'ai'));
|
||||
});
|
||||
const externallyFocused = state!.sidePanelLayouts.get('terminal-a')!;
|
||||
assert.deepEqual(collectSidePanelPanes(externallyFocused.root).map((pane) => pane.tool), ['system', 'ai']);
|
||||
assert.equal(state!.sidePanelOpenTabs.get('terminal-a'), 'ai');
|
||||
assert.equal(
|
||||
collectSidePanelPanes(externallyFocused.root).find((pane) => pane.id === externallyFocused.focusedPaneId)?.tool,
|
||||
'ai',
|
||||
);
|
||||
} finally {
|
||||
await act(async () => {
|
||||
renderer?.unmount();
|
||||
});
|
||||
actEnvironment.IS_REACT_ACT_ENVIRONMENT = previousActEnvironment;
|
||||
}
|
||||
});
|
||||
|
||||
test('closing the final pane removes only that terminal side panel state', async () => {
|
||||
const actEnvironment = globalThis as typeof globalThis & {
|
||||
IS_REACT_ACT_ENVIRONMENT?: boolean;
|
||||
};
|
||||
const previousActEnvironment = actEnvironment.IS_REACT_ACT_ENVIRONMENT;
|
||||
actEnvironment.IS_REACT_ACT_ENVIRONMENT = true;
|
||||
let state: ReturnType<typeof useTerminalSidePanelLayoutState> | null = null;
|
||||
let renderer: ReactTestRenderer | null = null;
|
||||
|
||||
const Probe = () => {
|
||||
state = useTerminalSidePanelLayoutState();
|
||||
return null;
|
||||
};
|
||||
|
||||
try {
|
||||
await act(async () => {
|
||||
renderer = create(React.createElement(Probe));
|
||||
});
|
||||
await act(async () => {
|
||||
state?.setSidePanelOpenTabs(new Map([
|
||||
['terminal-a', 'notes'],
|
||||
['terminal-b', 'scripts'],
|
||||
]));
|
||||
});
|
||||
const paneId = state!.sidePanelLayouts.get('terminal-a')!.focusedPaneId;
|
||||
|
||||
let closedLast = false;
|
||||
await act(async () => {
|
||||
closedLast = state!.closePane('terminal-a', paneId);
|
||||
});
|
||||
|
||||
assert.equal(closedLast, true);
|
||||
assert.equal(state!.sidePanelLayouts.has('terminal-a'), false);
|
||||
assert.equal(state!.sidePanelOpenTabs.has('terminal-a'), false);
|
||||
assert.equal(state!.sidePanelLayouts.has('terminal-b'), true);
|
||||
} finally {
|
||||
await act(async () => {
|
||||
renderer?.unmount();
|
||||
});
|
||||
actEnvironment.IS_REACT_ACT_ENVIRONMENT = previousActEnvironment;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user