Add settings, server config and idle subagent details

- tui3's own settings in ~/.config/tui3/config.json, under the web app's
  names and defaults: followUpBehavior, sendShortcut, timestampFormat,
  diffIgnoreWhitespace. A settings view (from the palette) cycles them and
  shows the relevant server settings read-only.
- Subscribe to the server config; when it advertises shellThreadFamilies,
  fetch an idle subagent's family so it gets full details and lineage.
This commit is contained in:
Callum Alpass committed 2026-11-02 18:23:35 +11:00
1 parent ed36949fa7
commit 121bbd9137
11 files changed
+393 -35

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import { describe, expect, test } from "bun:test";
import { cycleConfig, DEFAULT_CONFIG, formatClock, parseConfig } from "../src/config.ts";
import { settingRows } from "../src/model/settings.ts";
describe("config", () => {
test("keeps valid values and defaults the rest", () => {
expect(parseConfig({ followUpBehavior: "queue", sendShortcut: "nope", diffIgnoreWhitespace: false, extra: 1 })).toEqual({
...DEFAULT_CONFIG,
followUpBehavior: "queue",
diffIgnoreWhitespace: false,
});
expect(parseConfig(null)).toEqual(DEFAULT_CONFIG);
});
test("cycles through each setting's choices", () => {
const once = cycleConfig(DEFAULT_CONFIG, "timestampFormat");
expect(once.timestampFormat).toBe("12-hour");
expect(cycleConfig(cycleConfig(once, "timestampFormat"), "timestampFormat").timestampFormat).toBe("locale");
expect(cycleConfig(DEFAULT_CONFIG, "diffIgnoreWhitespace").diffIgnoreWhitespace).toBe(false);
});
test("formats clock times", () => {
expect(formatClock("09:05", "24-hour")).toBe("09:05");
expect(formatClock("21:30", "12-hour")).toMatch(/^9:30\s?PM$/i);
expect(formatClock("bad", "24-hour")).toBe("bad");
});
test("labels settings for the settings view", () => {
const rows = settingRows({ ...DEFAULT_CONFIG, followUpBehavior: "queue" });
expect(rows.map((row) => row.key)).toEqual(["followUpBehavior", "sendShortcut", "timestampFormat", "diffIgnoreWhitespace"]);
expect(rows[0]?.value).toBe("queues");
});
});
+1 -1
View File
@@ -117,7 +117,7 @@ describe("threadDetails", () => {
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,
{ servers, automations, timestampFormat: "24-hour" } 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" });