mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Revert tui code so it does not rely on in-process app server (#14899)
PR https://github.com/openai/codex/pull/14512 added an in-process app server and started to wire up the tui to use it. We were originally planning to modify the `tui` code in place, converting it to use the app server a bit at a time using a hybrid adapter. We've since decided to create an entirely new parallel `tui_app_server` implementation and do the conversion all at once but retain the existing `tui` while we work the bugs out of the new implementation. This PR undoes the changes to the `tui` made in the PR #14512 and restores the old initialization to its previous state. This allows us to modify the `tui_app_server` without the risk of regressing the old `tui` code. For example, we can start to remove support for all legacy core events, like the ones that PR https://github.com/openai/codex/pull/14892 needed to ignore. Testing: * I manually verified that the old `tui` starts and shuts down without a problem.
This commit is contained in:
committed by
GitHub
Unverified
parent
57f865c069
commit
d37dcca7e0
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
This module holds the temporary adapter layer between the TUI and the app
|
||||
server during the hybrid migration period.
|
||||
|
||||
For now, the TUI still owns its existing direct-core behavior, but startup
|
||||
allocates a local in-process app server and drains its event stream. Keeping
|
||||
the app-server-specific wiring here keeps that transitional logic out of the
|
||||
main `app.rs` orchestration path.
|
||||
|
||||
As more TUI flows move onto the app-server surface directly, this adapter
|
||||
should shrink and eventually disappear.
|
||||
*/
|
||||
|
||||
use super::App;
|
||||
use codex_app_server_client::InProcessAppServerClient;
|
||||
use codex_app_server_client::InProcessServerEvent;
|
||||
use codex_app_server_protocol::JSONRPCErrorError;
|
||||
|
||||
impl App {
|
||||
pub(super) async fn handle_app_server_event(
|
||||
&mut self,
|
||||
app_server_client: &InProcessAppServerClient,
|
||||
event: InProcessServerEvent,
|
||||
) {
|
||||
match event {
|
||||
InProcessServerEvent::Lagged { skipped } => {
|
||||
tracing::warn!(
|
||||
skipped,
|
||||
"app-server event consumer lagged; dropping ignored events"
|
||||
);
|
||||
}
|
||||
InProcessServerEvent::ServerNotification(_) => {}
|
||||
InProcessServerEvent::LegacyNotification(_) => {}
|
||||
InProcessServerEvent::ServerRequest(request) => {
|
||||
let request_id = request.id().clone();
|
||||
tracing::warn!(
|
||||
?request_id,
|
||||
"rejecting app-server request while TUI still uses direct core APIs"
|
||||
);
|
||||
if let Err(err) = self
|
||||
.reject_app_server_request(
|
||||
app_server_client,
|
||||
request_id,
|
||||
"TUI client does not yet handle this app-server server request".to_string(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
tracing::warn!("{err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn reject_app_server_request(
|
||||
&self,
|
||||
app_server_client: &InProcessAppServerClient,
|
||||
request_id: codex_app_server_protocol::RequestId,
|
||||
reason: String,
|
||||
) -> std::result::Result<(), String> {
|
||||
app_server_client
|
||||
.reject_server_request(
|
||||
request_id,
|
||||
JSONRPCErrorError {
|
||||
code: -32000,
|
||||
message: reason,
|
||||
data: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.map_err(|err| format!("failed to reject app-server request: {err}"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user