Add diffs, git actions, servers, automations and a command palette

- Details rows are actionable: view the working-tree diff (whole or per
  file), run the web app's git quick action or menu after a confirmation,
  stop a local server, run or toggle an automation, open lineage threads.
- Command palette (ctrl+k or :) searching commands and threads with T3's
  own scoring.
- Subagent work entries link to their child threads; u goes to the parent.
- Threads open scrolled to the bottom.
- Mouse: thread rows, collapsed sections, details rows, palette, composer.
- The / filter opens in the thread list.
- Multi-line composer: shift+enter, ctrl+j, or a trailing backslash; it
  grows to 8 lines.
- The credential asks for filesystem:read, source-control:write and
  terminal:operate, and is reissued when a stored one lacks them.
This commit is contained in:
Callum Alpass committed 2026-11-02 18:11:48 +11:00
1 parent 248603d9ae
commit ed36949fa7
15 files changed
+1235 -192

No files matched your search

+28 -9
View File
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
import type { OrchestrationProjectShell, OrchestrationV2ShellSnapshot, OrchestrationV2ThreadShell } from "@t3tools/contracts";
import type { VcsState } from "../src/client/session.ts";
import { detailsCwd, threadDetails } from "../src/model/details.ts";
import { detailsActions, detailsCwd, threadDetails } from "../src/model/details.ts";
const project = { id: "p1", title: "tasknotes", workspaceRoot: "/repo/tasknotes" } as unknown as OrchestrationProjectShell;
const thread = (extra: Record<string, unknown> = {}) =>
@@ -38,9 +38,12 @@ const vcs = (local: Record<string, unknown>, remote: Record<string, unknown> | n
remote,
}) as unknown as VcsState;
const detailsOf = (t: OrchestrationV2ThreadShell, v: VcsState | null, snapshot: OrchestrationV2ShellSnapshot | null, extra: Partial<Parameters<typeof threadDetails>[0]> = {}) =>
threadDetails({ thread: t, project, vcs: v, snapshot, ...extra });
describe("threadDetails", () => {
test("runs git in the worktree and labels the workspace", () => {
const details = threadDetails(thread(), project, null, null);
const details = detailsOf(thread(), null, null);
expect(detailsCwd(thread(), project)).toBe("/repo/tasknotes-wt/sync");
expect(detailsCwd(thread({ worktreePath: null }), project)).toBe("/repo/tasknotes");
expect(details.workspace).toEqual({ path: "/repo/tasknotes-wt/sync", worktree: true, model: "gpt-5", mode: "Build · Supervised" });
@@ -50,9 +53,8 @@ describe("threadDetails", () => {
});
test("shows changes, ahead/behind and the remote's PR", () => {
const details = threadDetails(
const details = detailsOf(
thread(),
project,
vcs(
{
workingTree: { files: [{ path: "src/a.ts", insertions: 3, deletions: 1 }], insertions: 3, deletions: 1 },
@@ -71,7 +73,7 @@ describe("threadDetails", () => {
const pullRequests = [
{ host: "github.com", repository: "o/r", number: 7, url: "u", source: "created", linkedAt: "2026-01-01T00:00:00Z", stack: null, snapshot: { state: "open", title: "Seven", headBranch: "x", baseBranch: "main", isDraft: true, updatedAt: null, syncedAt: "2026-01-01T00:00:00Z", checksState: "failing" } },
];
const details = threadDetails(thread({ pullRequests }), project, vcs({}, { hasUpstream: false, aheadCount: 0, behindCount: 0, pr: null }), null);
const details = detailsOf(thread({ pullRequests }), vcs({}, { hasUpstream: false, aheadCount: 0, behindCount: 0, pr: null }), null);
expect(details.branch?.upstream).toBe("not pushed");
expect(details.branch?.pullRequest).toEqual({ number: 7, title: "Seven", state: "draft", tone: "muted", checks: { text: "✕ checks", tone: "bad" } });
});
@@ -83,7 +85,7 @@ describe("threadDetails", () => {
{ id: "fork", title: "Try another way", lineage: { parentThreadId: "t1", relationshipToParent: "fork" }, deletedAt: null },
],
} as unknown as OrchestrationV2ShellSnapshot;
const details = threadDetails(
const details = detailsOf(
thread({
lineage: { parentThreadId: "parent", relationshipToParent: "fork", rootThreadId: "parent" },
pendingBackgroundTasks: [
@@ -92,16 +94,33 @@ describe("threadDetails", () => {
],
goal: { objective: "Ship sync", status: "active", timeUsedSeconds: 90 },
}),
project,
vcs({}),
snapshot,
);
expect(details.lineage.map((entry) => entry.text)).toEqual(['forked from "Plan sync"', 'forked into "Try another way"', "1 subagent (1 running)"]);
expect(details.lineage.map((entry) => [entry.text, entry.threadId])).toEqual([
['forked from "Plan sync"', "parent"],
['fork "Try another way"', "fork"],
["1 subagent running", undefined],
]);
expect(details.background).toEqual([{ glyph: "◐", text: "dev server :5173" }]);
expect(details.goal).toEqual({ objective: "Ship sync", status: "active · 1m", tone: "info" });
});
test("notes folders that aren't repositories", () => {
expect(threadDetails(thread(), project, vcs({ isRepo: false }), null).vcsNote).toBe("Not a git repository");
expect(detailsOf(thread(), vcs({ isRepo: false }), null).vcsNote).toBe("Not a git repository");
});
test("offers the web's git actions and lists selectable lines in order", () => {
const servers = [{ host: "127.0.0.1", port: 5173, url: "http://127.0.0.1:5173", processName: "vite", pid: 42, terminal: null, agent: { threadId: "t1" } }];
const automations = [{ id: "a1", title: "Nightly check", prompt: "check", enabled: true, schedule: { type: "fixed_time", timeOfDay: "09:00", weekdays: [1, 2] }, threadId: "t1", nextRunAt: null, lastRunAt: null, lastRunStatus: "never", lastRunError: null, runCount: 0 }];
const details = detailsOf(
thread(),
vcs({ workingTree: { files: [{ path: "src/a.ts", insertions: 3, deletions: 1 }], insertions: 3, deletions: 1 } }, { hasUpstream: true, aheadCount: 0, behindCount: 0, aheadOfDefaultCount: 0, pr: null }),
null,
{ servers, automations } as never,
);
expect(details.git?.quick).toEqual({ action: "commit_push_pr", label: "Commit, push & PR", commits: true });
expect(details.automations[0]).toMatchObject({ schedule: "Mon,Tue 09:00", status: "on" });
expect(detailsActions(details).map((action) => action.id)).toEqual(["git:quick:commit_push_pr", "git:commit", "diff:*", "diff:src/a.ts", "server:5173", "automation:a1"]);
});
});
+37
View File
@@ -0,0 +1,37 @@
import { expect, test } from "bun:test";
import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts";
import * as DateTime from "effect/DateTime";
import { paletteEntries, paletteGroups } from "../src/model/palette.ts";
const at = (ms: number) => DateTime.makeUnsafe(ms);
const thread = (id: string, title: string, updated: number, extra: Record<string, unknown> = {}) => ({
id, title, projectId: "p1", branch: null, archivedAt: null, deletedAt: null, latestUserMessageAt: null, updatedAt: at(updated),
lineage: { parentThreadId: null, relationshipToParent: null }, ...extra,
});
const snapshot = {
projects: [{ id: "p1", title: "tasknotes", workspaceRoot: "/r" }],
threads: [
thread("t1", "Fix calendar sync", 1_000),
thread("t2", "Release notes", 3_000),
thread("t3", "Sync worker", 2_000, { lineage: { parentThreadId: "t1", relationshipToParent: "subagent" } }),
thread("t4", "Old", 500, { archivedAt: at(600) }),
],
} as unknown as OrchestrationV2ShellSnapshot;
const commands = [
{ id: "details", title: "Show thread details", shortcut: "d" },
{ id: "diff", title: "View uncommitted changes", keywords: ["diff"] },
];
test("lists commands, then recent threads, before you type", () => {
const groups = paletteGroups({ query: "", commands, snapshot });
expect(groups.map((group) => group.label)).toEqual(["Commands", "Recent threads"]);
expect(groups[1]!.entries.map((entry) => (entry.kind === "thread" ? (entry.threadId as string) : ""))).toEqual(["t2", "t3", "t1"]);
});
test("searches threads, subagents included, and commands by keyword", () => {
const entries = paletteEntries(paletteGroups({ query: "sync", commands, snapshot }));
expect(entries.map((entry) => (entry.kind === "thread" ? `${entry.threadId}${entry.subagent ? "*" : ""}` : entry.command.id)).sort()).toEqual(["t1", "t3*"]);
expect(paletteEntries(paletteGroups({ query: "diff", commands, snapshot }))[0]).toMatchObject({ kind: "command", command: { id: "diff" } });
expect(paletteGroups({ query: ">", commands, snapshot }).map((group) => group.label)).toEqual(["Commands"]);
});