Rename to t3tui

The command, package, env vars (T3TUI_*), config folder, tmux session and
the session label it issues itself. An existing ~/.config/tui3 moves to
~/.config/t3tui on the first run.
This commit is contained in:
Callum Alpass committed 2026-11-03 01:12:17 +11:00
1 parent 673d314e46
commit 1cccff8031
30 files changed
+147 -138

No files matched your search

+12 -12
View File
@@ -4,10 +4,10 @@ import { join } from "node:path";
import { configDir } from "./client/auth.ts";
/**
* tui3's own preferences. The web app keeps these in each browser's storage, out of the
* server's reach, so tui3 keeps its own copy, under the web app's names and defaults.
* t3tui's own preferences. The web app keeps these in each browser's storage, out of the
* server's reach, so t3tui keeps its own copy, under the web app's names and defaults.
*/
export interface Tui3Config {
export interface T3tuiConfig {
/** What enter does while the agent is running; alt+enter does the other. */
readonly followUpBehavior: "steer" | "queue";
/** "ctrl-enter" makes enter a newline and ctrl+enter send (needs the kitty keyboard protocol). */
@@ -22,10 +22,10 @@ export interface Tui3Config {
readonly theme: "auto" | "dark" | "light";
}
export const DEFAULT_CONFIG: Tui3Config = { followUpBehavior: "steer", sendShortcut: "enter", timestampFormat: "locale", diffIgnoreWhitespace: true, notificationMode: "sound", inAppNotificationsEnabled: true, theme: "auto" };
export const DEFAULT_CONFIG: T3tuiConfig = { followUpBehavior: "steer", sendShortcut: "enter", timestampFormat: "locale", diffIgnoreWhitespace: true, notificationMode: "sound", inAppNotificationsEnabled: true, theme: "auto" };
/** Every setting with its choices in cycling order, for the settings view. */
export const CONFIG_CHOICES: { readonly [K in keyof Tui3Config]: readonly Tui3Config[K][] } = {
export const CONFIG_CHOICES: { readonly [K in keyof T3tuiConfig]: readonly T3tuiConfig[K][] } = {
followUpBehavior: ["steer", "queue"],
sendShortcut: ["enter", "ctrl-enter"],
timestampFormat: ["locale", "12-hour", "24-hour"],
@@ -38,7 +38,7 @@ export const CONFIG_CHOICES: { readonly [K in keyof Tui3Config]: readonly Tui3Co
export const configPath = () => join(configDir(), "config.json");
/** Reads the config, keeping defaults for anything missing or not one of the choices. */
export async function loadConfig(): Promise<Tui3Config> {
export async function loadConfig(): Promise<T3tuiConfig> {
let raw: unknown;
try {
raw = JSON.parse(await readFile(configPath(), "utf8"));
@@ -48,29 +48,29 @@ export async function loadConfig(): Promise<Tui3Config> {
return parseConfig(raw);
}
export function parseConfig(raw: unknown): Tui3Config {
export function parseConfig(raw: unknown): T3tuiConfig {
const record = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
const config: Record<string, unknown> = { ...DEFAULT_CONFIG };
for (const [key, choices] of Object.entries(CONFIG_CHOICES)) {
if ((choices as readonly unknown[]).includes(record[key])) config[key] = record[key];
}
return config as unknown as Tui3Config;
return config as unknown as T3tuiConfig;
}
export async function saveConfig(config: Tui3Config): Promise<void> {
export async function saveConfig(config: T3tuiConfig): Promise<void> {
await mkdir(configDir(), { recursive: true });
await writeFile(configPath(), `${JSON.stringify(config, null, 2)}\n`);
}
/** The next choice for one setting, wrapping around. */
export function cycleConfig<K extends keyof Tui3Config>(config: Tui3Config, key: K): Tui3Config {
const choices = CONFIG_CHOICES[key] as readonly Tui3Config[K][];
export function cycleConfig<K extends keyof T3tuiConfig>(config: T3tuiConfig, key: K): T3tuiConfig {
const choices = CONFIG_CHOICES[key] as readonly T3tuiConfig[K][];
const next = choices[(choices.indexOf(config[key]) + 1) % choices.length]!;
return { ...config, [key]: next };
}
/** A clock time ("HH:MM") in the chosen format, as the web app's timestamps. */
export function formatClock(timeOfDay: string, format: Tui3Config["timestampFormat"]): string {
export function formatClock(timeOfDay: string, format: T3tuiConfig["timestampFormat"]): string {
const [hours, minutes] = timeOfDay.split(":").map(Number);
if (hours === undefined || minutes === undefined || Number.isNaN(hours) || Number.isNaN(minutes)) return timeOfDay;
const date = new Date(2000, 0, 1, hours, minutes);