Skip to content

Start TUI on embedded app server#14512

Merged
etraut-openai merged 17 commits intomainfrom
etraut/tui-app-server-startup
Mar 13, 2026
Merged

Start TUI on embedded app server#14512
etraut-openai merged 17 commits intomainfrom
etraut/tui-app-server-startup

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Mar 12, 2026

This PR is part of the effort to move the TUI on top of the app server. In a previous PR, we introduced an in-process app server and moved exec on top of it.

For the TUI, we want to do the migration in stages. The app server doesn't currently expose all of the functionality required by the TUI, so we're going to need to support a hybrid approach as we make the transition.

This PR changes the TUI initialization to instantiate an in-process app server and access its AuthManager and ThreadManager rather than constructing its own copies. It also adds a placeholder TUI event handler that will eventually translate app server events into TUI events. App server notifications are accepted but ignored for now. It also adds proper shutdown of the app server when the TUI terminates.

@etraut-openai
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

codex/codex-rs/tui/src/app.rs

Lines 1755 to 1756 in db84242

if let Some(exit_info) = exit_info {
return Ok(exit_info);

P2 Badge Shut down embedded app-server before early returns

App::run can return here when the model-migration prompt exits, but the only embedded_app_server.client.shutdown() call is later (line ~2070). That leaves the in-process client worker/runtime detached for this path. In long-lived hosts/tests this is a resource leak and can interfere with subsequent runs.

ℹ️ 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".

@etraut-openai
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

app.handle_event(tui, event).await?

P1 Badge Ensure embedded app-server always shuts down before returning

App::run starts an embedded server but this ? can return early from the loop on handler errors, bypassing the shutdown call at the end of the function. That leaves the in-process worker/task running until runtime teardown. Use a guard/finally-style path so embedded_app_server.client.shutdown() runs on both success and error exits.

ℹ️ 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".

@etraut-openai
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

codex/codex-rs/tui/src/app.rs

Lines 1996 to 2002 in c13e55b

return Ok(AppExitInfo {
token_usage: app.token_usage(),
thread_id: app.chat_widget.thread_id(),
thread_name: app.chat_widget.thread_name(),
update_action: app.pending_update_action,
exit_reason,
});

P2 Badge Shut down embedded app server before early return

App::run returns from this update-notification exit path without calling embedded_app_server.client.shutdown(). InProcessAppServerClient has no Drop-based shutdown, so this leaves the in-process server worker/background tasks running until process exit. The shutdown call only exists in other exit paths, making this branch leak runtime resources.

ℹ️ 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".

@etraut-openai
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 6bb10d2559

ℹ️ 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".

@etraut-openai
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: f423a82226

ℹ️ 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".

@etraut-openai etraut-openai marked this pull request as ready for review March 13, 2026 06:03
}
}

pub fn clear_external_auth_refresher(&self) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ooc, why?

@fcoury
Copy link
Copy Markdown
Contributor

fcoury commented Mar 13, 2026

It seems like I can't formally approve it but I reviewed and only had the nitpick above, so LGTM.

@etraut-openai etraut-openai merged commit 9dba733 into main Mar 13, 2026
32 checks passed
@etraut-openai etraut-openai deleted the etraut/tui-app-server-startup branch March 13, 2026 18:04
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants