From ce2650d626b8bb44d0d1d2ed905cf155991636c6 Mon Sep 17 00:00:00 2001 From: Eric Richey <313060819+er0826-dex@users.noreply.github.com> Date: Wed, 11 Nov 2026 10:10:34 -0600 Subject: [PATCH 1/2] Point the tmux file-limit banner at a restart for legacy servers The open-file-limit banner always said "Close an extra agent-desk window", but a server on the old 256 default stays capped no matter how many windows close, and a user hitting it may have only one window open. Closing a window frees descriptors for a moment; it never lifts the ceiling. Add ServerFiles.Relief(): a Low() (legacy, <1024) server is told to restart the tmux server so a fresh one inherits agent-desk's raised 16384 limit (the real fix since v1.0.28), while a roomier server that is merely full still points to closing a window. All three banner branches use it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ internal/tmux/serverfiles.go | 12 ++++++++++++ internal/tmux/serverfiles_test.go | 8 ++++++++ internal/ui/home.go | 21 +++++++++++++-------- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e547eff..3e5b0e73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ the in-app updater downloads the `agent-desk___.tar.gz` asset ## [Unreleased] +### Fixed + +- The tmux open-file-limit banner now tells you to **restart the tmux server** when the server is on the old 256 default, instead of "Close an extra agent-desk window". Closing a window only frees descriptors for a moment on a server that stays capped, and assumes you have a second window to close; a server agent-desk started before v1.0.28 (or a plain `tmux` from a shell) keeps 256 until it exits, so a restart is the only thing that lifts the limit for good. A genuinely roomier server that is merely full still points you to close a window. + ## [1.0.28] - 2026-11-11 ### Fixed diff --git a/internal/tmux/serverfiles.go b/internal/tmux/serverfiles.go index 79bcda10..dc4067d9 100644 --- a/internal/tmux/serverfiles.go +++ b/internal/tmux/serverfiles.go @@ -62,6 +62,18 @@ func (f ServerFiles) Headroom() int { return f.Limit - f.InUse } // the ones a few agent-desk windows can fill. func (f ServerFiles) Low() bool { return f.Limit > 0 && f.Limit < 1024 } +// Relief is the shortest instruction that gives the server room again. A +// server on the old default class (Low) stays capped however many windows +// close, so closing one only buys time; the real fix is to restart it so a +// fresh server inherits agent-desk's raised limit. A roomier server that is +// merely full answers again the moment a window closes. +func (f ServerFiles) Relief() string { + if f.Low() { + return "restart the tmux server to lift the limit (Troubleshooting: tmux file limit)" + } + return "Close an extra agent-desk window (Troubleshooting: tmux file limit)" +} + // ProbeServerFiles reads the default tmux server's limit (through a shell it // spawns, which inherits it) and counts its descriptors with lsof. func ProbeServerFiles() (ServerFiles, error) { diff --git a/internal/tmux/serverfiles_test.go b/internal/tmux/serverfiles_test.go index bed6aa87..a5d2b8bf 100644 --- a/internal/tmux/serverfiles_test.go +++ b/internal/tmux/serverfiles_test.go @@ -46,6 +46,14 @@ func TestPipeBudget(t *testing.T) { assert.False(t, ServerFiles{Limit: 16384}.Low()) } +// A low-limit (legacy) server is capped no matter how many windows close, so +// its relief is to restart; a roomier server that is merely full frees up +// when a window closes. +func TestRelief(t *testing.T) { + assert.Contains(t, ServerFiles{Limit: 256, InUse: 200}.Relief(), "restart the tmux server") + assert.Contains(t, ServerFiles{Limit: 16384, InUse: 16000}.Relief(), "Close an extra agent-desk window") +} + // A server without room for another pipe gets none: Connect refuses before // spawning a client, and the session is counted as going without. func TestConnectRefusedWithoutServerRoom(t *testing.T) { diff --git a/internal/ui/home.go b/internal/ui/home.go index a83b97eb..aad660bd 100644 --- a/internal/ui/home.go +++ b/internal/ui/home.go @@ -1321,22 +1321,27 @@ func (h *Home) bannerMsg() string { // unexpectedly" while the agents keep running (issues #3, #4). Reads only // cached state, so it is cheap per tick. func tmuxServerWarning() string { + pm := tmux.GetPipeManager() + var room tmux.ServerFiles + skipped := 0 + if pm != nil { + room, skipped = pm.Room() + } + if since, full := tmux.ServerUnreachable(); full { - return fmt.Sprintf("tmux server is full (open-file limit) since %s: agents still running. Close an extra agent-desk window to free it", - since.Format("3:04pm")) + return fmt.Sprintf("tmux server is full (open-file limit) since %s: agents still running. %s", + since.Format("3:04pm"), room.Relief()) } - pm := tmux.GetPipeManager() if pm == nil { return "" } - room, skipped := pm.Room() if skipped > 0 { - return fmt.Sprintf("tmux server near its open-file limit (%d of %d): %d session(s) without live status. Close an extra agent-desk window (Troubleshooting: tmux file limit)", - room.InUse, room.Limit, skipped) + return fmt.Sprintf("tmux server near its open-file limit (%d of %d): %d session(s) without live status. %s", + room.InUse, room.Limit, skipped, room.Relief()) } if room.Low() && room.PipeBudget() < pm.ConnectedCount() { - return fmt.Sprintf("tmux server allows only %d open files (%d in use): another agent-desk window won't fit (Troubleshooting: tmux file limit)", - room.Limit, room.InUse) + return fmt.Sprintf("tmux server allows only %d open files (%d in use): %s", + room.Limit, room.InUse, room.Relief()) } return "" } From 1f0eaf845285375115713d9d34e4d1a550c7c1da Mon Sep 17 00:00:00 2001 From: Millwright Software <249657134+millwright-software@users.noreply.github.com> Date: Wed, 11 Nov 2026 10:55:39 -0600 Subject: [PATCH 2/2] Banner: say what a tmux restart costs; keep the limit when the server is full - Relief() for a low-limit server now says the restart ends every session (R resumes Claude ones), so the banner never points at the destructive fix without its cost. - A full server cannot be probed, and the failed probe blanked the cached reading, so the "server is full" banner fell back to "Close an extra window" even on a 256 server. PipeManager keeps the last good reading (LastRoom) and that branch uses it. - The low-limit notice keeps its reason ("another agent-desk window won't fit") ahead of the instruction. Co-Authored-By: Claude Fable 5.2 --- CHANGELOG.md | 3 ++- internal/tmux/pipemanager.go | 13 ++++++++++ internal/tmux/serverfiles.go | 8 +++--- internal/tmux/serverfiles_test.go | 43 ++++++++++++++++++++++++++++--- internal/ui/home.go | 9 ++++--- 5 files changed, 65 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e5b0e73..47a7f2cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ the in-app updater downloads the `agent-desk___.tar.gz` asset ### Fixed -- The tmux open-file-limit banner now tells you to **restart the tmux server** when the server is on the old 256 default, instead of "Close an extra agent-desk window". Closing a window only frees descriptors for a moment on a server that stays capped, and assumes you have a second window to close; a server agent-desk started before v1.0.28 (or a plain `tmux` from a shell) keeps 256 until it exits, so a restart is the only thing that lifts the limit for good. A genuinely roomier server that is merely full still points you to close a window. +- The tmux open-file-limit banner no longer says "Close an extra agent-desk window" to a server on the old 256 default. Closing a window only frees descriptors for a moment on a server that stays capped, and assumes you have a second window to close; a server agent-desk started before v1.0.28 (or a plain `tmux` from a shell) keeps 256 until it exits. The banner now says that only a tmux server restart lifts the limit, **and that the restart ends every session** (`R` resumes Claude ones), so the choice stays yours. A roomier server that is merely full still points you to close a window. +- The "tmux server is full" banner knows which kind of server it is. A full server cannot be probed, so the banner used to lose the limit at the moment it mattered; it now uses the last reading that succeeded. ## [1.0.28] - 2026-11-11 diff --git a/internal/tmux/pipemanager.go b/internal/tmux/pipemanager.go index 70acbd10..6e70dcd9 100644 --- a/internal/tmux/pipemanager.go +++ b/internal/tmux/pipemanager.go @@ -31,6 +31,7 @@ type PipeManager struct { // probe is cached and debited per pipe, so a batch of connects costs one. roomMu sync.Mutex room ServerFiles + lastRoom ServerFiles // the last reading a probe returned without error roomAt time.Time roomErr error skipped map[string]bool // sessions left without a pipe for lack of room @@ -444,6 +445,7 @@ func (pm *PipeManager) takeRoom(sessionName string) error { f, err := pm.probeRoom() pm.room, pm.roomErr, pm.roomAt = f, err, time.Now() if err == nil { + pm.lastRoom = f pipeLog.Debug("tmux_server_files", slog.Int("limit", f.Limit), slog.Int("in_use", f.InUse), slog.Int("pipe_budget", f.PipeBudget())) } } @@ -484,6 +486,17 @@ func (pm *PipeManager) Room() (ServerFiles, int) { return pm.room, len(pm.skipped) } +// LastRoom is the last reading a probe returned without error. A server that +// refuses clients cannot be probed, so Room goes blank exactly when the +// banner most needs to know which class of server it is talking about; the +// limit does not change while a server lives, so the last good one stands. +// Zero when no probe has succeeded yet. +func (pm *PipeManager) LastRoom() ServerFiles { + pm.roomMu.Lock() + defer pm.roomMu.Unlock() + return pm.lastRoom +} + // tmuxSessionExists checks if a tmux session exists (lightweight subprocess). func tmuxSessionExists(name string) bool { cmd := exec.Command("tmux", "has-session", "-t", name) diff --git a/internal/tmux/serverfiles.go b/internal/tmux/serverfiles.go index dc4067d9..b6294034 100644 --- a/internal/tmux/serverfiles.go +++ b/internal/tmux/serverfiles.go @@ -65,11 +65,13 @@ func (f ServerFiles) Low() bool { return f.Limit > 0 && f.Limit < 1024 } // Relief is the shortest instruction that gives the server room again. A // server on the old default class (Low) stays capped however many windows // close, so closing one only buys time; the real fix is to restart it so a -// fresh server inherits agent-desk's raised limit. A roomier server that is -// merely full answers again the moment a window closes. +// fresh server inherits agent-desk's raised limit. That restart ends every +// session in the server, so the instruction says so: the banner must not +// send someone to the destructive fix without its cost. A roomier server +// that is merely full answers again the moment a window closes. func (f ServerFiles) Relief() string { if f.Low() { - return "restart the tmux server to lift the limit (Troubleshooting: tmux file limit)" + return "Only a tmux server restart lifts its limit, and that ends every session (R resumes Claude ones). Troubleshooting: tmux file limit" } return "Close an extra agent-desk window (Troubleshooting: tmux file limit)" } diff --git a/internal/tmux/serverfiles_test.go b/internal/tmux/serverfiles_test.go index a5d2b8bf..307fbb81 100644 --- a/internal/tmux/serverfiles_test.go +++ b/internal/tmux/serverfiles_test.go @@ -47,11 +47,46 @@ func TestPipeBudget(t *testing.T) { } // A low-limit (legacy) server is capped no matter how many windows close, so -// its relief is to restart; a roomier server that is merely full frees up -// when a window closes. +// its relief is to restart, and the instruction carries what that costs; a +// roomier server that is merely full frees up when a window closes. func TestRelief(t *testing.T) { - assert.Contains(t, ServerFiles{Limit: 256, InUse: 200}.Relief(), "restart the tmux server") - assert.Contains(t, ServerFiles{Limit: 16384, InUse: 16000}.Relief(), "Close an extra agent-desk window") + low := ServerFiles{Limit: 256, InUse: 200}.Relief() + assert.Contains(t, low, "tmux server restart") + assert.Contains(t, low, "ends every session") + roomy := ServerFiles{Limit: 16384, InUse: 16000}.Relief() + assert.Contains(t, roomy, "Close an extra agent-desk window") + assert.NotContains(t, roomy, "restart") + assert.Contains(t, ServerFiles{}.Relief(), "Close an extra agent-desk window", "unknown limit: the safe instruction") +} + +// A server that refuses clients cannot be probed, and the failed probe blanks +// Room. LastRoom keeps the last good reading so the full-server banner still +// knows it is talking about a low-limit server. +func TestLastRoomSurvivesFailedProbe(t *testing.T) { + pm := NewPipeManager(t.Context(), nil) + defer pm.Close() + fail := false + pm.probeRoom = func() (ServerFiles, error) { + if fail { + return ServerFiles{}, errors.New("server exited unexpectedly") + } + return ServerFiles{PID: 1, Limit: 256, InUse: 100}, nil + } + + assert.Equal(t, 0, pm.LastRoom().Limit, "nothing known before a probe") + _ = pm.takeRoom("agentdesk_nope_a") + assert.Equal(t, 256, pm.LastRoom().Limit) + + fail = true + pm.roomMu.Lock() + pm.roomAt = time.Time{} // the reading has gone stale + pm.roomMu.Unlock() + _ = pm.takeRoom("agentdesk_nope_b") + + room, _ := pm.Room() + assert.Equal(t, 0, room.Limit, "the failed probe blanked the current reading") + assert.True(t, pm.LastRoom().Low(), "the last good reading stands") + assert.Contains(t, pm.LastRoom().Relief(), "tmux server restart") } // A server without room for another pipe gets none: Connect refuses before diff --git a/internal/ui/home.go b/internal/ui/home.go index aad660bd..5f11c30a 100644 --- a/internal/ui/home.go +++ b/internal/ui/home.go @@ -1322,15 +1322,18 @@ func (h *Home) bannerMsg() string { // cached state, so it is cheap per tick. func tmuxServerWarning() string { pm := tmux.GetPipeManager() - var room tmux.ServerFiles + var room, known tmux.ServerFiles skipped := 0 if pm != nil { room, skipped = pm.Room() + known = pm.LastRoom() } + // A full server cannot be probed, so room is blank here; the last good + // reading says which class of server it is. if since, full := tmux.ServerUnreachable(); full { return fmt.Sprintf("tmux server is full (open-file limit) since %s: agents still running. %s", - since.Format("3:04pm"), room.Relief()) + since.Format("3:04pm"), known.Relief()) } if pm == nil { return "" @@ -1340,7 +1343,7 @@ func tmuxServerWarning() string { room.InUse, room.Limit, skipped, room.Relief()) } if room.Low() && room.PipeBudget() < pm.ConnectedCount() { - return fmt.Sprintf("tmux server allows only %d open files (%d in use): %s", + return fmt.Sprintf("tmux server allows only %d open files (%d in use): another agent-desk window won't fit. %s", room.Limit, room.InUse, room.Relief()) } return ""