Skip to content

fix(tmux): disable continuum auto-restore to stop tpo cold-start hang - #1893

Merged
shunkakinoki merged 4 commits into
mainfrom
fix/tmux-continuum-restore-cold-start-hang
Jun 7, 2026
Merged

fix(tmux): disable continuum auto-restore to stop tpo cold-start hang#1893
shunkakinoki merged 4 commits into
mainfrom
fix/tmux-continuum-restore-cold-start-hang

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Problem

tpo hangs on startup unless another tmux session already exists in another tab.

Root cause

@continuum-restore 'on' races with __tmux_bootstrap_default_session on cold server start:

  1. tpo_tpo_function → with no primary session, runs tmux new-session -d -s primary -n btop, which cold-starts the tmux server.
  2. On server start, continuum's main() hits just_started_tmux_server → launches continuum_restore.sh &, which (after a 1s sleep) restores the saved sessions, re-spawning btop fish git and restoring pane contents.
  3. That background restore stomps on the session the bootstrap is simultaneously building; the foreground tmux attach-session -t primary lands on a session being rewritten under it → frozen screen.

When a session already exists in another tab, tmux new-session reuses the running server, so just_started_tmux_server is false → restore never fires → no race. This matches the symptom exactly.

Fix

Set @continuum-restore 'off'. Restore is already driven manually by two/_two_function for the work session only (_two_function.fish:33-34 invokes the resurrect restore script directly), so auto-restore is redundant there and harmful on tpo/tdo/tmo.

  • tpo/tdo/tmo cold-start cleanly, no race, no hang.
  • two is unaffected — it restores work itself.
  • Saving still runs every 3 min, so work snapshots stay current.

Test plan

  • home-manager switch, then tmux kill-server once to drop the running server holding the old on value.
  • Run tpo with no existing server → attaches cleanly, no hang.
  • Run two → still restores the work session.

Summary by cubic

Disable tmux Continuum auto-restore (@continuum-restore 'off') to stop tpo cold-start hangs; saves still run every 3 minutes and two keeps restoring work manually. Improve npm-globals to reinstall packages missing platform-native binaries (e.g., @anthropic-ai/claude-code) and enable the Karabiner keyboard device (vendor 1278, product 22).

Written for commit 7e1a603. Summary will update on new commits.

Review in cubic

@indent-zero

indent-zero Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor
PR Summary

Disables tmux-continuum's automatic resurrect-restore so a cold tmux server start no longer races __tmux_bootstrap_default_session (the path hit by tpo) and freezes the freshly attached client. Continuum's periodic save remains on and _two_function continues to drive manual restore for the work session. Two follow-up commits bundled in the same PR generalize a claude-code-specific native-binary repair into a per-package platform-native opt-dep check in install-npm-globals.sh, and explicitly enable a third-party keyboard (vendor 1278 / product 22) in karabiner.json. PR is now merged.

  • home-manager/programs/tmux/default.nix: flip @continuum-restore from 'on' to 'off' with an inline comment explaining the cold-start race and the manual two/_two_function restore path.
  • home-manager/modules/npm-globals/install-npm-globals.sh: derive PLATFORM_OS/PLATFORM_CPU once, add missing_native_optional_dep that scans an installed package's optionalDependencies for entries matching both platform tokens and checks whether they're present in node_modules, then integrate the check into the version-skip branch so the package dir is dropped and queued for bun add --global when the native dep is absent. Replaces the prior claude-code-specific repair_claude_code_native_binary function and its post-install call.
  • spec/npm_globals_spec.sh: replace the claude-code-specific assertions with a "native binary completeness" describe block and add an integration test that stubs bun/timeout, plants a nativecli package whose platform-native opt-dep dir is absent, and verifies the script invokes bun add --global nativecli.
  • config/karabiner/karabiner.json: add a devices entry under the profile that sets ignore: false for the keyboard with vendor_id: 1278, product_id: 22.

Issues

1 potential issue found:

  • PR bundles three unrelated changes — tmux continuum disable, npm-globals native-binary repair (456ec11/46f5e10), and a karabiner keyboard enable entry (7e1a603). PR is already merged, but for future work consider keeping unrelated fixes in separate PRs so each can be reverted independently and git log reads cleanly. → Autofix
1 issue already resolved
  • claude --version is invoked without a timeout in the new repair function; if a broken claude binary hangs at startup rather than exiting non-zero, home-manager activation will stall on this step. Wrap both pre- and post-check invocations in timeout (e.g. timeout 10 claude --version). (fixed by commit 46f5e10)

CI Checks

Waiting for CI checks...


⚡ Autofix All Issues

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@shunkakinoki, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 26 minutes and 48 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eca356cd-f15b-4f0d-bab9-d1e8f7ef1c5d

📥 Commits

Reviewing files that changed from the base of the PR and between 08c2779 and 7e1a603.

📒 Files selected for processing (3)
  • config/karabiner/karabiner.json
  • home-manager/modules/npm-globals/install-npm-globals.sh
  • spec/npm_globals_spec.sh
📝 Walkthrough

Walkthrough

The @continuum-restore setting in the tmux continuum plugin is switched from 'on' to 'off' to disable automatic session restoration at startup. Comments document that this prevents startup race conditions and explains that restoration should be triggered manually for the work session.

Changes

Tmux continuum restore configuration

Layer / File(s) Summary
Disable continuum auto-restore with explanatory comments
home-manager/programs/tmux/default.nix
The continuum plugin's @continuum-restore is changed from 'on' to 'off'. Comments are added explaining that auto-restore is disabled to avoid startup races and that restore must be triggered manually for the work session.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • shunkakinoki/dotfiles#1529: Both PRs modify the tmux continuum plugin's @continuum-restore setting in the same configuration file.
  • shunkakinoki/dotfiles#1287: Both PRs address tmux resurrect/continuum restore timing by adjusting restore behavior to prevent startup race issues.

Poem

🐰 A session sleeps, no auto-wake in sight,
The continuum rests, restored by paw tonight,
Race conditions vanquished with a thoughtful tweak,
Work awaits the signal, manual and sleek!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: disabling tmux continuum auto-restore to resolve the tpo cold-start hang issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly explains the problem (tpo hangs on startup), root cause (race between continuum auto-restore and tmux bootstrap on cold start), and fix (disable @continuum-restore), all directly related to the changeset in tmux/default.nix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tmux-continuum-restore-cold-start-hang

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the tmux configuration in home-manager/programs/tmux/default.nix to disable the automatic restore feature of the continuum plugin (@continuum-restore set to 'off'). A detailed comment has been added explaining that auto-restore is disabled to prevent race conditions and client freezing during cold tmux server starts, with restoration now handled manually. There are no review comments, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@mesa-dot-dev

mesa-dot-dev Bot commented Jun 7, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

  • Disables automatic tmux Continuum restoration (@continuum-restore 'off') to resolve a cold-start hang (tpo) caused by a race condition during default session bootstrapping.
  • Enhances the global npm package installer to automatically detect and reinstall packages missing their platform-native optional dependencies (e.g., @anthropic-ai/claude-code).

What changed?

  • home-manager/programs/tmux/default.nix:
    • Disabled @continuum-restore (set to 'off') and added comments explaining the startup race condition.
  • home-manager/modules/npm-globals/install-npm-globals.sh:
    • Added OS and CPU platform detection.
    • Implemented missing_native_optional_dep helper function to identify, remove, and queue packages missing native optional dependencies for re-installation.
  • spec/npm_globals_spec.sh:
    • Added ShellSpec unit and integration tests to verify detection and re-installation of packages using bun.

Test plan

  • Run home-manager switch, then tmux kill-server to drop the old running server state.
  • Run tpo with no existing server and verify it attaches cleanly without hanging.
  • Run two and verify it still restores the work session.

Description generated by Mesa. Update settings

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@mesa-dot-dev mesa-dot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performed full review of 1614fa2...08c2779

Analysis

• Breaking behavioral change: Global auto-restore disable removes session restoration for all non-work sessions after server restart/crash; users relying on this will lose that functionality with no clear migration path.

• Single point of failure in restore flow: Restoration now depends entirely on users invoking the two command; any alternate entry paths to the work session (or gaps in workflow adoption) will silently skip restore, leading to stale state without validation.

• Incomplete visibility of implementation: The manual restore invocation in _two_function is not shown in this PR; assuming it exists and works correctly creates risk if the underlying resurrect restore call is misconfigured or missing failure handling.

• Documentation gap in user-facing commands: The rationale for changed restore behavior is documented in Nix config comments but likely invisible to end users; shell function definitions (where users see two/tpo/etc.) are not part of this PR, leaving no visible trace of the behavioral shift.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

0 files reviewed | 1 comments | Edit Agent SettingsRead Docs

# server start, racing __tmux_bootstrap_default_session and freezing
# the freshly-attached client (e.g. on `tpo`). Restore is driven
# manually by `two`/_two_function for the `work` session only.
set -g @continuum-restore 'off'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium

This change disables auto-restore globally for all sessions, not just for tpo/tdo/tmo. While this fixes the race condition, it creates a single point of failure: restore now only works if users enter the work session via the two command.

Consider:

  1. Verify that ALL entrypoints to the work session route through two/_two_function - if users can attach to work via tmux attach -t work or other means, restore won't trigger.
  2. Document this behavioral change in user-facing documentation (README, shell function comments) since the Nix config comment won't be visible to users of the shell commands.
  3. Confirm that the manual restore in _two_function (mentioned as lines 33-34) is robust and handles failure cases appropriately.

If auto-restore for other sessions was previously relied upon, this is a functional regression. The test plan should verify behavior after server crash/reboot, not just clean shutdown scenarios.

Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#1893
File: home-manager/programs/tmux/default.nix#L32
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
This change disables auto-restore globally for all sessions, not just for `tpo`/`tdo`/`tmo`. While this fixes the race condition, it creates a single point of failure: restore now only works if users enter the `work` session via the `two` command.

Consider:
1. Verify that ALL entrypoints to the `work` session route through `two`/`_two_function` - if users can attach to `work` via `tmux attach -t work` or other means, restore won't trigger.
2. Document this behavioral change in user-facing documentation (README, shell function comments) since the Nix config comment won't be visible to users of the shell commands.
3. Confirm that the manual restore in `_two_function` (mentioned as lines 33-34) is robust and handles failure cases appropriately.

If auto-restore for other sessions was previously relied upon, this is a functional regression. The test plan should verify behavior after server crash/reboot, not just clean shutdown scenarios.

Comment thread home-manager/modules/npm-globals/install-npm-globals.sh Outdated
@shunkakinoki
shunkakinoki merged commit 50e2d88 into main Jun 7, 2026
10 checks passed
@shunkakinoki
shunkakinoki deleted the fix/tmux-continuum-restore-cold-start-hang branch June 7, 2026 16:06
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