Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

- **Composite Terminal Panes & Mainframe Paging**: Pin the command prompt to **Top** (`Alt+T`), **Bottom** (`Alt+B`), **Free-Float** (`Alt+Up`/`Down`), or **Fixed Split** (`Alt+S`) over a 60 FPS flood-immune PTY canvas with `DECSET 1049` auto-hide (`vim`, `htop`, `nmon`), 3-signal `!ECHO LOCK` password protection, and Mainframe Block/Page-Hold (`MORE...` / `HOLDING`) or Smooth Kinetic scrolling (`:scroll`). → *[User Guide Ch. 2](docs/user-guide/02-floating-command-prompt.md)*
- **2D Rectangular Block Selection & Copy**: Drag-select 2D rectangular columns with `Alt+LeftDrag` or persistent `:rect mode` across terminal output, log columns, or tables. Pastes cleanly to system and OSC 52 clipboards (`Alt+R` / `r` in Copy Mode). → *[User Guide Ch. 6](docs/user-guide/06-keyboard-mouse-and-command-reference.md)*
- **Full Session Persistence & Exit Guard**: Detach with `Ctrl+X D` or `:detach` leaving split tree ratios, Z-order stack, prompt anchors, active shells, running commands, and per-pane CWD intact; resume via `bilterm attach [session]`. Protects root shell exits via interactive Borland Exit Guard modals. → *[User Guide Ch. 3](docs/user-guide/03-window-manager-and-z-stack.md)*
- **Full Session Persistence & Exit Guard**: Detach with `Ctrl+X D` or `:detach` to save split tree ratios, Z-order stack, prompt anchors, per-pane shell, CWD and visible screen text; `bilterm attach [session]` rebuilds the layout and restarts each pane's shell and recorded command. Programs do **not** keep running while detached (run them inside a tmux link if they must survive). The workspace is also checkpointed in the background, and after a crash or `kill -9` the next start restores the last checkpoint and says so. Protects root shell exits via interactive Borland Exit Guard modals. → *[User Guide Ch. 3](docs/user-guide/03-window-manager-and-z-stack.md)*
- **Native Desktop GUI (`--gui`) & Per-Pane Font Scaling**: Run standalone without a host terminal on Linux (X11), macOS (Cocoa), or Windows (GDI). Scale each pane's font independently (`50%..300%` via `Ctrl++`/`Ctrl+-`/`Ctrl+Wheel`), drag all borders to resize, and plot high-res Kitty/Sixel/Braille graphics (`bilterm plot`, `:canvas`). → *[User Guide Ch. 8](docs/user-guide/08-extended-cli-and-gui-examples.md)*
- **Zero-Trust Confinement**: All runtime sockets, session TOMLs, command history exports, and `.cast` recordings reside in `0700` directories with `0600` atomic file permissions. Unix sockets enforce `SO_PEERCRED` UID checks; HTTP transports require local loopback and bearer token authentication. → *[Security & Best Practices (Ch. 10)](docs/user-guide/10-security-and-best-practices.md)*

Expand Down Expand Up @@ -103,7 +103,7 @@ bilterm run starter-packs/01-multi-agent-swarm/playbook.toml
| **Global Fuzzy Finder** | `Ctrl+Alt+F` | `:find [agent \| session \| history] <q>` | Unified registry search with secret masking |
| **Agent Messaging & Swarms** | `Alt+]` (next blocked) | `:agent [name \| send \| inbox \| list \| snoop]` | Inter-agent messaging, mailboxes & packet telemetry |
| **Appearance & Display Modes** | `F11` / `F4` (`<L> e`) | `:appearance [obsidian \| legacy \| ...]` / `:mode [standard \| zen]` | 8 visual profiles & distraction-free Zen mode |
| **Detach & Re-Attach Workspace** | `Ctrl+X D` / Exit Guard `[d]` | `:detach [name]` / `:attach [name]` | Leaves shells running in background daemon |
| **Detach & Re-Attach Workspace** | `Ctrl+X D` / Exit Guard `[d]` | `:detach [name]` / `:attach [name]` | Saves the layout; shells and commands are restarted on attach (not kept running) |
| **Split Horizontal / Split Vertical / Zoom** | `F2` (`<L> -`) / `Alt+V` (`<L> \|`) / `F5` (`<L> z`) | `:split h` / `:split v` / `:zoom` | Binary space partitioning tiling |
| **Tiled Splits vs. Z-Stack / Shuffle Deck** | `Cmd+L` / `Ctrl+Shift+L` (`<L> M`, Window mode `s`) / `F6` (`<L> o`) / `Alt+1..9` | `:layout tile\|stack` / `:deck next\|prev` | Overlapping Borland window cascade & switching |
| **Utility Windows (Fonts / Studio)** | `*` (pin) / `[` / `]` (scale) | `:fonts` / `:commands` / `:studio` | Workbench windows, live recorder & step debugger |
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Welcome to the comprehensive documentation suite for **Bilterm (`v3.2.0`)** —
| Command | Description |
|---------|-------------|
| `bilterm` | Launch interactive IBM 3270 × Borland Turbo Vision TUI multiplexer (auto-resumes detached session) |
| `bilterm attach [session]` (`-a` / `--attach`) | Re-attach & restore saved/detached multi-pane window layout intact (via live daemon RPC or saved session) |
| `bilterm attach [session]` (`-a` / `--attach`) | Re-attach: rebuild the saved/detached multi-pane window layout from the session file and restart its shells and recorded commands |
| `bilterm ls` (`bilterm sessions` / `--list-sessions`) | List live background daemon sockets (`LIVE DAEMON`) & saved `.toml` layouts (`SAVED LAYOUT`) |
| `bilterm -G` / `--gui` | Launch standalone native desktop GUI window (X11 / Win32 GDI / Cocoa) |
| `bilterm --gui-font <NAME>` (`-F` / `--font`) | Set font family or preset (`"JetBrains Mono"`, `"IBM 3270"`, `"Fira Code"`, `"vga"`, etc.) |
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/06-keyboard-mouse-and-command-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
| `Alt+O` | `<L> L` | `:spotlight` | Cycle Focal Spotlight shader around active cursor (`Circle` -> `Ellipse` -> `Pixel` -> `Off`) |
| `Alt+Shift+O` | — | `:focalzoom` | Cycle Focal Zoom Magnifying Lens (`1.25x` -> `1.5x` -> `2.0x` -> `Off`) |
| `Alt+}` / `Alt+{` | `<L> }` / `<L> {` | `:spotlight +\|-` | Expand or shrink Focal Spotlight / Focal Zoom lens radius |
| — | `Ctrl+X D` | `:detach [name]` | Detach client & spawn background daemon keeping full multi-pane layout intact |
| — | `Ctrl+X D` | `:detach [name]` | Detach client & save the full multi-pane layout (programs are restarted on attach, not kept running) |
| — | — | `:attach [name]` | Re-attach & restore saved/detached multi-pane window layout in-place |
| — | — | `:mcp [status\|tree\|...]` | Open interactive Master Control Program Console (`↑`/`↓`/`j`/`k`/`Enter`/Click, `r`, `f`, `n`, `m`, `d`) |
| **`Ctrl+Q`** | `<L> Ctrl+Q` | `:quit` / `:q` / `:quit!` | Exit Bilterm (`:quit` honors Exit Guard; `:quit!` forces immediate exit) |
Expand Down Expand Up @@ -442,7 +442,7 @@ The previous defaults stay available on the `legacy` profile and, for one releas

| `:command` | Aliases | Arguments | Description |
|------------|---------|-----------|-------------|
| `:detach` | — | `[name]` | Save full multi-pane layout (`SplitTree` + `ZStack` + prompts + screen lines), spawn background daemon (`daemon-<session>.sock`), and detach |
| `:detach` | — | `[name]` | Save full multi-pane layout (`SplitTree` + `ZStack` + prompts + screen lines), spawn a headless daemon (`daemon-<session>.sock`) that re-launches the saved session, and detach. Running programs end with the client; a failed save cancels the detach |
| `:attach` | — | `[name]` | Re-attach to live background daemon via JSON-RPC or restore saved `.toml` workspace layout |
| `:mcp` | — | `[status \| tree \| float \| push [edge] \| attach <node> \| spawn <parent/child> \| graft <src> <dst> \| detach-subtree <node> \| broadcast <node> <cmd> \| freeze <node> \| thaw <node> \| derez <node> --confirm \| checkpoint \| shutdown --confirm]` | Master Control Program Root Console (`↑`/`↓`/`j`/`k`/`Enter`/Click to activate row, `r`=Refresh, `f`=Freeze/Thaw, `n`=Branch, `m`=Float↔Push, `d`=Edge, `Esc`=Close) |
| `:exit-guard` | `:exitguard` | `[guard \| respawn \| detach \| off]` | Configure final/root shell exit protection (`[r]` Respawn, `[d]` Detach, `[q]` Quit) |
Expand Down
13 changes: 6 additions & 7 deletions src/api/rpc_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
use crate::api::json::JsonValue;
use crate::daemon::registry::DaemonRegistry;
use crate::daemon::supervisor::{
daemon_lock_path_in, ensure_started, stop_daemon, DaemonLockRecord, DaemonStartResult,
daemon_lock_path_in, ensure_started, resolve_runtime_dir, stop_daemon, DaemonLockRecord, DaemonStartResult,
};
use crate::secure_fs::private_runtime_dir;

/// Handles `daemon.list`.
pub fn handle_daemon_list() -> Result<JsonValue, String> {
let runtime_dir = private_runtime_dir().map_err(|e| format!("runtime directory error: {e}"))?;
let runtime_dir = resolve_runtime_dir().map_err(|e| format!("runtime directory error: {e}"))?;
let active = DaemonRegistry::list_active(&runtime_dir);

let mut daemons = Vec::new();
Expand All @@ -36,7 +35,7 @@ pub fn handle_daemon_list() -> Result<JsonValue, String> {

/// Handles `daemon.status`.
pub fn handle_daemon_status(params: &JsonValue) -> Result<JsonValue, String> {
let runtime_dir = private_runtime_dir().map_err(|e| format!("runtime directory error: {e}"))?;
let runtime_dir = resolve_runtime_dir().map_err(|e| format!("runtime directory error: {e}"))?;
let name = params
.get("name")
.and_then(JsonValue::as_str)
Expand Down Expand Up @@ -76,7 +75,7 @@ pub fn handle_daemon_status(params: &JsonValue) -> Result<JsonValue, String> {
"socket_path",
JsonValue::String(rec.socket_path.to_string_lossy().into_owned()),
),
("status", JsonValue::String("locked".to_string())),
("status", JsonValue::String("crashed".to_string())),
]))
} else {
Ok(JsonValue::obj([
Expand All @@ -88,7 +87,7 @@ pub fn handle_daemon_status(params: &JsonValue) -> Result<JsonValue, String> {

/// Handles `daemon.start`.
pub fn handle_daemon_start(params: &JsonValue) -> Result<JsonValue, String> {
let runtime_dir = private_runtime_dir().map_err(|e| format!("runtime directory error: {e}"))?;
let runtime_dir = resolve_runtime_dir().map_err(|e| format!("runtime directory error: {e}"))?;
let name = params
.get("name")
.and_then(JsonValue::as_str)
Expand Down Expand Up @@ -119,7 +118,7 @@ pub fn handle_daemon_start(params: &JsonValue) -> Result<JsonValue, String> {

/// Handles `daemon.stop`.
pub fn handle_daemon_stop(params: &JsonValue) -> Result<JsonValue, String> {
let runtime_dir = private_runtime_dir().map_err(|e| format!("runtime directory error: {e}"))?;
let runtime_dir = resolve_runtime_dir().map_err(|e| format!("runtime directory error: {e}"))?;
let name = params
.get("name")
.and_then(JsonValue::as_str)
Expand Down
21 changes: 12 additions & 9 deletions src/api/rpc_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,12 @@ impl AutomationControlPlane {
&mut self,
params: &JsonValue,
) -> std::result::Result<JsonValue, String> {
let name = params
.get("name")
.and_then(JsonValue::as_str)
.unwrap_or("default");
let path = self.wm.save_session(name).map_err(|e| e.to_string())?;
// Same function and default (the active session) as `:session save [name]`.
let name = params.get("name").and_then(JsonValue::as_str);
let (name, path) = self.wm.save_and_activate_session(name).map_err(|e| e.to_string())?;
Ok(JsonValue::obj([
("saved", JsonValue::Bool(true)),
("session", JsonValue::String(name.to_string())),
("session", JsonValue::String(name)),
("path", JsonValue::String(path.display().to_string())),
("panes", JsonValue::Number(self.wm.pane_count() as i64)),
]))
Expand All @@ -175,14 +173,19 @@ impl AutomationControlPlane {
&mut self,
params: &JsonValue,
) -> std::result::Result<JsonValue, String> {
// Same default (the active session) as `:session restore [name]`.
let name = params
.get("name")
.and_then(JsonValue::as_str)
.unwrap_or("default");
let count = self.wm.restore_session(name).map_err(|e| e.to_string())?;
.map(str::trim)
.filter(|s| !s.is_empty())
.map_or_else(|| self.wm.config().history_session.clone(), str::to_string);
let count = self.wm.restore_session(&name).map_err(|e| e.to_string())?;
let note = self.wm.take_restore_note().map_or(JsonValue::Null, JsonValue::String);
Ok(JsonValue::obj([
("restored", JsonValue::Bool(true)),
("session", JsonValue::String(name.to_string())),
("note", note),
("session", JsonValue::String(name)),
("panes", JsonValue::Number(count as i64)),
]))
}
Expand Down
29 changes: 26 additions & 3 deletions src/colon_command/execute_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::daemon::registry::DaemonRegistry;
use crate::daemon::supervisor::{
daemon_lock_path_in, ensure_started, resolve_runtime_dir, stop_daemon, DaemonLockRecord, DaemonStartResult,
};
use crate::wm::resilience::DaemonJob;
use crate::wm::WindowManager;

/// Executes a daemon supervisor operation against the local runtime directory.
Expand All @@ -19,6 +20,28 @@ pub fn execute_daemon_command(wm: &mut WindowManager, op: &DaemonSupervisorOp) -
}
};

// With a UI attached, start/stop wait on a worker; the result arrives as a status message.
if !wm.is_headless() {
let job = match op {
DaemonSupervisorOp::Start { name } => {
Some(DaemonJob::Start { name: name.clone().unwrap_or_else(|| "default".to_string()) })
}
DaemonSupervisorOp::Stop { name, force } => Some(DaemonJob::Stop {
name: name.clone().unwrap_or_else(|| "default".to_string()),
force: *force,
}),
_ => None,
};
if let Some(job) = job {
let verb = if matches!(job, DaemonJob::Start { .. }) { "starting" } else { "stopping" };
let (DaemonJob::Start { name } | DaemonJob::Stop { name, .. }) = &job;
wm.active_pane_mut().set_status_message(Some(format!("Daemon '{name}': {verb}…")));
wm.spawn_daemon_job(&runtime_dir, job);
wm.open_daemon_window_from(&runtime_dir);
return false;
}
}

match op {
DaemonSupervisorOp::List => {
let active = DaemonRegistry::list_active(&runtime_dir);
Expand Down Expand Up @@ -99,12 +122,12 @@ pub fn execute_daemon_command(wm: &mut WindowManager, op: &DaemonSupervisorOp) -
let res = JsonValue::obj([
("name", JsonValue::String(rec.name.clone())),
("pid", JsonValue::Number(rec.pid as i64)),
("status", JsonValue::String("locked".to_string())),
("status", JsonValue::String("crashed".to_string())),
]);
wm.set_command_data(res.to_json_string());
wm.active_pane_mut().set_status_message(Some(format!(
"Daemon '{}': lock held by PID {}",
rec.name, rec.pid
"Daemon '{}': crashed (PID {} exited without cleanup) — ':daemon start {}' restarts it",
rec.name, rec.pid, rec.name
)));
} else {
let res = JsonValue::obj([
Expand Down
3 changes: 2 additions & 1 deletion src/colon_command/execute_wm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ pub fn execute_wm_colon_command(wm: &mut WindowManager, cmd: ColonCommand) -> bo
};
match wm.restore_session(&target) {
Ok(count) => {
let note = wm.take_restore_note().map(|n| format!(" — {n}")).unwrap_or_default();
wm.active_pane_mut().set_status_message(
Some(format!("Restored session '{target}' ({count} pane(s))")),
Some(format!("Restored session '{target}' ({count} pane(s)){note}")),
);
}
Err(err) => {
Expand Down
Loading
Loading