mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 07:32:54 +00:00
* feat(terminal): add Directory Picker context chip * fix(terminal): bind directory reads to the exact SSH session * fix(terminal): follow manually changed working directories * fix(terminal): isolate cwd updates and gate local platform support * docs(terminal): research Directory Picker cross-platform follow-up * fix(terminal): confirm OSC 7 navigation and reset picker loading * fix(terminal): preserve active shell OSC 7 during directory refresh * test(terminal): retain cross-session OSC 7 submission guard --------- Co-authored-by: Joseph Hau <hexart@gmail.com>
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { terminalCwdStore } from './terminalCwdStore.ts';
|
|
|
|
test('terminalCwdStore bumps version only when cwd or provenance changes', () => {
|
|
const versions: number[] = [];
|
|
const unsubscribe = terminalCwdStore.subscribe(() => {
|
|
versions.push(terminalCwdStore.getVersion());
|
|
});
|
|
|
|
const baseVersion = terminalCwdStore.getVersion();
|
|
assert.equal(terminalCwdStore.setCwd('s1', '/tmp'), true);
|
|
assert.equal(terminalCwdStore.getCwd('s1'), '/tmp');
|
|
assert.equal(terminalCwdStore.getVersion(), baseVersion + 1);
|
|
|
|
assert.equal(terminalCwdStore.setCwd('s1', '/tmp'), false);
|
|
assert.equal(terminalCwdStore.getVersion(), baseVersion + 1);
|
|
|
|
assert.equal(terminalCwdStore.setCwd('s1', '/var'), true);
|
|
assert.equal(terminalCwdStore.getCwd('s1'), '/var');
|
|
|
|
assert.equal(terminalCwdStore.setCwd('s1', '/var', 'backend-strict'), true);
|
|
assert.equal(terminalCwdStore.getSource('s1'), 'backend-strict');
|
|
assert.equal(terminalCwdStore.setCwd('s1', '/var', 'backend-strict'), false);
|
|
|
|
terminalCwdStore.prune(new Set());
|
|
assert.equal(terminalCwdStore.getCwd('s1'), null);
|
|
|
|
unsubscribe();
|
|
assert.ok(versions.length >= 2);
|
|
});
|
|
|
|
test('session revisions isolate terminals and retain identical OSC 7 reports without rerendering', () => {
|
|
const a = 'revision-a'; const b = 'revision-b';
|
|
terminalCwdStore.setCwd(a, '/same', 'osc7');
|
|
const revisionA = terminalCwdStore.getSessionRevision(a);
|
|
terminalCwdStore.setCwd(b, '/elsewhere', 'osc7');
|
|
assert.equal(terminalCwdStore.getSessionRevision(a), revisionA);
|
|
const globalVersion = terminalCwdStore.getVersion();
|
|
assert.equal(terminalCwdStore.setCwd(a, '/same', 'osc7'), false);
|
|
assert.ok(terminalCwdStore.getSessionRevision(a) > revisionA);
|
|
assert.equal(terminalCwdStore.getVersion(), globalVersion);
|
|
const revisionB = terminalCwdStore.getSessionRevision(b);
|
|
terminalCwdStore.prune(new Set([b]));
|
|
assert.equal(terminalCwdStore.getSessionRevision(a), 0);
|
|
assert.equal(terminalCwdStore.getSessionRevision(b), revisionB);
|
|
terminalCwdStore.prune(new Set());
|
|
});
|