Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(tmux-banner): installing/ready/failed states instead of optimistic dismiss

enes6369edb5f910
diff --git a/src/renderer/components/TmuxBanner.tsx b/src/renderer/components/TmuxBanner.tsx
index e98bb18f5..c80df6355 100644
--- a/src/renderer/components/TmuxBanner.tsx
+++ b/src/renderer/components/TmuxBanner.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from 'react'
+import { useEffect, useRef, useState } from 'react'
import type { TmuxStatus } from '@shared/types'
import { localSession } from '../session/localSession'
@@ -6,12 +6,29 @@ import { localSession } from '../session/localSession'
// don't survive restarts and the mobile companion can't attach — and nothing used to say so
// (one field report ran degraded for months without anyone noticing). Shown every launch until
// tmux is installed; the ✕ hides it for this session only. The install button runs the suggested
-// package-manager command in a new terminal node (the gh-sign-in pattern), so the user watches it
-// happen. No known package manager → text-only guidance. Hidden on win32 (no native tmux to
-// install) and on any fetch error (fail-open, like the ws-bridge stub).
+// package-manager command in a new terminal node (the gh-sign-in pattern) and — unlike the first
+// version, which dismissed the banner optimistically and left the user guessing (second field
+// report) — keeps the banner up as a status strip: installing → ready | failed. tmuxStatus()
+// re-probes on every call (ensureTmux), so `available` flipping true is also what makes NEW
+// terminals tmux-backed without a restart. Hidden on win32 and on any fetch error (fail-open).
+
+export const INSTALL_POLL_MS = 3000
+export const INSTALL_CAP_MS = 5 * 60_000
+export const READY_HIDE_MS = 6000
+
+export type InstallPhase = 'missing' | 'installing' | 'ready' | 'failed'
+
+/** Poll verdict while installing: available wins outright; past the cap → failed. */
+export function pollOutcome(available: boolean, elapsedMs: number): InstallPhase {
+ if (available) return 'ready'
+ return elapsedMs >= INSTALL_CAP_MS ? 'failed' : 'installing'
+}
+
export function TmuxBanner({ onInstall }: { onInstall: (command: string) => void }): JSX.Element | null {
const [status, setStatus] = useState<TmuxStatus | null>(null)
const [dismissed, setDismissed] = useState(false)
+ const [phase, setPhase] = useState<InstallPhase>('missing')
+ const startedAtRef = useRef(0)
useEffect(() => {
let cancelled = false
@@ -28,29 +45,64 @@ export function TmuxBanner({ onInstall }: { onInstall: (command: string) => void
}
}, [])
- if (!status || status.available || dismissed || status.platform === 'win32') return null
+ // While installing, poll tmuxStatus. The raw install output is visible in the spawned
+ // terminal node either way — the banner only reports the outcome.
+ useEffect(() => {
+ if (phase !== 'installing') return
+ const t = setInterval(() => {
+ localSession.api.pty
+ .tmuxStatus()
+ .then((s) => {
+ const next = pollOutcome(s.available, Date.now() - startedAtRef.current)
+ if (next !== 'installing') setPhase(next)
+ })
+ .catch(() => {})
+ }, INSTALL_POLL_MS)
+ return () => clearInterval(t)
+ }, [phase])
+
+ // The success note has said what it needed to — take itself down.
+ useEffect(() => {
+ if (phase !== 'ready') return
+ const t = setTimeout(() => setDismissed(true), READY_HIDE_MS)
+ return () => clearTimeout(t)
+ }, [phase])
+
+ if (!status || dismissed || status.platform === 'win32') return null
+ if (status.available && phase === 'missing') return null
+ const title =
+ phase === 'installing' ? 'Installing tmux' : phase === 'ready' ? 'tmux ready' : 'tmux not found'
+ const body =
+ phase === 'installing'
+ ? 'Running the install in a terminal node — watch it for progress (it may ask for your password).'
+ : phase === 'ready'
+ ? 'New terminals will survive restarts from now on. Terminals opened before the install stay on the plain shell.'
+ : phase === 'failed'
+ ? 'The install hasn’t completed. Check the terminal node for errors, or install tmux with your package manager and restart nodeterm.'
+ : status.installCommand
+ ? 'Terminals won’t survive restarts and the mobile app can’t attach until tmux is installed.'
+ : 'Terminals won’t survive restarts and the mobile app can’t attach. Install tmux with your package manager (e.g. brew install tmux), then restart nodeterm.'
+
+ const showInstall = (phase === 'missing' || phase === 'failed') && !!status.installCommand
return (
<div className="announce-banner announce-banner--warning">
<span className="announce-banner__dot" />
<div className="announce-banner__content">
- <span className="announce-banner__title">tmux not found</span>
- <span className="announce-banner__body">
- {status.installCommand
- ? 'Terminals won’t survive restarts and the mobile app can’t attach until tmux is installed.'
- : 'Terminals won’t survive restarts and the mobile app can’t attach. Install tmux with your package manager (e.g. brew install tmux), then restart nodeterm.'}
- </span>
+ <span className="announce-banner__title">{title}</span>
+ <span className="announce-banner__body">{body}</span>
</div>
- {status.installCommand && (
+ {showInstall && (
<button
className="announce-banner__btn"
- title={status.installCommand}
+ title={status.installCommand!}
onClick={() => {
onInstall(status.installCommand!)
- setDismissed(true)
+ startedAtRef.current = Date.now()
+ setPhase('installing')
}}
>
- {status.installLabel ?? 'Install tmux'}
+ {phase === 'failed' ? 'Retry' : (status.installLabel ?? 'Install tmux')}
</button>
)}
<button className="announce-banner__close" title="Dismiss" onClick={() => setDismissed(true)}>
diff --git a/src/renderer/components/tmux-banner-phase.test.ts b/src/renderer/components/tmux-banner-phase.test.ts
new file mode 100644
index 000000000..5907df452
--- /dev/null
+++ b/src/renderer/components/tmux-banner-phase.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it, vi } from 'vitest'
+
+// Importing the component transitively loads `session/localSession`, which reads
+// `window.nodeTerminal` at module-eval time (safe in-app for its documented boot order) — a
+// ReferenceError under the node vitest env, which has no `window`. Stub that one module so the
+// import stays pure: only `pollOutcome` is exercised here, and the component is never rendered.
+vi.mock('../session/localSession', () => ({
+ localSession: { api: { pty: { tmuxStatus: async () => ({ available: false }) } } }
+}))
+
+import { INSTALL_CAP_MS, pollOutcome } from './TmuxBanner'
+
+describe('pollOutcome', () => {
+ it('stays installing while unavailable and under the cap', () => {
+ expect(pollOutcome(false, 0)).toBe('installing')
+ expect(pollOutcome(false, INSTALL_CAP_MS - 1)).toBe('installing')
+ })
+ it('flips to ready the moment tmux is available — even past the cap', () => {
+ expect(pollOutcome(true, 0)).toBe('ready')
+ expect(pollOutcome(true, INSTALL_CAP_MS + 1)).toBe('ready')
+ })
+ it('fails once the cap elapses without tmux', () => {
+ expect(pollOutcome(false, INSTALL_CAP_MS)).toBe('failed')
+ })
+})