Skip to content

Set host terminal title for agent sessions and dashboard#14

Merged
madarco merged 1 commit into
mainfrom
agentbox/agentbox-91c4911f
May 28, 2026
Merged

Set host terminal title for agent sessions and dashboard#14
madarco merged 1 commit into
mainfrom
agentbox/agentbox-91c4911f

Conversation

@madarco
Copy link
Copy Markdown
Owner

@madarco madarco commented May 28, 2026

Summary

  • The host terminal/tab title (iTerm2 etc.) was never set when running agentbox claude/codex/opencode/attach or dashboard. The inner agent's OSC title is swallowed by tmux (set-titles off) and by @xterm/headless in the dashboard, so it never reaches the host.
  • New TTY-guarded helper apps/cli/src/terminal/title.ts: OSC 0 set-title plus XTPUSHTITLE/XTPOPTITLE to save/restore the user's original title.
  • Attach paths (docker + cloud, one runWrappedAttach site) now show just <title> — the live session title from status.json, resolved per active agent so codex/opencode work too, falling back to the box name until the agent sets one.
  • Dashboard shows AgentBox: <selected box title|name>, updated on box switch and restored on exit.
  • Drives the title from the already-polled status (uniform across docker/daytona/hetzner); ~3s update latency. No new dependency, no tmux set-titles change (host stays the sole title writer).

Test plan

  • pnpm build, pnpm typecheck, pnpm lint clean
  • pnpm test (335 passed, incl. new terminal-title.test.ts)
  • Ran compiled dashboard under a real PTY: emits \x1b[22;2t (push), \x1b]0;AgentBox\x07 (title), \x1b[23;2t (pop on quit)
  • Manual on host in iTerm2: agentbox claude tab shows box name then the agent's session title, restored on exit
  • Manual on host: agentbox dashboard tab shows AgentBox: <selected>, updates on Ctrl+Option+↑/↓, restored on quit

Note

Low Risk
Terminal UX only (OSC sequences, title sanitization); no auth, data, or infrastructure changes beyond existing status polling.

Overview
Adds a TTY-safe terminal/title helper (OSC 0 set-title, push/pop title stack) so the host tab/window title updates even when tmux or the dashboard headless PTY swallow inner OSC sequences.

Attach (runWrappedAttach): saves the user’s title, seeds the tab with the box name, then mirrors the live session title from polled status.json for Claude/Codex/OpenCode (not shell), with deduped writes; restores the prior title on exit.

Dashboard: on entry pushes the saved title and sets AgentBox: <session title|box name> (or AgentBox for “+ New box”), refreshed when selection/chrome redraws; restores on quit. stripTitleGlyph is exported for shared title cleanup.

Includes terminal-title.test.ts for OSC/CSI output and sanitization.

Reviewed by Cursor Bugbot for commit 940844e. Configure here.

The host terminal/tab title (iTerm2 etc.) was never set when running
`agentbox claude`/`codex`/`opencode`/`attach` or `dashboard`: the inner
agent's OSC title is swallowed by tmux (set-titles off) and by
@xterm/headless in the dashboard, so it never reaches the host.

Add a small TTY-guarded helper (OSC 0 set-title + XTPUSHTITLE/XTPOPTITLE
save/restore) and drive it from the already-polled status.json title:
- attach paths (docker + cloud) show just `<title>` (agent session title,
  falling back to the box name), resolved per active agent so codex/opencode
  work too;
- the dashboard shows `AgentBox: <selected box title|name>`, updated on
  box switch and restored on exit.
@madarco madarco merged commit cccd3c5 into main May 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant