mirror of
https://github.com/openai/codex.git
synced 2026-11-22 23:00:42 +00:00
Add a gated Cloud backend to the TUI (#59828)
## What changed - Register an additional Cloud connection on supported macOS and Linux launches when `TuiMultiBackend` is enabled, using the selected ChatGPT account and local network policy. - Preserve backend settings and identify Cloud in connection controls and status. - Let Cloud supply the model when a thread opens, skip local skills requests and stale results, and allow resume without a local working-directory override. - Preserve Git metadata in Cloud thread snapshots and continue history hydration past empty filtered pages within the scan budget. - Report Cloud connection failures and require reopening Codex to reconnect. ## Testing Add regression coverage for Cloud model bootstrap, skipped skills requests, resume directory handling, history pagination through filtered pages, and Git metadata preservation. GitOrigin-RevId: 6717f0f5ad7708c5e9b5796d94711dd1eecc49bb
This commit is contained in:
committed by
copyberry
parent
a037e65ead
commit
7b8d67e456
@@ -73,7 +73,7 @@ async fn collaboration_catalog_is_optional_and_refetched_on_bootstrap() -> Resul
|
||||
let initial = session.bootstrap(&config).await?;
|
||||
assert_eq!(
|
||||
(initial.default_model, initial.collaboration_modes),
|
||||
("task-model".into(), vec![])
|
||||
(Some("task-model".into()), vec![])
|
||||
);
|
||||
let refreshed = session.bootstrap(&config).await?;
|
||||
assert_eq!(
|
||||
|
||||
@@ -372,6 +372,19 @@ impl AppServerSession {
|
||||
)
|
||||
.await?;
|
||||
if page.data.is_empty() {
|
||||
state.next_item_cursor = advancing_cursor(
|
||||
state.next_item_cursor.as_deref(),
|
||||
page.next_cursor,
|
||||
&mut state.seen_item_cursors,
|
||||
);
|
||||
if self.thread_params_mode() == super::ThreadParamsMode::Cloud
|
||||
&& state.next_item_cursor.is_some()
|
||||
{
|
||||
// Unknown native items may fill a page; preserve its continuation
|
||||
// and charge the requested page against the existing scan budget.
|
||||
scanned_items = scanned_items.saturating_add(limit as usize);
|
||||
continue;
|
||||
}
|
||||
state.next_item_cursor = None;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
//! Fetch picker models without blocking the event loop and keep new-thread defaults in sync.
|
||||
|
||||
use super::AppServerSession;
|
||||
use super::ThreadParamsMode;
|
||||
use super::model_preset_from_api_model;
|
||||
use crate::app_event::AppEvent;
|
||||
use crate::app_event_sender::AppEventSender;
|
||||
use codex_app_server_client::AppServerRequestHandle;
|
||||
use codex_app_server_client::TypedRequestError;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::ModelListParams;
|
||||
use codex_app_server_protocol::ModelListResponse;
|
||||
@@ -24,28 +27,41 @@ impl AppServerSession {
|
||||
}
|
||||
|
||||
pub(crate) fn fetch_models(&self, request_id: Uuid, app_event_tx: AppEventSender) {
|
||||
let request_handle = self.request_handle();
|
||||
let models = list(
|
||||
self.thread_params_mode,
|
||||
self.request_handle(),
|
||||
RequestId::String(format!("model-list-{request_id}")),
|
||||
);
|
||||
tokio::spawn(async move {
|
||||
let result = request_handle
|
||||
.request_typed::<ModelListResponse>(ClientRequest::ModelList {
|
||||
request_id: RequestId::String(format!("model-list-{request_id}")),
|
||||
params: ModelListParams {
|
||||
cursor: None,
|
||||
limit: None,
|
||||
include_hidden: Some(true),
|
||||
model_provider: None,
|
||||
},
|
||||
})
|
||||
.await
|
||||
.map(|response| {
|
||||
response
|
||||
.data
|
||||
.into_iter()
|
||||
.map(model_preset_from_api_model)
|
||||
.collect()
|
||||
})
|
||||
.map_err(|err| err.to_string());
|
||||
let result = models.await.map_err(|err| err.to_string());
|
||||
app_event_tx.send(AppEvent::ModelsLoaded { request_id, result });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn list(
|
||||
mode: ThreadParamsMode,
|
||||
request_handle: AppServerRequestHandle,
|
||||
request_id: RequestId,
|
||||
) -> Result<Vec<ModelPreset>, TypedRequestError> {
|
||||
if mode == ThreadParamsMode::Cloud {
|
||||
// The internal preview uses the model returned by Cloud when the thread opens.
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
let response: ModelListResponse = request_handle
|
||||
.request_typed(ClientRequest::ModelList {
|
||||
request_id,
|
||||
params: ModelListParams {
|
||||
cursor: None,
|
||||
limit: None,
|
||||
include_hidden: Some(true),
|
||||
model_provider: None,
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
Ok(response
|
||||
.data
|
||||
.into_iter()
|
||||
.map(model_preset_from_api_model)
|
||||
.collect())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user