[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,51 @@
import assert from "node:assert/strict";
import test from "node:test";
import {
getDirectoryCacheEntry,
setDirectoryCacheEntry,
type DirectoryListingCache,
} from "./directoryListingCache";
const files = (count: number) => Array.from({ length: count }, (_value, index) => ({
name: `file-${index}`,
})) as never[];
test("directory cache removes expired entries when it is read", () => {
const cache: DirectoryListingCache = new Map([
["expired", { files: files(1), timestamp: 0 }],
["fresh", { files: files(1), timestamp: 95 }],
]);
assert.equal(getDirectoryCacheEntry(cache, "fresh", 100, 10)?.files.length, 1);
assert.equal(cache.has("expired"), false);
});
test("directory cache evicts least-recently-used listings by entry count", () => {
const cache: DirectoryListingCache = new Map();
setDirectoryCacheEntry(cache, "a", { files: files(1), timestamp: 1 }, { now: 1, ttlMs: 1_000, maxEntries: 2 });
setDirectoryCacheEntry(cache, "b", { files: files(1), timestamp: 2 }, { now: 2, ttlMs: 1_000, maxEntries: 2 });
assert.ok(getDirectoryCacheEntry(cache, "a", 3, 1_000));
setDirectoryCacheEntry(cache, "c", { files: files(1), timestamp: 4 }, { now: 4, ttlMs: 1_000, maxEntries: 2 });
assert.deepEqual([...cache.keys()], ["a", "c"]);
});
test("directory cache bounds retained file rows", () => {
const cache: DirectoryListingCache = new Map();
setDirectoryCacheEntry(cache, "large-a", { files: files(6), timestamp: 1 }, { now: 1, ttlMs: 1_000, maxFiles: 10 });
setDirectoryCacheEntry(cache, "large-b", { files: files(6), timestamp: 2 }, { now: 2, ttlMs: 1_000, maxFiles: 10 });
assert.deepEqual([...cache.keys()], ["large-b"]);
});
test("directory cache does not retain one listing larger than the file budget", () => {
const cache: DirectoryListingCache = new Map();
setDirectoryCacheEntry(
cache,
"oversized",
{ files: files(11), timestamp: 1 },
{ now: 1, ttlMs: 1_000, maxFiles: 10 },
);
assert.equal(cache.has("oversized"), false);
});