fix(tui): stop creating empty sessions, spawn on Enter - #924
Conversation
serve no longer pre-creates empty bash sessions for every agent. Sessions are created on-demand by genie spawn. TUI Enter handler spawns the agent if not running, then attaches.
There was a problem hiding this comment.
Code Review
This pull request refactors agent session management by shifting from pre-creating tmux sessions at startup to an on-demand creation model. It removes the startAgentTmuxServer and discoverAgents functions from the server command and updates the TUI navigation to spawn agents if they are not currently running. A review comment suggests improving the user experience in the TUI by handling the asynchronous nature of agent spawning more robustly to ensure the session is fully ready before the user attaches to it.
| if (node.wsAgentState !== 'running') { | ||
| spawnAgent(node.label); |
There was a problem hiding this comment.
The spawnAgent function is asynchronous and detached. When Enter is pressed, spawnAgent is called, and then onTmuxSessionSelect is immediately invoked to attach to the session. If the agent takes a moment to fully initialize within its tmux session, the user might briefly attach to an empty or partially ready pane. While ensureAgentSession in tmux.ts ensures the tmux session exists, it doesn't guarantee the agent process inside it is fully operational. Consider making the handleEnter callback async and introducing a short delay or a polling mechanism after spawnAgent to wait for the agent's wsAgentState to transition to 'running' before attempting to attach. This would improve the user experience by ensuring a more complete view upon attachment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ced84ade44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (node.wsAgentState !== 'running') { | ||
| spawnAgent(node.label); |
There was a problem hiding this comment.
Avoid respawn while agent state is already spawning
This condition treats every non-running agent as spawnable, so pressing Enter on an agent in spawning state launches another detached genie spawn. In handleWorkerSpawn, each spawn first calls terminateActiveExecutorWithCleanup, so the second launch can terminate the in-flight executor and restart it, causing startup thrash when users hit Enter to attach during boot. Restrict this branch so Enter does not trigger a new spawn while wsAgentState is spawning.
Useful? React with 👍 / 👎.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE 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 |
Summary
startAgentTmuxServer()from serve — no more empty bash sessionsgenie spawnTest plan
genie serve startdoes NOT create agent sessions