New threads, model and mode picker, alerts, $EDITOR and terminal attach

- c starts a draft thread (project, model, mode, worktree) launched with orchestration.launchThread
- m picks model, provider options and access mode from the server's providers, following the web's provider lock; model changes ride on the next message
- Alerts port T3's notification gate: bell, OSC 9/99 desktop notifications when unfocused, in-app flash
- ctrl+g edits the message in $EDITOR; ctrl+j attaches to the thread's T3 terminal
- Credential gains terminal:read
This commit is contained in:
Callum Alpass committed 2026-11-02 18:55:47 +11:00
1 parent 121bbd9137
commit 626d37a4e9
18 files changed
+1074 -49

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import type { CliRenderer } from "@opentui/core";
import { spawnSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
/**
* Hands the terminal to $VISUAL or $EDITOR on a copy of `text` and returns what was saved,
* or null if the editor failed. The renderer is suspended meanwhile.
*/
export function editInEditor(renderer: CliRenderer, text: string): string | null {
const editor = process.env.VISUAL || process.env.EDITOR || "vi";
const dir = mkdtempSync(join(tmpdir(), "tui3-"));
const file = join(dir, "prompt.md");
writeFileSync(file, text);
renderer.suspend();
try {
// Through the shell, so EDITOR="code --wait" works.
const result = spawnSync(process.env.SHELL || "sh", ["-c", `${editor} "$1"`, "sh", file], { stdio: "inherit" });
if (result.status !== 0) return null;
return readFileSync(file, "utf8").replace(/\n$/, "");
} finally {
rmSync(dir, { recursive: true, force: true });
renderer.resume();
renderer.requestRender();
}
}