feat: convert file manager into a plugin

This commit is contained in:
LukeGus committed 2026-09-23 16:27:29 -05:00
1 parent b76da9ab52
commit c85c1fdb86
259 files changed
+54155 -16791

No files matched your search

@@ -1,49 +0,0 @@
import { describe, expect, it, vi } from "vitest";
import {
getCachedFileContent,
invalidateCachedFileContent,
shouldPrefetchFileContent,
} from "../../lib/file-content-request-cache";
describe("file content request cache", () => {
it("coalesces reads and reloads after invalidation", async () => {
const loader = vi.fn(async () => ({ content: "hello", path: "/note" }));
await Promise.all([
getCachedFileContent("session", "/note", loader),
getCachedFileContent("session", "/note", loader),
]);
expect(loader).toHaveBeenCalledOnce();
invalidateCachedFileContent("session", "/note");
await getCachedFileContent("session", "/note", loader);
expect(loader).toHaveBeenCalledTimes(2);
});
it("only prefetches known small files on an unconstrained network", () => {
expect(
shouldPrefetchFileContent(
{ name: "note", path: "/note", type: "file", size: 512 * 1024 },
512 * 1024,
),
).toBe(true);
expect(
shouldPrefetchFileContent(
{ name: "large", path: "/large", type: "file", size: 512 * 1024 + 1 },
512 * 1024,
),
).toBe(false);
expect(
shouldPrefetchFileContent(
{ name: "unknown", path: "/unknown", type: "file" },
512 * 1024,
),
).toBe(false);
expect(
shouldPrefetchFileContent(
{ name: "note", path: "/note", type: "file", size: 100 },
0,
),
).toBe(false);
});
});
@@ -1,30 +0,0 @@
import { renderHook, waitFor } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import {
computeReconnectDelay,
useConnectionRetry,
} from "../../lib/useConnectionRetry.ts";
describe("connection retry delay", () => {
it("uses exponential backoff with bounded jitter", () => {
expect(computeReconnectDelay(1, 2000, 8000, () => 0.5)).toBe(2000);
expect(computeReconnectDelay(2, 2000, 8000, () => 0)).toBe(3600);
expect(computeReconnectDelay(2, 2000, 8000, () => 1)).toBe(4400);
});
it("never exceeds the configured cap", () => {
expect(computeReconnectDelay(8, 2000, 8000, () => 1)).toBe(8000);
});
});
describe("useConnectionRetry", () => {
it("turns a rejected async connection into a failed state", async () => {
const connect = vi.fn().mockRejectedValue(new Error("offline"));
const { result } = renderHook(() =>
useConnectionRetry({ connect, enabled: false }),
);
await waitFor(() => expect(result.current.status).toBe("error"));
expect(connect).toHaveBeenCalledOnce();
});
});