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

+6 -3
View File
@@ -13,6 +13,7 @@ import { formatWorkingDurationLabel } from "@t3tools/client-runtime/state/models
import { homedir } from "node:os";
import type { VcsState } from "../client/session.ts";
import { formatClock, type Tui3Config } from "../config.ts";
import { buildMenuItems, resolveQuickAction } from "../../vendor/t3code/apps/web/src/components/GitActionsControl.logic.ts";
import type { StatusTone } from "./threads.ts";
@@ -91,6 +92,8 @@ export interface DetailsInput {
readonly servers?: readonly DiscoveredLocalServer[];
readonly automations?: readonly ScheduledTask[];
readonly now?: number;
/** How automation times read; the system's locale by default. */
readonly timestampFormat?: Tui3Config["timestampFormat"];
}
export interface PullRequestLine {
@@ -171,7 +174,7 @@ export function threadDetails(input: DetailsInput): ThreadDetails {
const automations = (input.automations ?? [])
.filter((task) => task.threadId === thread.id)
.map((task) => automationLine(task, now));
.map((task) => automationLine(task, now, input.timestampFormat ?? "locale"));
const background = (thread.pendingBackgroundTasks ?? [])
.filter((task) => task.kind !== "subagent")
@@ -220,12 +223,12 @@ function gitActions(status: VcsStatusResult): NonNullable<ThreadDetails["git"]>
return { quick, hint: quick ? null : quickAction.hint ?? quickAction.label, menu };
}
function automationLine(task: ScheduledTask, now: number): AutomationLine {
function automationLine(task: ScheduledTask, now: number, timestampFormat: Tui3Config["timestampFormat"]): AutomationLine {
const schedule =
task.schedule.type === "interval"
? `every ${formatWorkingDurationLabel(task.schedule.everyMs)}`
: task.schedule.type === "fixed_time"
? `${task.schedule.weekdays && task.schedule.weekdays.length < 7 ? task.schedule.weekdays.map((day) => WEEKDAYS[day]).join(",") + " " : "daily "}${task.schedule.timeOfDay}`
? `${task.schedule.weekdays && task.schedule.weekdays.length < 7 ? task.schedule.weekdays.map((day) => WEEKDAYS[day]).join(",") + " " : "daily "}${formatClock(task.schedule.timeOfDay, timestampFormat)}`
: "on webhook";
if (!task.enabled) return { task, schedule, status: "off", tone: "muted" };
if (task.lastRunStatus === "running") return { task, schedule, status: "running", tone: "info" };
+41
View File
@@ -0,0 +1,41 @@
import type { ServerConfig } from "@t3tools/contracts";
import { CONFIG_CHOICES, type Tui3Config } from "../config.ts";
import { RUNTIME_MODE_LABELS } from "./details.ts";
export interface SettingRow {
readonly key: keyof Tui3Config;
readonly label: string;
readonly value: string;
readonly help: string;
}
const LABELS: { readonly [K in keyof Tui3Config]: { readonly label: string; readonly help: string; readonly values?: Partial<Record<string, string>> } } = {
followUpBehavior: { label: "While the agent runs, enter", help: "alt+enter does the other", values: { steer: "steers", queue: "queues" } },
sendShortcut: { label: "Send with", help: "ctrl+enter needs kitty keyboard support; alt+enter also sends", values: { enter: "enter", "ctrl-enter": "ctrl+enter (enter adds a line)" } },
timestampFormat: { label: "Times", help: "automation schedules", values: { locale: "system locale", "12-hour": "12-hour", "24-hour": "24-hour" } },
diffIgnoreWhitespace: { label: "Diffs", help: "whitespace-only changes", values: { true: "ignore whitespace", false: "show whitespace" } },
};
/** tui3's own settings, in display order, each cycled with enter. */
export function settingRows(config: Tui3Config): SettingRow[] {
return (Object.keys(CONFIG_CHOICES) as (keyof Tui3Config)[]).map((key) => {
const meta = LABELS[key];
const raw = String(config[key]);
return { key, label: meta.label, value: meta.values?.[raw] ?? raw, help: meta.help };
});
}
/** The server settings worth knowing from the terminal, read-only: they're changed in the app. */
export function serverSettingLines(config: ServerConfig | null): { label: string; value: string }[] {
if (!config) return [];
const settings = config.settings;
return [
{ label: "Server", value: `${config.environment.label} · T3 Code ${config.environment.serverVersion}` },
{ label: "New thread model", value: settings.defaultModelSelection ? settings.defaultModelSelection.model : "provider default" },
{ label: "New thread mode", value: RUNTIME_MODE_LABELS[settings.defaultRuntimeMode] ?? settings.defaultRuntimeMode },
{ label: "New threads run in", value: settings.defaultThreadEnvMode ?? "project default" },
{ label: "Auto-settle", value: settings.sidebarAutoSettleAfterDays ? `after ${settings.sidebarAutoSettleAfterDays} days idle` : "off" },
{ label: "Rate-limited threads", value: [settings.snoozeLimitedThreads ? "snooze" : "", settings.autoResumeLimitedThreads ? "resume when reset" : ""].filter(Boolean).join(", ") || "left as they are" },
];
}