From 48ac4f76bf41bcf63d807d3c46a8345d1efcabf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ryan4yin=20=7C=20=E4=BA=8C=E8=8A=B1?= Date: Thu, 8 Oct 2026 20:29:52 +0800 Subject: [PATCH] fix(tuios): keep sessions across reboots and split them by purpose (#416) --- home/base/tui/tuios/default.nix | 13 ++++++++----- home/linux/gui/niri/conf/keybindings.kdl | 1 + home/linux/gui/niri/conf/windowrules.kdl | 6 ++++++ hosts/idols-ai/preservation.nix | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/home/base/tui/tuios/default.nix b/home/base/tui/tuios/default.nix index 14f5f932..de0328d9 100644 --- a/home/base/tui/tuios/default.nix +++ b/home/base/tui/tuios/default.nix @@ -19,14 +19,17 @@ in config.lib.file.mkOutOfStoreSymlink "${configDir}/config.toml"; # auto-start tuios in interactive shells, except when already inside tuios. - # Each terminal attaches to its own session (a bare `tuios` would attach to - # the most recent one). tuios starts its daemon on demand, so no systemd unit - # is needed. + # `work` for the ~/work tree, `personal` for everything else (a host with no + # ~/work gets `personal` everywhere). programs.nushell.extraConfig = '' # auto start tuios if $nu.is-interactive and (not ("TUIOS_SESSION" in $env)) { - let session = if ("KITTY_WINDOW_ID" in $env) { "kitty" } else { "main" } - ^tuios attach $session -c + let work_root = ($nu.home-dir | path join "work") + if $env.PWD == $work_root or ($env.PWD | str starts-with $"($work_root)/") { + ^tuios attach work -c --cwd $work_root + } else { + ^tuios attach personal -c --cwd $nu.home-dir + } } ''; } diff --git a/home/linux/gui/niri/conf/keybindings.kdl b/home/linux/gui/niri/conf/keybindings.kdl index 9fecfc99..42ecd616 100644 --- a/home/linux/gui/niri/conf/keybindings.kdl +++ b/home/linux/gui/niri/conf/keybindings.kdl @@ -16,6 +16,7 @@ binds { // Suggested binds for running programs: terminal, app launcher, screen locker. Mod+Return { spawn "ghostty"; } Mod+Shift+Return { spawn "kitty"; } + Mod+Ctrl+Return { spawn "ghostty" "--working-directory=~/work"; } // Launcher Mod+D { spawn "noctalia" "msg" "panel-toggle" "launcher"; } diff --git a/home/linux/gui/niri/conf/windowrules.kdl b/home/linux/gui/niri/conf/windowrules.kdl index 7a7e3b62..c0a63a2b 100644 --- a/home/linux/gui/niri/conf/windowrules.kdl +++ b/home/linux/gui/niri/conf/windowrules.kdl @@ -11,10 +11,16 @@ window-rule { } // Terminal applications - open in workspace 1 +// +// Both emulators are configured identically (font, size, opacity, theme), so +// the focus ring colour is what names them: global cyan = ghostty, pink = kitty. window-rule { match app-id="kitty" open-on-workspace "1terminal" open-maximized true + focus-ring { + active-color "#f5c2e7" // catppuccin pink + } } window-rule { match app-id="com.mitchellh.ghostty" diff --git a/hosts/idols-ai/preservation.nix b/hosts/idols-ai/preservation.nix index 03cbc8fc..ea44276a 100644 --- a/hosts/idols-ai/preservation.nix +++ b/hosts/idols-ai/preservation.nix @@ -188,6 +188,25 @@ in ".local/share/nvim" ".local/state/nvim" + # ====================================== + # TUIOS (terminal window manager) + # ====================================== + # Without .local/state/tuios the daemon has no saved session state to + # restore after a reboot, and every session is lost. + + # session structure (resurrection), plus each pane's saved history + { + directory = ".local/state/tuios"; + mode = "0700"; + } + # project-tape trust store and tape recordings + { + directory = ".local/share/tuios"; + mode = "0700"; + } + # layout templates (config.toml is a Home Manager symlink into the repo) + ".config/tuios" + # Joplin ".config/joplin" # tui client ".config/Joplin" # joplin-desktop