Skip to content

fix(tmux): target sessions with a trailing colon so numeric session names resolve - #328

Closed
sandersjdd wants to merge 5 commits into
kunchenguid:mainfrom
sandersjdd:fm/fix-tmux-numeric-session
Closed

sandersjdd wants to merge 5 commits into
kunchenguid:mainfrom
sandersjdd:fm/fix-tmux-numeric-session

Conversation

@sandersjdd

Copy link
Copy Markdown

Problem

When firstmate runs inside a tmux session with a numeric name (the unnamed default session is 0), spawning a task fails with create window failed: index 0 in use.
tmux parses a bare numeric -t target as a window index in the current session rather than a session name; with a free numeric index (e.g. -t "5", no session named 5) it instead silently creates the window in the wrong session.
Observed live on 2026-07-06.

Fix

  • fm_backend_tmux_create_task (bin/backends/tmux.sh) now targets sessions with a trailing colon (-t "$ses:"), which tmux unambiguously parses as a session, in both its list-windows duplicate check and its new-window call.
  • Audited all -t usages across bin/*.sh and bin/backends/*.sh: these two were the only bare-session targets. has-session -t firstmate is deliberately left bare (it only accepts session targets and the name is a fixed non-numeric literal). All other targets are session:window composites or window names and are unchanged.

Verification

  • tests/fm-backend-tmux-smoke.test.sh gained a numeric-session section on a real private-socket tmux server (session named 0): reproduced the exact live failure pre-fix, passes post-fix, asserts the window lands in session 0 and does not leak into another session, and duplicate refusal still works.
  • docs/tmux-backend.md gained a dated empirical note (tmux 3.6a) recording the observed behaviors, per the backend-verification-evidence guideline.
  • shellcheck bin/*.sh bin/backends/*.sh tests/*.sh clean; all 44 tests/*.test.sh scripts pass.

Pipeline commits riding along

The branch was validated through the no-mistakes pipeline (review, test, document, lint all green); its head includes the pipeline's own fix commits:

  • 215c297 test-step fix: locale-sensitive prompt-glyph stripping in composer-state readers.
  • fce68ab review fix round: locale-safe herdr bare-prompt regex plus LC_ALL=C composer fixtures.
  • e49f138, 5bd40ec document-step syncs (CONTRIBUTING test coverage list, regex/coverage docs).

The upstream push from the pipeline was blocked by repo permissions, so this PR delivers the validated head from a fork instead.

…ames resolve

tmux parses a bare numeric -t target as a window index in the current
session, so spawning from the unnamed default session "0" failed with
"create window failed: index 0 in use" (or silently landed the window in
the wrong session for a free index). Target sessions as "$ses:" in
fm_backend_tmux_create_task's list-windows and new-window calls, which
tmux unambiguously parses as a session. has-session keeps its bare
fixed non-numeric "firstmate" target; all other -t usages already pass
session:window composites or window names.

Verified on tmux 3.6a against a private-socket server; the extended
smoke test reproduces the failure pre-fix and passes post-fix.
@kunchenguid

Copy link
Copy Markdown
Owner

Thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#328 at 5bd40ec9.

@kunchenguid

Copy link
Copy Markdown
Owner

Automated reminder: this PR still looks blocked on a rebase or merge conflict fix.

If you are still interested, please rebase onto the current base branch, resolve the conflict, and push.

If I do not hear back, I may close this as inactive.

@kunchenguid kunchenguid added wheelhouse:pending-contributor-action Managed by Wheelhouse and removed wheelhouse:pending-contributor-action Managed by Wheelhouse labels Jul 20, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

I am closing this because it has been waiting on a rebase or merge-conflict fix since 2026-07-10, and I have not seen a comment or push since then.

If you still want to keep working on this, please reopen it or open a new PR and mention this one.

Happy to take another look when there is an update.

sctru added a commit to sctru/firstmate that referenced this pull request Aug 3, 2026
Merge 6 upstream commits (kunchenguid#353 AFK herdr escalations, kunchenguid#367 harness-aware
supervision, kunchenguid#369 X-mode platform split, kunchenguid#372 stow inspect-before-update,
kunchenguid#375 watcher wait-on-healthy-arm, kunchenguid#386 pi launch simplification) into the
captain's 11 local-only commits.

Resolved 3 documentation conflicts by union (CONTRIBUTING.md,
docs/configuration.md, docs/scripts.md), preserving both the captain's
local additions and upstream's new content. The one genuine contradiction
- FM_BACKEND_HERDR_BARE_PROMPT_RE - keeps the captain's locale-safe
alternation '^(|)' (matching the merged code default) with upstream's
faint-Codex-suggestion note folded in.

Semantic-merge audit of the watcher/guard/backend surface confirmed no
behavioral collision: local orphan-marker guard, kunchenguid#328 numeric-session fix,
and locale-safe regex/glyph fixes all coexist coherently with upstream's
wait-on-healthy-arm, harness-aware supervision, and ANSI/faint herdr work.
@idevakk

idevakk commented Oct 30, 2026

Copy link
Copy Markdown

Local verification

GitHub Actions is temporarily disabled for this repository (account free minutes exhausted), so no workflow job ran and local verification was used as the gate. Results on head 9b3bc00906a50752374a8105810af803c9c7be73:

  • ./vendor/bin/pest - 743 passed (4040 assertions)
  • ./vendor/bin/pest --type-coverage --min=100 - 100.0%
  • php -d memory_limit=1G vendor/bin/phpstan analyse -a vendor/larastan/larastan/bootstrap.php --no-progress - no errors
  • ./vendor/bin/pint --test - passed
  • ./vendor/bin/rector --dry-run - clean

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.

3 participants