Merge tidy: shared text helpers, hook readability pass, Biome lint

This commit is contained in:
Callum Alpass committed 2026-11-02 23:03:07 +11:00
commit 273feb4294
28 files changed
+983 -349

No files matched your search

+12 -2
View File
@@ -78,7 +78,12 @@ describe("commands tui3 dispatches", () => {
test("a new thread launches with a payload the server accepts", async () => {
const session = new T3Session();
let payload: unknown;
const rpc = { "orchestration.launchThread": (input: unknown) => ((payload = input), Effect.succeed({ threadId: ThreadId.make("new-1") })) };
const rpc = {
"orchestration.launchThread": (input: unknown) => {
payload = input;
return Effect.succeed({ threadId: ThreadId.make("new-1") });
},
};
(session as unknown as { connection: unknown }).connection = { rpc };
const id = await session.launchThread({
projectId: ProjectId.make("p1"),
@@ -104,7 +109,12 @@ describe("commands tui3 dispatches", () => {
const launching = new T3Session();
let payload: unknown;
const rpc = { "orchestration.launchThread": (input: unknown) => ((payload = input), Effect.succeed({ threadId: ThreadId.make("new-2") })) };
const rpc = {
"orchestration.launchThread": (input: unknown) => {
payload = input;
return Effect.succeed({ threadId: ThreadId.make("new-2") });
},
};
(launching as unknown as { connection: unknown }).connection = { rpc };
await launching.launchThread({
projectId: ProjectId.make("p1"),
+4 -1
View File
@@ -5,7 +5,10 @@ import { splitPatch, wholeFilePatch } from "../src/model/diffs.ts";
const changed = "diff --git a/a.ts b/a.ts\n--- a/a.ts\n+++ b/a.ts\n@@ -2 +2 @@\n-old\n+new\n";
test("diff files retain old paths and change types for contents requests", () => {
const files = splitPatch(changed + "diff --git a/old.ts b/new.ts\nsimilarity index 100%\nrename from old.ts\nrename to new.ts\n" + "diff --git a/gone.ts b/gone.ts\ndeleted file mode 100644\n--- a/gone.ts\n+++ /dev/null\n@@ -1 +0,0 @@\n-gone\n" + "diff --git a/add.ts b/add.ts\nnew file mode 100644\n--- /dev/null\n+++ b/add.ts\n@@ -0,0 +1 @@\n+added\n");
const renamed = "diff --git a/old.ts b/new.ts\nsimilarity index 100%\nrename from old.ts\nrename to new.ts\n";
const deleted = "diff --git a/gone.ts b/gone.ts\ndeleted file mode 100644\n--- a/gone.ts\n+++ /dev/null\n@@ -1 +0,0 @@\n-gone\n";
const added = "diff --git a/add.ts b/add.ts\nnew file mode 100644\n--- /dev/null\n+++ b/add.ts\n@@ -0,0 +1 @@\n+added\n";
const files = splitPatch(`${changed}${renamed}${deleted}${added}`);
expect(files.map(({ path, oldPath, changeType }) => ({ path, oldPath, changeType }))).toEqual([
{ path: "a.ts", oldPath: "a.ts", changeType: "change" }, { path: "new.ts", oldPath: "old.ts", changeType: "rename-pure" },
{ path: "gone.ts", oldPath: "gone.ts", changeType: "deleted" }, { path: "add.ts", oldPath: "add.ts", changeType: "new" },
+4 -1
View File
@@ -261,7 +261,10 @@ describe("pull request commands and payloads", () => {
const payloads = new Map<string, unknown>();
const capture =
(method: string, result: unknown) =>
(input: unknown) => (payloads.set(method, input), Effect.succeed(result));
(input: unknown) => {
payloads.set(method, input);
return Effect.succeed(result);
};
const rpc = {
"pullRequests.list": capture("list", listResult([])),
"pullRequests.detail": capture("detail", detail()),
+28
View File
@@ -0,0 +1,28 @@
import { describe, expect, test } from "bun:test";
import { firstLine, truncate } from "../src/ui/text.ts";
describe("truncate", () => {
test("collapses whitespace and clips with an ellipsis", () => {
expect(truncate("a b\nc", 10)).toBe("a b c");
expect(truncate("abcdef", 4)).toBe("abc…");
expect(truncate("abcdef", 0)).toBe("…");
});
test("keeps leading whitespace collapsed to one space", () => {
// The majority of the old copies did not trim; only QueuePanel's did.
expect(truncate(" hi", 10)).toBe(" hi");
});
});
describe("firstLine", () => {
test("takes the first trimmed line, collapsed", () => {
expect(firstLine(" hello world\nsecond line")).toBe("hello world");
expect(firstLine("")).toBe("");
});
test("caps at 100 characters", () => {
const long = "x".repeat(150);
expect(firstLine(long)).toBe(`${"x".repeat(99)}…`);
});
});
+3 -1
View File
@@ -77,7 +77,9 @@ describe("workspace RPC payloads (no live mutations)", () => {
await session.cancelWorktreeSetup(threadId);
expect(sent.map((call) => call.method)).toEqual(["vcs.switchRef", "vcs.createRef", "vcs.pull", "vcs.createWorktree", "vcs.removeWorktree", "shell.openInEditor", "worktreeSetup.cancel"]);
const schemas = [VcsSwitchRefInput, VcsCreateRefInput, VcsPullInput, VcsCreateWorktreeInput, VcsRemoveWorktreeInput, LaunchEditorInput, WorktreeSetupCancelInput];
schemas.forEach((schema, index) => expect(Schema.is(schema)(sent[index]!.input)).toBe(true));
schemas.forEach((schema, index) => {
expect(Schema.is(schema)(sent[index]!.input)).toBe(true);
});
expect(sent[1]!.input).toMatchObject({ switchRef: true });
expect(sent[3]!.input).toEqual({ cwd: "/repo", refName: "main", newRefName: "new-work", path: null });
expect(sent[4]!.input).not.toHaveProperty("force");