[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

This commit is contained in:
2026-09-13 18:24:01 +08:00
commit 3c72efcb7f
3255 changed files with 907009 additions and 0 deletions

View File

@@ -0,0 +1,130 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import type { Host } from '../../types';
import {
buildWorkSurfaceHostEditorKey,
mergeWorkSurfaceHostDraft,
saveWorkSurfaceHostDraft,
shouldCloseDeletedWorkSurfaceHost,
type WorkSurfaceHostEditorTarget,
} from './useWorkSurfaceHostEditor';
const host = (overrides: Partial<Host> = {}): Host => ({
id: 'host-1',
label: 'web',
hostname: '10.0.0.1',
username: 'root',
port: 22,
protocol: 'ssh',
tags: [],
os: 'linux',
createdAt: 1,
...overrides,
});
test('editor keys separate new requests and edit targets', () => {
assert.equal(
buildWorkSurfaceHostEditorKey({ mode: 'edit', openedHost: host(), requestId: 1 }),
'edit:host-1:1',
);
assert.equal(
buildWorkSurfaceHostEditorKey({ mode: 'new', defaultGroup: 'prod', requestId: 2 }),
'new:prod:2',
);
});
test('saving an edited host updates in place and preserves a concurrent display setting', () => {
const opened = host({ showLineTimestamps: false });
const latest = host({ showLineTimestamps: true });
const draft = host({ label: 'web-2', showLineTimestamps: false });
assert.deepEqual(
saveWorkSurfaceHostDraft(
[latest],
{ mode: 'edit', openedHost: opened, requestId: 1 },
draft,
),
[host({ label: 'web-2', showLineTimestamps: true })],
);
});
test('saving preserves every field that changed elsewhere while the editor was open', () => {
const opened = host({
group: 'old-group',
charset: 'utf-8',
distro: 'debian',
algorithms: { kex: ['base-kex'] },
});
const latest = host({
group: 'moved-group',
charset: 'gbk',
distro: 'ubuntu',
lastConnectedAt: 42,
algorithms: { kex: ['base-kex'], cipher: ['runtime-cipher'] },
});
const draft = host({
label: 'renamed-in-editor',
group: 'old-group',
charset: 'utf-8',
distro: 'debian',
algorithms: { kex: ['base-kex'], hmac: ['editor-hmac'] },
});
assert.deepEqual(mergeWorkSurfaceHostDraft(opened, draft, latest), host({
label: 'renamed-in-editor',
group: 'moved-group',
charset: 'gbk',
distro: 'ubuntu',
lastConnectedAt: 42,
algorithms: {
kex: ['base-kex'],
cipher: ['runtime-cipher'],
hmac: ['editor-hmac'],
},
}));
});
test('saving keeps intentional clears instead of restoring the latest value', () => {
const opened = host({ notes: 'old note' });
const draft = host();
const latest = host({ notes: 'changed elsewhere' });
assert.deepEqual(mergeWorkSurfaceHostDraft(opened, draft, latest), draft);
});
test('saving merges independently added settings inside a previously absent object', () => {
const opened = host();
const draft = host({ algorithms: { hmac: ['editor-hmac'] } });
const latest = host({ algorithms: { cipher: ['runtime-cipher'] } });
assert.deepEqual(mergeWorkSurfaceHostDraft(opened, draft, latest), host({
algorithms: {
cipher: ['runtime-cipher'],
hmac: ['editor-hmac'],
},
}));
});
test('saving a new host appends it', () => {
const created = host({ id: 'host-2' });
assert.deepEqual(
saveWorkSurfaceHostDraft(
[host()],
{ mode: 'new', defaultGroup: null, requestId: 1 },
created,
),
[host(), created],
);
});
test('an edit target closes after external deletion and cannot be recreated', () => {
const target: WorkSurfaceHostEditorTarget = {
mode: 'edit',
openedHost: host(),
requestId: 1,
};
assert.equal(shouldCloseDeletedWorkSurfaceHost([], target), true);
assert.equal(saveWorkSurfaceHostDraft([], target, host({ label: 'stale' })), null);
});