Skip to content

fix(tui): stop creating empty sessions, spawn on Enter - #924

Merged
namastex888 merged 1 commit into
devfrom
fix/remove-empty-sessions
Mar 30, 2026
Merged

namastex888 merged 1 commit into
devfrom
fix/remove-empty-sessions

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Summary

  • Remove startAgentTmuxServer() from serve — no more empty bash sessions
  • Sessions created on-demand by genie spawn
  • TUI Enter handler spawns agent if not running, then attaches

Test plan

  • genie serve start does NOT create agent sessions
  • Press Enter on agent in TUI → Claude spawns + right pane attaches

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.
@namastex888
namastex888 merged commit d89bf6b into dev Mar 30, 2026
5 checks passed
@namastex888
namastex888 deleted the fix/remove-empty-sessions branch March 30, 2026 11:09

@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 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.

Comment on lines +167 to +168
if (node.wsAgentState !== 'running') {
spawnAgent(node.label);

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.

medium

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment on lines +167 to +168
if (node.wsAgentState !== 'running') {
spawnAgent(node.label);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@coderabbitai

coderabbitai Bot commented Mar 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c9e8bfbe-f60d-45cd-b352-65bc09e8fdf7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-empty-sessions

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.

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