Skip to content

Run tmux watchers and dependencies in one shared services window - #729

Merged
tonyalaribe merged 1 commit into
masterfrom
tmux-services-window
Oct 26, 2026
Merged

tonyalaribe merged 1 commit into
masterfrom
tmux-services-window

Conversation

@tonyalaribe

Copy link
Copy Markdown
Contributor

Agents opened a new tmux window (or session) per watcher/dependency, and the old helpers pinned panes per window, so an agent in another window started duplicates.

  • One tmux_pane helper replaces tmux_run/tmux_own_pane: one pane per worktree+job, tracked in a session option, created in a shared services window (tiled, labelled <worktree>:<job>), reused from any window.
  • Panes run a shell with the job typed in, so C-c on reuse no longer closes the pane; a dead pane is recreated.
  • Adds tmux-minio-local.
  • AGENTS.md: never tmux new-window/new-session for watchers; use make tmux-*.

Sign-off: all checks attested for this tree (make ci-signoff).

🤖 Generated with Claude Code

Panes are tracked per worktree+job in session options, so any window
reuses them instead of opening a new window. Adds tmux-minio-local.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@claude

claude Bot commented Oct 26, 2026

Copy link
Copy Markdown

Review (Makefile/AGENTS.md only; not run locally, since it needs tmux). The consolidation is a net win: about 4 fewer lines, and one helper replaces two.

Issues

  • Foreground fallback exit status: echo ...; $(2); exit ends with a bare exit, which returns exit's own status, 0. A failing make live-reload outside tmux therefore reports success. Use $(2); exit $$?, or exec-style $(2) as the last command.
  • Session scope: tmux show-option and set-option with no -t act on the current session, and -t :services also resolves to the current session. An agent in a different tmux session on the same server won't find the tracked pane and will start a duplicate, which is the bug this PR targets. If cross-session reuse is intended, use a server-global option (set-option -s/-g) and an explicit services session or window target. If it isn't intended, say "within a session" in the AGENTS.md line.
  • Check-then-create race: list-windows | grep services followed by new-window is not atomic. Two agents starting at once can create two services windows. It's minor, but tmux new-window -d -n services ... || split-window guarded by select-window -t :services, or a flock, would close it.
  • Shared build key: tmux-live-reload and tmux-live-reload-cli both use key build, so starting one C-c's the other. This matches the old pinned-pane behaviour, but it is easy to trip over. Add a one-line comment, or give the CLI its own key.
  • Stale comment: the tmux-web-components-watch comment now says "not the build pane", but tmux-pin-here lets the user point build at any pane. Not a bug.

Conciseness

  • alive runs twice. A single alive && { send-keys C-c; sleep 0.5; } followed by a reuse branch that re-checks would be shorter. Alternatively, drop the second check and let send-keys fail into the recreate path.
  • tmux-pin-here and tmux-unpin could share a $(TMUX_WT)-keyed variable (BUILD_KEY := @build-$(TMUX_WT)), so the key string isn't repeated three times.
  • tmux_pane needs both $(1) as key and $(2) as command in every call. Key it off a target-name pattern rule (tmux-%) to drop the first argument and the 4 wrapper targets. That is optional, but would make adding the next tmux-* a one-liner.

No tests apply here. The AGENTS.md addition is accurate and succinct.

@monoscope-bot

monoscope-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

Monoscope production impact · Worth checking

Project 87576849-4941-49d3-a15d-680fef88a1a8 · reviewed 3a264528f50b337abb633b4f4e073b37aa970c68 · advisory

Evidence window (UTC): 2026-10-19 09:56:35.961850921 UTC → 2026-10-26 09:56:35.961850921 UTC

Makefile:340 (Head)

Inferred: The pane-reuse path sends an interrupt and waits a fixed 0.5 seconds, while its liveness check only verifies that the tmux pane still exists. If the previous watcher takes longer to terminate, the replacement command can be delivered to the still-running process instead of a shell, leaving the requested restart ineffective.

Next check: Wait for the tracked job to exit with a bounded timeout and escalation, and dispatch the replacement only after confirming the shell or expected idle state.

telemetry evidence · Observed: 8772393 events · 0 errors · service: srv-captain--monoscope

Makefile:336 (Head)

Inferred: The pane key uses only the basename of the current directory. Distinct worktrees with the same basename can therefore alias the same session option and pane, causing one worktree's watcher to interrupt or replace another worktree's job.

Next check: Derive the key from a canonical absolute worktree path or a collision-resistant hash, and test simultaneous same-basename worktrees.

telemetry evidence · Observed: 8772393 events · 0 errors · service: srv-captain--monoscope

Makefile:349 (Head)

Inferred: The pane border format does not use tmux's format expansion for the user-defined job option, so the intended job identity can render as literal text. This makes panes difficult to distinguish during watcher failures or restarts.

Next check: Use the tmux user-option format expression in the border template and verify that different jobs display distinct labels.

telemetry evidence · Observed: 8772393 events · 0 errors · service: srv-captain--monoscope

Coverage: Evidence is capped at 20 service/environment groups, monitors and dashboard queries. Telemetry describes the mapped service, not a proven changed-path or deployed-revision match. Monitor and dashboard references are project-wide; their relationship to the mapped service is unverified. Diff coverage is incomplete: only the first 30 files and 2000 characters per patch are inspected. The Makefile patch is truncated before the tmux pane option-write and command-dispatch tail, so persistence of the mapping and replacement-command behavior could not be verified. No test or runtime evidence covers slow watcher shutdown, same-basename worktrees, concurrent invocations, or pane-label rendering. The available telemetry is not linked to the changed Makefile path or deployed revision and contains no direct watcher or dependency lifecycle signals.

Review history and settings

@tonyalaribe
tonyalaribe merged commit 0688d81 into master Oct 26, 2026
14 checks passed
@tonyalaribe
tonyalaribe deleted the tmux-services-window branch October 26, 2026 10:47
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