Gateway: snooze finished threads, and name the files a file approval would change
Gateway / check (push) Successful in 9s
Gateway / image (push) Successful in 22s

This commit is contained in:
gib committed 2026-11-02 14:20:39 -05:00
1 parent d10df56cc9
commit 4dc4e57dac
8 files changed
+295 -10

No files matched your search

+47 -1
View File
@@ -2,7 +2,7 @@ import { describe, expect, it } from "bun:test";
import type { BoundedThread, ThreadShell } from "../src/t3/types.ts";
import type { T3Host } from "../src/t3/host.ts";
import { agentProviders, buildFeed, currentActivity, latestChanges, searchThreads, loadHistory, projectThreads, buildSummary, routeKind, summarize, SummaryCache, trimText } from "../src/views.ts";
import { agentProviders, buildFeed, currentActivity, feedCandidates, latestChanges, pendingFiles, searchThreads, loadHistory, projectThreads, buildSummary, routeKind, summarize, SummaryCache, trimText } from "../src/views.ts";
const thread = (overrides: Partial<ThreadShell> = {}): ThreadShell => ({
id: "thread-1",
@@ -73,6 +73,7 @@ describe("summarize", () => {
{ decision: "acceptAlways", label: "Always allow", warning: "Applies to every thread" },
{ decision: "decline", label: "Deny" },
],
files: [],
questions: [],
});
});
@@ -343,3 +344,48 @@ describe("searchThreads", () => {
expect(result.unsearched).toEqual(["Laptop"]);
});
});
describe("pendingFiles", () => {
it("lists the run's unfinished file changes with whatever counts and diff the server sent", () => {
const files = pendingFiles(
[
{ type: "file_change", runId: "run-2", status: "completed", fileName: "done.ts" },
{ type: "file_change", runId: "run-2", status: "pending", fileName: "deploy/compose.yml", additions: 2, deletions: 1, diffStr: "--- a/compose.yml\n+++ b/compose.yml\n@@ -1 +1,2 @@\n- image: bun:1\n+ image: bun:1-alpine\n+ restart: always" },
],
"run-2",
"Edit: deploy/compose.yml",
);
expect(files).toEqual([
{ path: "deploy/compose.yml", name: "compose.yml", additions: 2, deletions: 1, preview: ["- image: bun:1", "+ image: bun:1-alpine", "+ restart: always"] },
]);
});
it("falls back to the path in Claude's prompt when no change is in the window", () => {
expect(pendingFiles([], "run-1", "Edit: /home/me/app/src/main.ts")).toEqual([
{ path: "/home/me/app/src/main.ts", name: "main.ts", additions: null, deletions: null, preview: [] },
]);
});
});
describe("snoozed threads", () => {
it("leave Recent until their time comes, the soonest first", () => {
const now = Date.parse("2026-11-01T12:00:00.000Z");
const host = {
id: "Desktop",
label: "Desktop",
threads: new Map(
[
thread({ id: "done", status: "completed" }),
thread({ id: "later", status: "completed", snoozedUntil: "2026-11-02T09:00:00.000Z" }),
thread({ id: "soon", status: "completed", snoozedUntil: "2026-11-01T13:00:00.000Z" }),
thread({ id: "woke", status: "completed", snoozedUntil: "2026-11-01T11:00:00.000Z" }),
thread({ id: "busy", status: "running", snoozedUntil: "2026-11-02T09:00:00.000Z" }),
].map((t) => [t.id, t]),
),
} as unknown as T3Host;
const { recent, snoozed, working } = feedCandidates([host], now);
expect(recent.map(({ thread }) => thread.id).sort()).toEqual(["done", "woke"]);
expect(snoozed.map(({ thread }) => thread.id)).toEqual(["soon", "later"]);
expect(working.map(({ thread }) => thread.id)).toEqual(["busy"]);
});
});