fix(cli): prevent daemon respawn and harden tmux session resume#139
Closed
caseyjkey wants to merge 9 commits intohappier-dev:devfrom
Closed
fix(cli): prevent daemon respawn and harden tmux session resume#139caseyjkey wants to merge 9 commits intohappier-dev:devfrom
caseyjkey wants to merge 9 commits intohappier-dev:devfrom
Conversation
When creating a new window in an existing tmux session, tmux can fail with "create window failed: index N in use" due to window index allocation issues. The previous retry logic just retried the same command, which would fail again if tmux kept trying to use the same conflicting index. This fix: - Adds extractTmuxWindowIndexConflict() to parse the conflicting index - Adds getWindowIndices() to query session for existing window indices - Adds findAvailableWindowIndex() to find an available index (gap or next) - Updates retry logic to explicitly target an available index on retry On first attempt: tmux new-window -t session (auto-assign) On retry: tmux new-window -t session:3 (explicit available index)
Bumping version so daemon detects code change and restarts with the tmux window index conflict fix from previous commit.
When stopping a session via the app (killSession RPC) or Ctrl-C, the daemon would sometimes respawn it after ~60 seconds. This happened because the killSession RPC handler exited without notifying the daemon, so the heartbeat loop detected a missing process and triggered respawn. Fix: Call stopDaemonSession(sessionId) in the killSession handler before exiting. This marks the session as "stop requested" in the respawn manager, preventing unwanted respawns. Discovered during mobile development testing on Termux.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolveHasTTYbut allow tmux sessions started by the daemon to re-enable Ink whenHAPPIER_CLI_ALLOW_DAEMON_TTY_IN_TMUX=1, so tmux-based resumes from the app continue to work while other daemon sessions stay headlessVerification
yarn workspace @happier-dev/cli vitest run src/integrations/tmux/env.extractIndex.test.ts src/integrations/tmux/tmux.spawnAndEnv.test.ts src/sessionControl/sessionRpc.plaintext.test.tsHAPPIER_CLI_TMUX_INTEGRATION=1 yarn workspace @happier-dev/cli vitest run --config vitest.integration.config.ts src/integrations/tmux/tmux.real.integration.test.ts src/backends/claude/runClaude.fastStart.integration.test.tsyarn workspace @happier-dev/cli vitest run --config vitest.integration.config.ts src/backends/claude/claudeRemoteLauncher.integration.test.ts -t \"does not mount Ink UI for daemon-started sessions even when a TTY is available\"yarn workspace @happier-dev/cli typecheckFollow-up