[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,126 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { extractRootPathsFromDropEntries } from './terminalHelpers.ts';
// Inline copy of extractRootPathsFromClipboardFiles for standalone test
function extractRootPathsFromClipboardFiles(
files: Array<{ path: string; name: string; isDirectory: boolean; size?: number }>,
): string[] {
const paths: string[] = [];
const seenPaths = new Set<string>();
for (const file of files) {
const fullPath = file.path;
if (!fullPath || seenPaths.has(fullPath)) continue;
paths.push(fullPath.includes(' ') ? `"${fullPath}"` : fullPath);
seenPaths.add(fullPath);
}
return paths;
}
describe('extractRootPathsFromClipboardFiles', () => {
it('single file path', () => {
assert.deepEqual(
extractRootPathsFromClipboardFiles([{
path: '/home/user/file.txt', name: 'file.txt', isDirectory: false, size: 100,
}]),
['/home/user/file.txt'],
);
});
it('multiple files', () => {
assert.deepEqual(
extractRootPathsFromClipboardFiles([
{ path: '/home/a.txt', name: 'a.txt', isDirectory: false, size: 10 },
{ path: '/home/b.txt', name: 'b.txt', isDirectory: false, size: 20 },
]),
['/home/a.txt', '/home/b.txt'],
);
});
it('quotes paths with spaces', () => {
assert.deepEqual(
extractRootPathsFromClipboardFiles([{
path: '/home/user/my file.txt', name: 'my file.txt', isDirectory: false, size: 100,
}]),
['"/home/user/my file.txt"'],
);
});
it('deduplicates', () => {
assert.deepEqual(
extractRootPathsFromClipboardFiles([
{ path: '/home/file.txt', name: 'file.txt', isDirectory: false, size: 10 },
{ path: '/home/file.txt', name: 'file.txt', isDirectory: false, size: 10 },
]),
['/home/file.txt'],
);
});
it('handles directory entries', () => {
assert.deepEqual(
extractRootPathsFromClipboardFiles([{
path: '/home/myfolder', name: 'myfolder', isDirectory: true, size: 0,
}]),
['/home/myfolder'],
);
});
it('filters out empty paths', () => {
assert.deepEqual(
extractRootPathsFromClipboardFiles([{
path: '', name: 'empty', isDirectory: false,
}]),
[],
);
});
it('Windows-style paths', () => {
assert.deepEqual(
extractRootPathsFromClipboardFiles([{
path: 'C:\\Users\\test\\file.txt', name: 'file.txt', isDirectory: false, size: 100,
}]),
['C:\\Users\\test\\file.txt'],
);
});
it('empty list', () => {
assert.deepEqual(extractRootPathsFromClipboardFiles([]), []);
});
it('multiple spaced paths', () => {
assert.deepEqual(
extractRootPathsFromClipboardFiles([
{ path: '/home/user/a b.txt', name: 'a b.txt', isDirectory: false, size: 10 },
{ path: '/home/user/c d.txt', name: 'c d.txt', isDirectory: false, size: 20 },
]),
['"/home/user/a b.txt"', '"/home/user/c d.txt"'],
);
});
});
describe('extractRootPathsFromDropEntries', () => {
it('uses a reconstructed DropEntry local path when File.path is unavailable', () => {
const fileWithoutPath = { name: 'child.txt' } as File;
assert.deepEqual(
extractRootPathsFromDropEntries([{
file: fileWithoutPath,
localPath: '/home/user/folder/child.txt',
relativePath: 'folder/child.txt',
isDirectory: false,
}]),
['/home/user/folder'],
);
});
it('uses native path-only entries from a folder scan', () => {
assert.deepEqual(
extractRootPathsFromDropEntries([{
file: null,
localPath: '/home/user/folder/src/main.ts',
relativePath: 'folder/src/main.ts',
isDirectory: false,
}]),
['/home/user/folder'],
);
});
});