Start t3 serve from t3tui when no local server is up, stop it on quit

ensureLocalServer() probes the origin named by the runtime file; if
nothing answers (and T3TUI_SERVER/T3TUI_TOKEN are unset) it spawns
`t3 serve` detached in its own process group, waits for the runtime
file to come up, and returns a handle whose stop() SIGTERMs the whole
group (SIGKILL after a grace period). Wired into the UI's destroy
handler, `list` and `tmux`, with a process exit hook as backstop. The
server's output goes to ~/.config/t3tui/server.log so it can't corrupt
the TUI screen. An existing, answering server is always used as-is.

Tests cover spawn+stop, existing-server reuse, and the no-spawn env
overrides, using a fake t3 binary.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
venomade committed 2026-11-24 01:29:13 +00:00
1 parent 57578ca4f5
commit 5ebff7b68d
5 files changed
+232 -13

No files matched your search

+1 -1
View File
@@ -61,7 +61,7 @@
runHook preInstall
mkdir -p $out/lib $out/bin
cp -r . $out/lib/t3
${pkgs.lib.optionalString pkgs.stdenv.isLinux ''
${pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
libPath="${pkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc.lib
pkgs.zlib