diff --git a/codex-rs/app-server/src/request_processors/thread_processor.rs b/codex-rs/app-server/src/request_processors/thread_processor.rs index 036b5799..25e5465e 100644 --- a/codex-rs/app-server/src/request_processors/thread_processor.rs +++ b/codex-rs/app-server/src/request_processors/thread_processor.rs @@ -244,6 +244,8 @@ fn collect_resume_override_mismatches( mismatch_details } +/// aKode: only used when a daemon restart reopens live threads; a user resume keeps the current +/// config's provider, model and reasoning effort. fn merge_persisted_resume_metadata( request_overrides: &mut Option>, typesafe_overrides: &mut ConfigOverrides, @@ -4242,16 +4244,23 @@ impl ThreadRequestProcessor { } InitialHistory::New | InitialHistory::Cleared | InitialHistory::Forked(_) => None, }; + // aKode: a user resume takes provider, model and reasoning effort from the current + // config (or the request's explicit overrides), so switching provider in config (e.g. + // local server -> openrouter) also applies to resumed sessions. Only a daemon restart, + // which reopens live sessions transparently, keeps the values the thread was using. + let restore_saved_model = matches!(target, ThreadResumeTarget::DaemonRecovery(_)); let persisted_metadata = self .load_and_apply_persisted_resume_metadata( &thread_history, persisted_settings.as_ref(), &mut request_overrides, &mut typesafe_overrides, + restore_saved_model, ) .await; - let clear_reasoning_effort = !has_explicit_model_resume_override + let clear_reasoning_effort = restore_saved_model + && !has_explicit_model_resume_override && persisted_metadata .as_ref() .is_some_and(|metadata| metadata.reasoning_effort.is_none()); @@ -4290,7 +4299,9 @@ impl ThreadRequestProcessor { }) } _ => None, - }), + }) + // aKode: the saved provider is enforced only for daemon recovery. + .filter(|_| restore_saved_model), request_overrides, typesafe_overrides, history_cwd, @@ -4590,6 +4601,7 @@ impl ThreadRequestProcessor { persisted_settings: Option<&PersistedResumeSettings>, request_overrides: &mut Option>, typesafe_overrides: &mut ConfigOverrides, + restore_saved_model: bool, ) -> Option { let InitialHistory::Resumed(resumed_history) = thread_history else { return None; @@ -4617,7 +4629,13 @@ impl ThreadRequestProcessor { .await .ok() .flatten()?; - merge_persisted_resume_metadata(request_overrides, typesafe_overrides, &persisted_metadata); + if restore_saved_model { + merge_persisted_resume_metadata( + request_overrides, + typesafe_overrides, + &persisted_metadata, + ); + } Some(persisted_metadata) } diff --git a/codex-rs/app-server/tests/suite/v2/model_auto_review.rs b/codex-rs/app-server/tests/suite/v2/model_auto_review.rs index 9a96de15..675c4d2f 100644 --- a/codex-rs/app-server/tests/suite/v2/model_auto_review.rs +++ b/codex-rs/app-server/tests/suite/v2/model_auto_review.rs @@ -388,6 +388,8 @@ async fn thread_resume_and_fork_upgrade_legacy_protected_model_settings() -> Res .send_thread_resume_request(params!( ResumeParams, thread_id = thread_id.clone(), + // aKode: resume no longer restores the saved model, so ask for it explicitly. + model = Some(MODEL.to_string()), approval_policy = Some(Never), approvals_reviewer = Some(User), )) @@ -400,7 +402,11 @@ async fn thread_resume_and_fork_upgrade_legacy_protected_model_settings() -> Res Never, ); let id = server - .send_thread_resume_request(params!(ResumeParams, thread_id)) + .send_thread_resume_request(params!( + ResumeParams, + thread_id, + model = Some(MODEL.to_string()) + )) .await?; let resumed: ResumeResponse = timeout(TIMEOUT, server.read_response(id)).await??; assert_protected_with_policy( diff --git a/codex-rs/app-server/tests/suite/v2/thread_resume.rs b/codex-rs/app-server/tests/suite/v2/thread_resume.rs index b965d99f..d81f8c1e 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_resume.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_resume.rs @@ -840,7 +840,9 @@ async fn cold_resume_workspace_roots_honor_owned_snapshot_and_caller_overrides() let response_mock = responses::mount_sse_sequence(&server, vec![responses::sse_completed("done"); 3]).await; let codex_home = TempDir::new()?; + // aKode: resume uses the configured model, so configure the one the thread was saved with. MockResponsesConfig::new(&server.uri()) + .with_model("gpt-5.5") .with_sandbox_mode("workspace-write") .with_extra_config( r#"[sandbox_workspace_write] @@ -1668,8 +1670,10 @@ async fn thread_resume_preserves_acknowledged_model_effort_and_approvals_reviewe .. } = timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(resume_id)).await??; - assert_eq!(model, "gpt-5.2-codex"); - assert_eq!(reasoning_effort, Some(ReasoningEffort::Ultra)); + // aKode: model and reasoning effort come from the current config on resume, not from the + // values the thread last used. + assert_eq!(model, "gpt-5.4"); + assert_eq!(reasoning_effort, Some(ReasoningEffort::High)); assert_eq!(approvals_reviewer, ApprovalsReviewer::AutoReview); assert_eq!(thread.cwd.as_path(), live_cwd); assert_eq!(cwd.as_path(), live_cwd); @@ -6568,12 +6572,14 @@ fn create_saved_gateway_rollout(home: &Path) -> Result { ) } +// aKode: the provider a thread was saved with is not enforced on resume; the current config's +// provider serves it. Only an explicit provider override is still validated. #[test_case::test_case(false, false; "missing_definition_config_override")] #[test_case::test_case(false, true; "missing_definition_typed_override")] #[test_case::test_case(true, false; "policy_conflict_config_override")] #[test_case::test_case(true, true; "policy_conflict_typed_override")] #[tokio::test] -async fn thread_resume_returns_provider_error_even_with_provider_override( +async fn thread_resume_validates_only_explicit_provider_override( policy_conflict: bool, typed_override: bool, ) -> Result<()> { @@ -6610,67 +6616,13 @@ async fn thread_resume_returns_provider_error_even_with_provider_override( model_provider: "old_provider".into(), } }; - // Model and reasoning overrides must not discard the provider being validated. - for mut params in [ - ThreadResumeParams::default(), - ThreadResumeParams { - model: Some("gpt-5.1-codex".into()), - ..Default::default() - }, - ThreadResumeParams { - config: Some(std::collections::HashMap::from([( - "model".into(), - json!("gpt-5.1-codex"), - )])), - ..Default::default() - }, - ThreadResumeParams { - config: Some(std::collections::HashMap::from([( - "model_reasoning_effort".into(), - json!("high"), - )])), - ..Default::default() - }, - ] { - params.thread_id = thread_id.clone(); - let id = client.send_thread_resume_request(params).await?; - let error = client - .read_stream_until_error_message(RequestId::Integer(id)) - .await?; - assert_eq!( - error.error, - JSONRPCErrorError { - code: -32600, - message: expected.to_string(), - data: Some(serde_json::to_value(&expected)?), - } - ); - } - assert!( - server - .received_requests() - .await - .expect("mock server should record received requests") - .iter() - .all(|request| !request.url.path().ends_with("/responses")) - ); - // Failure leaves the history readable and does not create a live session with a new provider. - let id = client - .send_raw_request( - "thread/read", - Some(json!({"threadId": thread_id, "includeTurns": true})), - ) - .await?; - let read: codex_app_server_protocol::ThreadReadResponse = client.read_response(id).await?; - assert_eq!(read.thread.model_provider, "old_provider"); - // Provider overrides must not bypass admission for the saved provider. + // Asking for the saved provider explicitly is still checked. let id = client .send_thread_resume_request(ThreadResumeParams { - thread_id, - model: Some("gpt-5.1-codex".into()), - model_provider: typed_override.then(|| "mock_provider".into()), + thread_id: thread_id.clone(), + model_provider: typed_override.then(|| "old_provider".into()), config: (!typed_override).then(|| { - std::collections::HashMap::from([("model_provider".into(), json!("mock_provider"))]) + std::collections::HashMap::from([("model_provider".into(), json!("old_provider"))]) }), ..Default::default() }) @@ -6678,37 +6630,25 @@ async fn thread_resume_returns_provider_error_even_with_provider_override( let error = client .read_stream_until_error_message(RequestId::Integer(id)) .await?; - assert_eq!(error.error.data, Some(serde_json::to_value(expected)?)); + assert_eq!(error.error.data, Some(serde_json::to_value(&expected)?)); + + let id = client + .send_thread_resume_request(ThreadResumeParams { + thread_id, + ..Default::default() + }) + .await?; + let resumed: ThreadResumeResponse = client.read_response(id).await?; + assert_eq!(resumed.model_provider, "mock_provider"); Ok(()) } #[tokio::test] -async fn thread_resume_recovers_after_provider_configuration_is_restored() -> Result<()> { +async fn thread_resume_uses_current_config_provider_not_saved_one() -> Result<()> { + // aKode: a session created with provider A resumes on provider B once config points at B. let server = create_mock_responses_server_repeating_assistant("Done").await; let home = TempDir::new()?; mock_responses_config(&server.uri()).write(home.path())?; - let thread_id = create_saved_gateway_rollout(home.path())?; - let mut client = TestAppServer::builder() - .with_codex_home(home.path()) - .build_initialized() - .await?; - let params = ThreadResumeParams { - thread_id, - ..Default::default() - }; - let id = client.send_thread_resume_request(params.clone()).await?; - let error = client - .read_stream_until_error_message(RequestId::Integer(id)) - .await?; - assert_eq!( - error - .error - .data - .as_ref() - .and_then(|data| data["type"].as_str()), - Some("modelProviderNotConfigured") - ); - let config_path = home.path().join("config.toml"); let config = std::fs::read_to_string(&config_path)?; let server_uri = server.uri(); @@ -6718,14 +6658,19 @@ async fn thread_resume_recovers_after_provider_configuration_is_restored() -> Re "{config}\n[model_providers.old_provider]\nname = 'Original provider'\nbase_url = '{server_uri}/v1'\n" ), )?; + let thread_id = create_saved_gateway_rollout(home.path())?; + let mut client = TestAppServer::builder() + .with_codex_home(home.path()) + .build_initialized() + .await?; let id = client .send_thread_resume_request(ThreadResumeParams { - model: Some("gpt-5.2-codex".into()), - ..params + thread_id, + ..Default::default() }) .await?; let resumed: ThreadResumeResponse = client.read_response(id).await?; - assert_eq!(resumed.model_provider, "old_provider"); - assert_eq!(resumed.model, "gpt-5.2-codex"); + assert_eq!(resumed.model_provider, "mock_provider"); + assert_eq!(resumed.model, "gpt-5.4"); Ok(()) } diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__composer_hints__tests__composer_usage_notice.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__composer_hints__tests__composer_usage_notice.snap index d0c8e560..243d14e4 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__composer_hints__tests__composer_usage_notice.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__composer_hints__tests__composer_usage_notice.snap @@ -11,7 +11,7 @@ Conversation › Ask aKode to do anything - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s ? for shortcuts ⚠ 1 warning · f2 to view 80 columns, 12 rows, running=true, queued=false @@ -25,7 +25,7 @@ Conversation › draft stays - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message 32 columns, 10 rows, running=true, queued=false @@ -37,7 +37,7 @@ Conversation › draft stays - 127.0.0.1:9 · GPT-5.6-Sol · C… + ctx 0% · -- t/s tab to queue message 18 columns, 10 rows, running=true, queued=false @@ -49,7 +49,7 @@ Conversation › draft stays - 127.0.0.1:9 · G… + ctx 0% · -- t… tab to queue mes 80 columns, 18 rows, running=true, queued=true @@ -69,7 +69,7 @@ Conversation row 19 › draft stays second line - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message 80 columns, 11 rows, running=true, queued=true @@ -82,7 +82,7 @@ Conversation row 19 › draft stays second line - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message 80 columns, 6 rows, running=true, queued=false @@ -90,5 +90,5 @@ Conversation row 19 › draft stays - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__empty_state_animation_tests__fresh_thread_header.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__empty_state_animation_tests__fresh_thread_header.snap index 475aafa0..02324eb9 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__empty_state_animation_tests__fresh_thread_header.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__empty_state_animation_tests__fresh_thread_header.snap @@ -45,7 +45,7 @@ enabled: › Ask aKode to do anything - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s ? for shortcuts ⚠ 1 warning · f2 to view --- disabled: @@ -91,5 +91,5 @@ disabled: › Ask aKode to do anything - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s ? for shortcuts ⚠ 1 warning · f2 to view diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_copy_feedback_spacing.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_copy_feedback_spacing.snap index b2c42657..e6eb2a67 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_copy_feedback_spacing.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_copy_feedback_spacing.snap @@ -13,7 +13,7 @@ transcript row 39 › draft stays here - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message 18 columns, 14 rows @@ -29,7 +29,7 @@ transcript row 39 › draft stays here - 127.0.0.1:9 · G… + ctx 0% · -- t… tab to queue mes 6 columns, 18 rows @@ -49,7 +49,7 @@ row 39 her e - 127… + c… tab 80 columns, 6 rows @@ -57,5 +57,5 @@ row 39 › draft stays here - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_follow_control.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_follow_control.snap index a849d539..6a878850 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_follow_control.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_follow_control.snap @@ -12,5 +12,5 @@ transcript row 28 › draft stays here - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_follow_control_short_terminal.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_follow_control_short_terminal.snap index f384aeb9..e60aaa90 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_follow_control_short_terminal.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_follow_control_short_terminal.snap @@ -9,5 +9,5 @@ transcript row 26 › draft stays here - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_without_composer_hint.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_without_composer_hint.snap index ebea8084..2641ebe1 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_without_composer_hint.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__follow_tests__running_without_composer_hint.snap @@ -12,5 +12,5 @@ transcript row 39 › draft stays here - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s tab to queue message diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__input_tests__escape_returns_to_latest.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__input_tests__escape_returns_to_latest.snap index 3323b612..e2ba3f69 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__input_tests__escape_returns_to_latest.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__input_tests__escape_returns_to_latest.snap @@ -13,7 +13,7 @@ row 19 › draft preserved - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s New activity · esc latest after @@ -27,4 +27,4 @@ new output › draft preserved - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__input_tests__raw_paste_burst_render.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__input_tests__raw_paste_burst_render.snap index 0bc77c47..b591ae6a 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__input_tests__raw_paste_burst_render.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__input_tests__raw_paste_burst_render.snap @@ -25,7 +25,7 @@ Before paste › Ask aKode to do anything - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s ? for shortcuts After flush: @@ -51,4 +51,4 @@ After paste › [Pasted Content 2084 chars] - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__conversation_in_offset_rect.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__conversation_in_offset_rect.snap index f7351620..49794ab3 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__conversation_in_offset_rect.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__conversation_in_offset_rect.snap @@ -16,7 +16,7 @@ expression: normalize_snapshot_paths(screen) ····· ····· ·····› preserved draft ····· ····· ····· -····· 127.0.0.1:9 · gpt-test …····· +····· ctx 0% · -- t/s ····· ····· ····· ···································· ···································· diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_composer_right_click_copy.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_composer_right_click_copy.snap index d85cb96f..a8b58cda 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_composer_right_click_copy.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_composer_right_click_copy.snap @@ -72,4 +72,4 @@ hello world › hello world - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_footer_selection.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_footer_selection.snap index 86e1edc2..e86c3c40 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_footer_selection.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_footer_selection.snap @@ -24,5 +24,5 @@ expression: "normalize_snapshot_paths(buffer_text(crate::custom_terminal::test_s › draft stays here - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s ⚠ 1 warning · f2 to view diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_prompt_remote_images.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_prompt_remote_images.snap index b487ca27..2fa8eec5 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_prompt_remote_images.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_prompt_remote_images.snap @@ -13,7 +13,7 @@ History stays visible › Edit this prompt - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s Up @@ -27,7 +27,7 @@ History stays visible › Edit this prompt - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s Up @@ -41,7 +41,7 @@ History stays visible › Edit this prompt - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s Delete @@ -55,7 +55,7 @@ History stays visible › Edit this prompt - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s Down @@ -69,4 +69,4 @@ History stays visible › Edit this prompt - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_prompt_wheel.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_prompt_wheel.snap index fd53065b..51de0a59 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_prompt_wheel.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__fullscreen_prompt_wheel.snap @@ -25,7 +25,7 @@ History 40 Prompt 34 界 Prompt 35 界 - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s Wheel up @@ -51,7 +51,7 @@ History 40 Prompt 25 界 Prompt 26 界 ↓ - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s Edit at caret @@ -77,7 +77,7 @@ History 40 Prompt 34 界 Prompt 35 界 - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s Paste at caret @@ -103,7 +103,7 @@ History 40 Edited 34 界 Edited 35 界 pasted here - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-… · …/project ctx 0% · -- t/s Short screen @@ -115,4 +115,4 @@ History 40 Edited 34 界 Edited 35 界 pasted here - 127.0.0.1:9 · GPT-5.6-Sol · Context 0… + ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__owned_transcript_composer_gap.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__owned_transcript_composer_gap.snap index a96b1203..803ab093 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__owned_transcript_composer_gap.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__owned_transcript_composer_gap.snap @@ -13,7 +13,7 @@ Transcript row 40 › draft - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s Reading @@ -27,7 +27,7 @@ Transcript row 35 › draft - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s esc latest Resized multiline composer @@ -41,14 +41,14 @@ Transcript row 33 second line third line - 127.0.0.1:9 · gpt-test · Context 0% u… + ctx 0% · -- t/s esc latest Tiny terminal › draft - 127.0.0.1:9 · gpt-test · Context 0% u… + ctx 0% · -- t/s esc latest Detailed @@ -62,4 +62,4 @@ Detailed › preserved draft - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__prompt_navigation.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__prompt_navigation.snap index e3e7daab..4bad1011 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__prompt_navigation.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__prompt_navigation.snap @@ -16,5 +16,5 @@ expression: "normalize_snapshot_paths(buffer_text(crate::custom_terminal::test_s › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s Browsing · ↑↓/jk scroll · ←→/hl prompts · ⌃t details · ↵ rewind · esc back diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__recap_tail_spacing.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__recap_tail_spacing.snap index ede92346..835b7e76 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__recap_tail_spacing.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__recap_tail_spacing.snap @@ -11,7 +11,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 80x10, Message after recap @@ -23,7 +23,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 80x10, Live message after recap @@ -35,7 +35,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 80x12, Recap at tail @@ -49,7 +49,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 80x12, Message after recap @@ -63,7 +63,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 80x12, Live message after recap @@ -77,7 +77,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 32x12, Recap at tail @@ -91,7 +91,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Cont… + ctx 0% · -- t/s ? for shortcuts 32x12, Message after recap @@ -105,7 +105,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Cont… + ctx 0% · -- t/s ? for shortcuts 32x12, Live message after recap @@ -119,7 +119,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Cont… + ctx 0% · -- t/s ? for shortcuts 80x7, Recap at tail @@ -128,7 +128,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 80x7, Message after recap @@ -137,7 +137,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 80x7, Live message after recap @@ -146,7 +146,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts 32x6, Recap at tail @@ -154,7 +154,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Cont… + ctx 0% · -- t/s ? for shortcuts 32x6, Message after recap @@ -162,7 +162,7 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Cont… + ctx 0% · -- t/s ? for shortcuts 32x6, Live message after recap @@ -170,5 +170,5 @@ History 20 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Cont… + ctx 0% · -- t/s ? for shortcuts diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__allocated_stream_table.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__allocated_stream_table.snap index 8ccc8e70..289e744f 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__allocated_stream_table.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__tests__allocated_stream_table.snap @@ -24,5 +24,5 @@ history-39 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used … + ctx 0% · -- t/s ? for shortcuts diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__turn_tip_placements.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__turn_tip_placements.snap index e84f51c4..b19b2784 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__turn_tip_placements.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__turn_tip_placements.snap @@ -13,7 +13,7 @@ Response row 0 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts working=true, response rows=1, 80x6 @@ -21,7 +21,7 @@ working=true, response rows=1, 80x6 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts working=false, response rows=1, 80x12 @@ -35,7 +35,7 @@ working=false, response rows=1, 80x12 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts working=false, response rows=1, 80x24 @@ -61,7 +61,7 @@ Response row 0 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts Completion tip selected, 80x24 @@ -87,7 +87,7 @@ Response row 0 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts working=false, response rows=30, 80x12 @@ -101,7 +101,7 @@ working=false, response rows=30, 80x12 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts working=false, response rows=1, 80x9 @@ -112,7 +112,7 @@ working=false, response rows=1, 80x9 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts working=false, response rows=1, 80x10 @@ -124,7 +124,7 @@ working=false, response rows=1, 80x10 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts working=false, response rows=1, 80x11 @@ -137,7 +137,7 @@ working=false, response rows=1, 80x11 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts working=false, response rows=1, 12x12 @@ -151,7 +151,7 @@ working=false, response rows=1, 12x12 › Ask aKode - 127.0.0.1… + ctx 0% … ? for shor working=false, response rows=1, 80x4 diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__working_tip_mouse_down.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__working_tip_mouse_down.snap index 1d991a78..c1d272da 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__working_tip_mouse_down.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__working_tip_mouse_down.snap @@ -24,5 +24,5 @@ Response row 9 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__working_tip_selected.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__working_tip_selected.snap index 833de3f3..0f40b875 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__working_tip_selected.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__turn_tips__tests__working_tip_selected.snap @@ -24,5 +24,5 @@ Response row 9 › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ? for shortcuts diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__warnings_tests__warnings_partial_dismissal.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__warnings_tests__warnings_partial_dismissal.snap index d253ff67..9e228843 100644 --- a/codex-rs/tui/src/app/snapshots/codex_tui__app__warnings_tests__warnings_partial_dismissal.snap +++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__warnings_tests__warnings_partial_dismissal.snap @@ -24,5 +24,5 @@ Earlier transcript row 29 › draft - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s esc latest ⚠ 1 warning · f2 to view diff --git a/codex-rs/tui/src/app/tests.rs b/codex-rs/tui/src/app/tests.rs index 70710ded..698078dc 100644 --- a/codex-rs/tui/src/app/tests.rs +++ b/codex-rs/tui/src/app/tests.rs @@ -2204,7 +2204,7 @@ async fn token_usage_update_refreshes_status_line_with_runtime_context_window() ))); assert!(matches!( app.chat_widget.status_line_content(), - Some(FooterContent::HyperlinkLine(_)) + Some(FooterContent::StatusBar(_)) )); let rendered = render_bottom_popup(&app.chat_widget, /*width*/ 60); assert!( @@ -5417,7 +5417,7 @@ async fn open_agent_picker_prompts_when_subagents_disabled() -> Result<()> { Enable subagents? › As Subagents are disabled in this TUI session. - 12 + 12 /s › 1. Yes, enable Save on the server for new threads without changing this thread 2. Not now Keep subagents disabled diff --git a/codex-rs/tui/src/app/tests/agents_navigation_tests.rs b/codex-rs/tui/src/app/tests/agents_navigation_tests.rs index 43eedaef..d3ae3652 100644 --- a/codex-rs/tui/src/app/tests/agents_navigation_tests.rs +++ b/codex-rs/tui/src/app/tests/agents_navigation_tests.rs @@ -30,7 +30,7 @@ async fn agents_navigation_opens_the_command_center_on_every_target() -> Result< let composer = render_bottom_popup(&app.chat_widget, /*width*/ 96); let footer = composer.lines().last().expect("composer footer").trim(); insta::allow_duplicates! { - insta::assert_snapshot!(normalize_snapshot_paths(footer), @"127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project · ← for agents"); + insta::assert_snapshot!(normalize_snapshot_paths(footer), @"127.0.0.1:9 · GPT-5.6-Sol · /tmp/project · ← for agents ctx 0% · -- t/s"); } app.handle_tui_event( &mut tui, diff --git a/codex-rs/tui/src/app/tests/local_command_scroll_tests.rs b/codex-rs/tui/src/app/tests/local_command_scroll_tests.rs index 06bc8773..5ff6dbef 100644 --- a/codex-rs/tui/src/app/tests/local_command_scroll_tests.rs +++ b/codex-rs/tui/src/app/tests/local_command_scroll_tests.rs @@ -87,8 +87,8 @@ async fn settings_pickers_preserve_the_reading_anchor_through_open_and_close() - app.handle_event(&mut tui, &mut server, event).await?; } if command == "/theme" { - // `/theme` opens the interface palettes; Enter keeps the automatic (dark) one. - assert_eq!(selected_theme, Some("dark".to_string())); + // `/theme` opens the interface palettes; Enter keeps the automatic one. + assert_eq!(selected_theme, Some("auto".to_string())); } assert!(!app.chat_widget.has_active_view(), "{command}"); assert!(!app.transcript_view.is_following(), "{command} closed"); diff --git a/codex-rs/tui/src/app/tests/new_session_tests.rs b/codex-rs/tui/src/app/tests/new_session_tests.rs index 7691a370..72eabafc 100644 --- a/codex-rs/tui/src/app/tests/new_session_tests.rs +++ b/codex-rs/tui/src/app/tests/new_session_tests.rs @@ -872,7 +872,7 @@ async fn replacement_preserves_remote_launch_paths_and_older_servers() -> Result } #[tokio::test] -async fn provider_continuation_starts_current_provider_and_drafts_saved_reference() -> Result<()> { +async fn resume_with_unconfigured_saved_provider_reopens_on_current_provider() -> Result<()> { use crate::app_server_session::ThreadParamsMode; for (mode, capabilities) in [ (ThreadParamsMode::Embedded, HistoryCapabilities::Current), @@ -934,106 +934,12 @@ async fn provider_continuation_starts_current_provider_and_drafts_saved_referenc }; app.resume_target_session(&mut tui, &mut server, target) .await?; - assert!(app.chat_widget.has_provider_error()); - let path = app.chat_widget.rollout_path().expect("saved history path"); - let original_history = std::fs::read(&path)?; + // aKode: the saved provider is no longer enforced on resume, so the thread reopens on the + // current provider and there is no provider error to continue from. + assert!(!app.chat_widget.has_provider_error()); + assert_eq!(app.chat_widget.thread_id(), Some(source_id)); + assert!(recorded_params(&requests, "thread/start").is_empty()); while events.try_recv().is_ok() {} - app.handle_tui_event( - &mut tui, - &mut server, - TuiEvent::Key(KeyCode::Char('c').into()), - ) - .await?; - let action = std::iter::from_fn(|| events.try_recv().ok()) - .find(|event| matches!(event, AppEvent::ContinueProviderChat { .. })) - .expect("c starts a continuation"); - Box::pin(app.handle_event(&mut tui, &mut server, action)).await?; - if capabilities == HistoryCapabilities::ThreadStartFails { - assert_eq!(app.chat_widget.thread_id(), Some(source_id)); - assert!(app.chat_widget.has_provider_error()); - } else { - let new_id = app.chat_widget.thread_id().expect("new thread"); - assert_ne!(new_id, source_id); - assert!(!app.chat_widget.has_provider_error()); - assert_eq!(app.chat_widget.current_model(), "current-model"); - assert_eq!( - app.primary_session_configured - .as_ref() - .unwrap() - .model_provider_id, - crate::test_support::TEST_MODEL_PROVIDER_ID - ); - let mut submissions = Vec::new(); - while let Ok(event) = events.try_recv() { - match event { - AppEvent::SubmitThreadOp { - thread_id, - op: Op::UserTurn { items, .. }, - } => { - assert_eq!(thread_id, new_id); - submissions.push(items); - } - AppEvent::CodexOp(Op::UserTurn { items, .. }) => submissions.push(items), - event => { - Box::pin(app.handle_event(&mut tui, &mut server, event)).await?; - } - } - } - assert!(submissions.is_empty()); - let expected_draft = format!( - "Read “Launch readiness” and let’s continue where we left off.\n\nSaved conversation: {}", - path.display() - ); - assert_eq!(app.chat_widget.composer_text_with_pending(), expected_draft); - let composer_lines = render_bottom_popup(&app.chat_widget, /*width*/ 80) - .lines() - .take(2) - .collect::>() - .join("\n"); - insta::assert_snapshot!("provider_continuation_draft", composer_lines); - // A repeated queued key cannot create a second chat or send into the original. - Box::pin(app.handle_event( - &mut tui, - &mut server, - AppEvent::ContinueProviderChat { - thread_id: source_id, - }, - )) - .await?; - assert_eq!(app.chat_widget.thread_id(), Some(new_id)); - assert_eq!(app.chat_widget.composer_text_with_pending(), expected_draft); - - let edited_draft = format!("{expected_draft}\n\nFocus on the remaining launch checks."); - app.chat_widget.apply_external_edit(edited_draft.clone()); - app.handle_tui_event(&mut tui, &mut server, TuiEvent::Key(KeyCode::Enter.into())) - .await?; - while let Ok(event) = events.try_recv() { - match event { - AppEvent::SubmitThreadOp { - thread_id, - op: Op::UserTurn { items, .. }, - } => { - assert_eq!(thread_id, new_id); - submissions.push(items); - } - AppEvent::CodexOp(Op::UserTurn { items, .. }) => submissions.push(items), - event => { - Box::pin(app.handle_event(&mut tui, &mut server, event)).await?; - } - } - } - assert_eq!( - submissions, - vec![vec![codex_app_server_protocol::UserInput::Text { - text: edited_draft, - text_elements: Vec::new(), - }]] - ); - assert_eq!(app.chat_widget.composer_text_with_pending(), ""); - } - assert_eq!(recorded_params(&requests, "thread/start").len(), 1); - assert!(recorded_params(&requests, "turn/start").is_empty()); - assert_eq!(std::fs::read(&path)?, original_history); tui.set_owned_screen(/*owned*/ false)?; server.shutdown().await?; proxy.await??; diff --git a/codex-rs/tui/src/app/tests/session_lifecycle_requests.rs b/codex-rs/tui/src/app/tests/session_lifecycle_requests.rs index a6bd4ac2..47f727b0 100644 --- a/codex-rs/tui/src/app/tests/session_lifecycle_requests.rs +++ b/codex-rs/tui/src/app/tests/session_lifecycle_requests.rs @@ -5981,7 +5981,7 @@ async fn command_center_read_only_open_requests_and_failure_preservation() -> Re mod backend_ownership_tests; #[tokio::test] -async fn provider_error_preserves_partial_history_notice() -> Result<()> { +async fn unconfigured_saved_provider_resumes_with_partial_history() -> Result<()> { for reopen_via_overview in [false, true] { let (mut app, _home) = Box::pin(make_history_test_app()).await?; std::fs::write( @@ -6006,7 +6006,7 @@ async fn provider_error_preserves_partial_history_notice() -> Result<()> { ThreadHistoryMode::Paginated, "Saved provider chat", )?; - let (mut server, requests, proxy) = start_recording_app_server_with_history( + let (mut server, _requests, proxy) = start_recording_app_server_with_history( &app.config, HistoryCapabilities::ItemsListFails, /*blocked_thread_list*/ None, @@ -6030,24 +6030,9 @@ async fn provider_error_preserves_partial_history_notice() -> Result<()> { }; Box::pin(app.resume_target_session(&mut tui, &mut server, target)).await?; } - assert!(app.chat_widget.has_provider_error()); - let notice = std::iter::from_fn(|| events.try_recv().ok()) - .filter_map(|event| match event { - AppEvent::InsertHistoryCell(cell) => { - Some(lines_to_single_string(&cell.display_lines(/*width*/ 200))) - } - _ => None, - }) - .find(|message| message.contains("Showing up to 100 recent prompts")) - .expect("provider error should preserve the partial-history notice"); - insta::allow_duplicates! { - insta::assert_snapshot!(notice, @"• Showing up to 100 recent prompts and final replies. Intermediate messages and tool activity are unavailable."); - } - assert!( - recorded_params(&requests, "thread/turns/list") - .iter() - .any(|params| params["itemsView"] == "summary") - ); + // aKode: the thread resumes on the current provider, so no provider-error notice is shown. + assert!(!app.chat_widget.has_provider_error()); + while events.try_recv().is_ok() {} server.shutdown().await?; proxy.await??; } diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__active_reconnect__unavailable_conversation.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__active_reconnect__unavailable_conversation.snap index 61838246..4a69d8a9 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__active_reconnect__unavailable_conversation.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__active_reconnect__unavailable_conversation.snap @@ -5,4 +5,4 @@ expression: "format!(\"{history}\\n{}\",\nrender_bottom_popup(&app.chat_widget,\ • This conversation is unavailable. Its cached transcript and draft remain here; input is paused. Open the agent picker or return to the parent to continue. › unavailable draft - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__background_exit_tests__embedded_exit_running_sessions.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__background_exit_tests__embedded_exit_running_sessions.snap index cb365673..0c85ba79 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__background_exit_tests__embedded_exit_running_sessions.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__background_exit_tests__embedded_exit_running_sessions.snap @@ -5,7 +5,7 @@ expression: "render_bottom_popup(&app.chat_widget, 90)" Quit and stop running sessions? › Ask aKo Quitting this TUI will stop its running sessions. - 127.0.0 + 127.0.0 -- t/s › 1. Stay in aKode 2. Stop sessions and quit diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__background_task_defaults_tests__command_center_new_draft_handoff.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__background_task_defaults_tests__command_center_new_draft_handoff.snap index 457395ca..afe13138 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__background_task_defaults_tests__command_center_new_draft_handoff.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__background_task_defaults_tests__command_center_new_draft_handoff.snap @@ -14,7 +14,7 @@ attached: › draft during startup - 127.0.0.1:9 · GPT-6.1-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-6.1-Sol · /tmp/project ctx 0% · -- t/s owned=true startup: @@ -27,4 +27,4 @@ attached: › draft during startup - 127.0.0.1:9 · GPT-6.1-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-6.1-Sol · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__buffered_replay__misalignment_replayed_input.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__buffered_replay__misalignment_replayed_input.snap index 08129a24..b07cfedf 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__buffered_replay__misalignment_replayed_input.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__buffered_replay__misalignment_replayed_input.snap @@ -8,4 +8,4 @@ expression: "normalize_snapshot_paths(render_bottom_popup(&app.chat_widget, 80)) › keep draft - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__buffered_replay__steers_after_returning_to_a_running_turn.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__buffered_replay__steers_after_returning_to_a_running_turn.snap index a628cb29..5ccf422c 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__buffered_replay__steers_after_returning_to_a_running_turn.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__buffered_replay__steers_after_returning_to_a_running_turn.snap @@ -15,4 +15,4 @@ expression: "normalize_snapshot_paths(render_bottom_popup(&app.chat_widget, 80)) › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__disconnect__rejected_startup_reconnected.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__disconnect__rejected_startup_reconnected.snap index c61a58ce..f36d4537 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__disconnect__rejected_startup_reconnected.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__disconnect__rejected_startup_reconnected.snap @@ -4,4 +4,4 @@ expression: "normalize_snapshot_paths(render_bottom_popup(&app.chat_widget, 80)) --- › startup draft - 127.0.0.1:9 · gpt-retry · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-retry · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__marketplace_upgrade_tests__marketplace_upgrade_warning.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__marketplace_upgrade_tests__marketplace_upgrade_warning.snap index e0a66a59..29c16fb1 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__marketplace_upgrade_tests__marketplace_upgrade_warning.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__marketplace_upgrade_tests__marketplace_upgrade_warning.snap @@ -17,7 +17,7 @@ Warning notice: › Ask aKode to do anything - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s ? for shortcuts ⚠ 2 warnings · f2 to view First warning details: diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__navigation_reconnect__reconnected_unavailable_conversation.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__navigation_reconnect__reconnected_unavailable_conversation.snap index 3d8b8a93..727369a9 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__navigation_reconnect__reconnected_unavailable_conversation.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__navigation_reconnect__reconnected_unavailable_conversation.snap @@ -8,4 +8,4 @@ Cached previous conversation • The rename target disappeared. Unsubmitted title: Keep this task draft! › latest draft - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__realtime_requests__voice_partial_completed_after_thread_switch.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__realtime_requests__voice_partial_completed_after_thread_switch.snap index e584ff8f..2e27d9fc 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__realtime_requests__voice_partial_completed_after_thread_switch.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__realtime_requests__voice_partial_completed_after_thread_switch.snap @@ -5,14 +5,14 @@ expression: "normalize_voice_snapshot_directory(&format!(\"Other task:\\n{other_ Other task: › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s Restored owner: voice ● listening f9 mute /voice stop mic ▁▁▁▁▁▁ codex ▁▁▁▁▁▁ › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ▄▄████▄▄ aKode v0.1.0 ██▀▀██▀▀██ gpt-test · mock diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__session_lifecycle_requests__cloud_composer_receipts.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__session_lifecycle_requests__cloud_composer_receipts.snap index db8d60e9..56955e25 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__session_lifecycle_requests__cloud_composer_receipts.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__session_lifecycle_requests__cloud_composer_receipts.snap @@ -12,14 +12,14 @@ expression: "rendered_receipts.join(\"\\n\\n\")" › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ── Steered ── ■ Conversation interrupted - use /feedback if something went wrong ■ Conversation interrupted - use /feedback if something went wrong › follow up - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ── Unconfirmed ── ■ Cloud submission could not be confirmed: cloud/submitUserMessage transport error: cloud backend dropped its response @@ -30,7 +30,7 @@ expression: "rendered_receipts.join(\"\\n\\n\")" › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s ── Rejected ── ■ reply stream closed before submission @@ -49,4 +49,4 @@ expression: "rendered_receipts.join(\"\\n\\n\")" › Ask aKode to do anything - 127.0.0.1:9 · gpt-test · Context 0% used · /tmp/project + 127.0.0.1:9 · gpt-test · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__session_lifecycle_requests__new_session_tests__widget_replacement_preserves_mention_usage_with_history_disabled.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__session_lifecycle_requests__new_session_tests__widget_replacement_preserves_mention_usage_with_history_disabled.snap index 06d507dc..be192c34 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__session_lifecycle_requests__new_session_tests__widget_replacement_preserves_mention_usage_with_history_disabled.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__session_lifecycle_requests__new_session_tests__widget_replacement_preserves_mention_usage_with_history_disabled.snap @@ -15,4 +15,4 @@ expression: "normalize_snapshot_paths(render_bottom_popup(&app.chat_widget, 80)) › $stat - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__startup_frame_tests__startup_tip_in_transcript.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__startup_frame_tests__startup_tip_in_transcript.snap index 7f4ae8c4..743d3eb9 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__startup_frame_tests__startup_tip_in_transcript.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__startup_frame_tests__startup_tip_in_transcript.snap @@ -21,7 +21,7 @@ expression: "normalize_snapshot_paths(normalize_agent_center_snapshot(snapshots. › Ask aKode to do anything - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s ? for shortcuts 32 columns @@ -43,5 +43,5 @@ expression: "normalize_snapshot_paths(normalize_agent_center_snapshot(snapshots. › Ask aKode to do anything - 127.0.0.1:9 · GPT-5.6-Sol · C… + ctx 0% · -- t/s ? for shortcuts diff --git a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__transcript_composer__transcript_close_restores_inline_draft.snap b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__transcript_composer__transcript_close_restores_inline_draft.snap index d13db80d..cc5800e3 100644 --- a/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__transcript_composer__transcript_close_restores_inline_draft.snap +++ b/codex-rs/tui/src/app/tests/snapshots/codex_tui__app__tests__transcript_composer__transcript_close_restores_inline_draft.snap @@ -6,4 +6,4 @@ expression: "buffer_text(crate::custom_terminal::test_support::last_rendered_buf › EDGE-DRAFT-MUST-SURVIVE - 127.0.0.1:9 · GPT-5.6-Sol · Context 0% used · /tmp/project + 127.0.0.1:9 · GPT-5.6-Sol · /tmp/project ctx 0% · -- t/s diff --git a/codex-rs/tui/src/app/tests/startup.rs b/codex-rs/tui/src/app/tests/startup.rs index c30898b5..9b60264f 100644 --- a/codex-rs/tui/src/app/tests/startup.rs +++ b/codex-rs/tui/src/app/tests/startup.rs @@ -2110,7 +2110,9 @@ async fn check_provider_resume_retries(reopen_via: ProviderResumeRoute) -> Resul history_mode: None, }; Box::pin(app.resume_target_session(&mut tui, &mut server, target.clone())).await?; - assert!(app.chat_widget.has_provider_error()); + // aKode: a thread saved with a provider that is no longer configured resumes on the current + // provider instead of failing with a provider error. + assert!(!app.chat_widget.has_provider_error()); assert_eq!(app.chat_widget.thread_id(), Some(thread_id)); let turns = app.thread_event_channels[&thread_id] .store @@ -2119,7 +2121,6 @@ async fn check_provider_resume_retries(reopen_via: ProviderResumeRoute) -> Resul .snapshot() .turns; assert!(serde_json::to_string(&turns)?.contains("Saved provider history")); - assert!(!app.ignore_same_thread_resume(&target)); app.chat_widget .apply_external_edit("Preserved draft".into()); for provider_configured in [false, true] { @@ -2138,9 +2139,10 @@ async fn check_provider_resume_retries(reopen_via: ProviderResumeRoute) -> Resul Box::pin(app.select_agents_overview_thread(&mut tui, &mut server, other_id)).await?; assert_eq!(app.chat_widget.thread_id(), Some(other_id)); assert!( - app.agents_overview.input_states[&thread_id] - .provider_error - .is_some() + app.agents_overview + .input_states + .get(&thread_id) + .is_none_or(|state| state.provider_error.is_none()) ); } let saved_definition = if provider_configured { definition } else { "" }; @@ -2169,12 +2171,8 @@ async fn check_provider_resume_retries(reopen_via: ProviderResumeRoute) -> Resul } } let input = app.chat_widget.capture_thread_input_state().unwrap(); - let expected_error = (!provider_configured).then(|| { - codex_app_server_protocol::ModelProviderError::ModelProviderNotConfigured { - model_provider: "missing_provider".into(), - } - }); - assert_eq!(input.provider_error, expected_error); + // aKode: whether or not the saved provider is configured, resume never reports it. + assert_eq!(input.provider_error, None); assert_eq!(app.chat_widget.thread_id(), Some(thread_id)); assert_eq!( app.chat_widget.composer_text_with_pending(), diff --git a/codex-rs/tui/src/app/tests/startup_defaults_tests.rs b/codex-rs/tui/src/app/tests/startup_defaults_tests.rs index 4b83c987..15bef0dd 100644 --- a/codex-rs/tui/src/app/tests/startup_defaults_tests.rs +++ b/codex-rs/tui/src/app/tests/startup_defaults_tests.rs @@ -749,7 +749,8 @@ async fn fresh_startup_reads_destination_and_cleared_model_uses_catalog() -> Res ], /*use_theme_colors*/ false, ); - let rendered = render_bottom_popup(&app.chat_widget, /*width*/ 80) + // Wide enough that a long temp path is never shortened by the status bar. + let rendered = render_bottom_popup(&app.chat_widget, /*width*/ 160) .replace(&destination.path().display().to_string(), ""); insta::assert_snapshot!(rendered, @r" › Ask aKode to do anything diff --git a/codex-rs/tui/src/app_server_session/provider_selection_tests.rs b/codex-rs/tui/src/app_server_session/provider_selection_tests.rs index 359251d9..09accd79 100644 --- a/codex-rs/tui/src/app_server_session/provider_selection_tests.rs +++ b/codex-rs/tui/src/app_server_session/provider_selection_tests.rs @@ -272,7 +272,8 @@ async fn resume_discovers_and_reopens_the_saved_gateway() -> Result<()> { ResumeModelSettings::RestoreFromThread, ) .await?; - assert_eq!(resumed.session.model_provider_id, "server-provider"); + // aKode: resume serves the thread with the current provider, not the saved one. + assert_eq!(resumed.session.model_provider_id, "client-provider"); assert_eq!( server .start_thread(&config) diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index a82f103c..09ecb857 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -901,9 +901,11 @@ impl ChatComposer { self.effort_ignition = Some(EffortIgnition::new(tier, style)); self.effort_animation_style = Some(style); if self.footer.status_line_enabled - && let Some(FooterContent::HyperlinkLine(previous)) = - passive_footer_status_line(&self.footer_props()) + && let Some( + previous @ (FooterContent::HyperlinkLine(_) | FooterContent::StatusBar(_)), + ) = passive_footer_status_line(&self.footer_props()) { + let previous = previous.into_hyperlink_line(); self.effort_status_line_transition = Some(EffortStatusLineTransition::new(tier, previous)); } diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/status_surface.rs b/codex-rs/tui/src/bottom_pane/chat_composer/status_surface.rs index e735f0fa..79d44b18 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer/status_surface.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer/status_surface.rs @@ -185,14 +185,21 @@ impl ChatComposer { } let line = passive_footer_status_line(&props); let left_width = line.as_ref().map_or(/*default*/ 0, FooterContent::width); - let (right, width) = self.status_line_layout(area, options, left_width); + let (right, mut width) = self.status_line_layout(area, options, left_width); + if right.is_none() && matches!(line, Some(FooterContent::StatusBar(_))) { + // Mirror the left indent so right-aligned metrics end where the composer text does. + width = width.saturating_sub(FOOTER_INDENT_COLS as u16); + } let transition = self .effort_status_line_transition .as_ref() .filter(|transition| !transition.is_finished()); let content = if let Some(transition) = transition { transition - .render_line(line.map(FooterContent::into_hyperlink_line), width) + .render_line( + line.map(|content| content.into_hyperlink_line_for_width(width)), + width, + ) .map(FooterContent::HyperlinkLine) } else { line diff --git a/codex-rs/tui/src/bottom_pane/footer.rs b/codex-rs/tui/src/bottom_pane/footer.rs index 97183042..b56818b0 100644 --- a/codex-rs/tui/src/bottom_pane/footer.rs +++ b/codex-rs/tui/src/bottom_pane/footer.rs @@ -830,6 +830,10 @@ pub(crate) fn passive_footer_status_line(props: &FooterProps) -> Option HyperlinkLine::from(line.clone()), Some(FooterContent::HyperlinkLine(line)) => line.clone(), + Some(FooterContent::StatusBar(bar)) => { + let suffix = passive_footer_suffix(props, /*has_status*/ true); + return Some(FooterContent::StatusBar(bar.clone().with_suffix(suffix))); + } Some(content @ FooterContent::Extension { .. }) => return Some(content.clone()), None => HyperlinkLine::default(), }; diff --git a/codex-rs/tui/src/bottom_pane/footer/footer_content.rs b/codex-rs/tui/src/bottom_pane/footer/footer_content.rs index d05dc651..c9a52784 100644 --- a/codex-rs/tui/src/bottom_pane/footer/footer_content.rs +++ b/codex-rs/tui/src/bottom_pane/footer/footer_content.rs @@ -7,6 +7,7 @@ use ratatui::text::Line; use ratatui::widgets::Widget; use std::sync::Arc; +use crate::bottom_pane::status_bar::StatusBar; use crate::line_truncation::truncate_line_with_ellipsis_if_overflow; use crate::render::highlight::with_syntax_theme; use crate::terminal_hyperlinks::HyperlinkLine; @@ -18,6 +19,8 @@ use crate::ui_tree::UiTree; pub(crate) enum FooterContent { Line(Line<'static>), HyperlinkLine(HyperlinkLine), + /// Left group plus right-aligned metrics, laid out for the width it is rendered at. + StatusBar(StatusBar), Extension { content: Arc }, } @@ -35,6 +38,7 @@ impl FooterContent { let width = match self { Self::Line(line) => line.width(), Self::HyperlinkLine(line) => line.width(), + Self::StatusBar(bar) => bar.natural_width(), Self::Extension { content } => return content.measure_natural().width, }; u16::try_from(width).unwrap_or(u16::MAX) @@ -47,6 +51,13 @@ impl FooterContent { Self::Extension { content } => { with_syntax_theme(|theme| content.render(area, theme, buf)); } + Self::StatusBar(bar) => { + let area = Rect { + height: area.height.min(1), + ..area + }; + bar.layout(usize::from(area.width)).render_fitted(area, buf); + } Self::HyperlinkLine(mut line) => { let area = Rect { height: area.height.min(1), @@ -67,11 +78,26 @@ impl FooterContent { match self { Self::Line(line) => line.into(), Self::HyperlinkLine(line) => line, + Self::StatusBar(bar) => bar.natural_line(), Self::Extension { content } => { with_syntax_theme(|theme| content.render_line(u16::MAX, theme)) } } } + + /// Like [`Self::into_hyperlink_line`], but lays a status bar out for `width` columns. + pub(crate) fn into_hyperlink_line_for_width(self, width: u16) -> HyperlinkLine { + match self { + Self::StatusBar(bar) => bar.layout(usize::from(width)), + other => other.into_hyperlink_line(), + } + } +} + +impl From for FooterContent { + fn from(bar: StatusBar) -> Self { + Self::StatusBar(bar) + } } impl From for FooterContent { diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs index 46ba8d7b..4277bb36 100644 --- a/codex-rs/tui/src/bottom_pane/mod.rs +++ b/codex-rs/tui/src/bottom_pane/mod.rs @@ -92,6 +92,7 @@ pub(crate) use multi_select_picker::MultiSelectPicker; mod question_tests; mod questions; mod request_user_input; +mod status_bar; mod status_line_setup; mod status_line_style; mod status_surface_preview; @@ -123,6 +124,8 @@ pub(crate) use mcp_server_elicitation::McpServerElicitationFormRequest; pub(crate) use mcp_server_elicitation::McpServerElicitationOverlay; pub(crate) use request_user_input::RequestUserInputOverlay; pub(crate) use status_line_style::StatusLineAccent; +pub(crate) use status_line_style::status_bar_from_segments; +#[cfg(test)] pub(crate) use status_line_style::status_line_from_segments; pub(crate) use voice_strip::VoiceStripPhase; pub(crate) use voice_strip::VoiceStripState; diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_120.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_120.snap index f77dfd16..d47359bd 100644 --- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_120.snap +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_120.snap @@ -6,10 +6,11 @@ expression: rendered Tema dell'interfaccia aKode · qwen3.6-35b-a3b › aggiungi un saluto a main.rs • Fatto, vedi main.rs: -› 1. Scuro per sfondi scuri 3 - println!("Ciao"); - 2. Chiaro per sfondi chiari 3 + println!("Ciao, mondo!"); - 3. Alto contrasto massima leggibilità 192.168.40.25:8080 · Context 23% used · 26.8 tok/s - 4. Daltonici blu e arancio, mai rosso/verde - 5. Tema della sintassi… colori del codice +› 1. Automatico chiaro o scuro come il sistema 3 - println!("Ciao"); + 2. Scuro per sfondi scuri 3 + println!("Ciao, mondo!"); + 3. Chiaro per sfondi chiari 192.168.40.25:8080 · ctx 23% · 26.8 t/s + 4. Alto contrasto massima leggibilità + 5. Daltonici blu e arancio, mai rosso/verde + 6. Tema della sintassi… colori del codice Press enter to confirm or esc to go back diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_60.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_60.snap index 46c16c58..65796ccf 100644 --- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_60.snap +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_60.snap @@ -6,11 +6,12 @@ expression: rendered Tema dell'interfaccia -› 1. Scuro per sfondi scuri - 2. Chiaro per sfondi chiari - 3. Alto contrasto massima leggibilità - 4. Daltonici blu e arancio, mai rosso/verde - 5. Tema della sintassi… colori del codice +› 1. Automatico chiaro o scuro come il sistema + 2. Scuro per sfondi scuri + 3. Chiaro per sfondi chiari + 4. Alto contrasto massima leggibilità + 5. Daltonici blu e arancio, mai rosso/verde + 6. Tema della sintassi… colori del codice aKode · qwen3.6-35b-a3b @@ -18,5 +19,5 @@ expression: rendered • Fatto, vedi main.rs: 3 - println!("Ciao"); 3 + println!("Ciao, mondo!"); - 192.168.40.25:8080 · Context 23% used · 26.8 tok/s + 192.168.40.25:8080 · ctx 23% · 26.8 t/s Press enter to confirm or esc to go back diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_80.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_80.snap index 46c16c58..65796ccf 100644 --- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_80.snap +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__list_selection_view__tests__ui_theme_picker_80.snap @@ -6,11 +6,12 @@ expression: rendered Tema dell'interfaccia -› 1. Scuro per sfondi scuri - 2. Chiaro per sfondi chiari - 3. Alto contrasto massima leggibilità - 4. Daltonici blu e arancio, mai rosso/verde - 5. Tema della sintassi… colori del codice +› 1. Automatico chiaro o scuro come il sistema + 2. Scuro per sfondi scuri + 3. Chiaro per sfondi chiari + 4. Alto contrasto massima leggibilità + 5. Daltonici blu e arancio, mai rosso/verde + 6. Tema della sintassi… colori del codice aKode · qwen3.6-35b-a3b @@ -18,5 +19,5 @@ expression: rendered • Fatto, vedi main.rs: 3 - println!("Ciao"); 3 + println!("Ciao, mondo!"); - 192.168.40.25:8080 · Context 23% used · 26.8 tok/s + 192.168.40.25:8080 · ctx 23% · 26.8 t/s Press enter to confirm or esc to go back diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_akode_default_items.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_akode_default_items.snap index f4ce27fe..35da59a9 100644 --- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_akode_default_items.snap +++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__status_line_setup__tests__setup_view_snapshot_akode_default_items.snap @@ -13,9 +13,9 @@ expression: "render_lines(&view,\n80).lines().map(str::trim_end).collect::, + right: Vec, + /// Passive hints (agent label, agents shortcut) appended to the left group; dropped first. + suffix: Line<'static>, + /// Width the right group is budgeted at, so ticking values do not reflow the left group. + right_reserve: usize, + pull_request_url: Option, +} + +impl StatusBar { + pub(crate) fn new( + left: Vec, + right: Vec, + pull_request_url: Option, + ) -> Option { + if left.is_empty() && right.is_empty() { + return None; + } + let right_reserve = stable_right_width(&right); + Some(Self { + left, + right, + suffix: Line::default(), + right_reserve, + pull_request_url, + }) + } + + pub(crate) fn with_suffix(mut self, suffix: Line<'static>) -> Self { + self.suffix = suffix; + self + } + + pub(crate) fn natural_width(&self) -> usize { + self.natural_line().width() + } + + /// Both groups at full length, separated by the minimum gap. + pub(crate) fn natural_line(&self) -> HyperlinkLine { + let left = self.left_line(&self.full_texts(), /*with_suffix*/ true); + let right = self.right_line(); + let width = left.width() + + right.width() + + if left.width() > 0 && right.width() > 0 { + STATUS_BAR_GAP + } else { + 0 + }; + compose(left, right, width) + } + + /// Lays the bar out in exactly `width` columns (or less when nothing needs padding). + pub(crate) fn layout(&self, width: usize) -> HyperlinkLine { + let right = self.right_line(); + let right_width = right.width(); + if right_width == 0 { + let left = self + .fit_left(width) + .unwrap_or_else(|| self.left_line(&self.full_texts(), /*with_suffix*/ false)); + let mut left = left; + if left.width() > width { + left.line = truncate_line_with_ellipsis_if_overflow(left.line, width); + left.clip_hyperlinks_to_width(left.width().saturating_sub(1)); + } + return left; + } + let reserve = right_width.max(self.right_reserve); + let left = width + .checked_sub(reserve + STATUS_BAR_GAP) + .filter(|available| *available > 0) + .and_then(|available| self.fit_left(available)) + .unwrap_or_default(); + compose(left, right, width) + } + + fn full_texts(&self) -> Vec> { + self.left + .iter() + .map(|segment| Some(segment.text.clone())) + .collect() + } + + fn right_line(&self) -> HyperlinkLine { + join_status_segments(self.right.iter(), self.pull_request_url.as_deref()) + } + + fn left_line(&self, texts: &[Option], with_suffix: bool) -> HyperlinkLine { + let kept: Vec = self + .left + .iter() + .zip(texts) + .filter_map(|(segment, text)| { + text.as_ref().map(|text| StyledStatusSegment { + text: text.clone(), + ..segment.clone() + }) + }) + .collect(); + let mut line = join_status_segments(kept.iter(), self.pull_request_url.as_deref()); + if with_suffix && !self.suffix.spans.is_empty() { + if !line.line.spans.is_empty() { + line.line.push_span(Span::styled( + super::status_line_style::STATUS_LINE_SEPARATOR, + crate::style::secondary_text_style(), + )); + } + line.line.spans.extend(self.suffix.spans.iter().cloned()); + } + line + } + + /// Shrinks the left group into `available` columns, or `None` when it has to go entirely. + fn fit_left(&self, available: usize) -> Option { + let mut texts = self.full_texts(); + let fits = |texts: &[Option], with_suffix: bool| { + let line = self.left_line(texts, with_suffix); + (line.width() <= available).then_some(line) + }; + if let Some(line) = fits(&texts, /*with_suffix*/ true) { + return Some(line); + } + if let Some(line) = fits(&texts, /*with_suffix*/ false) { + return Some(line); + } + + let dir = self.position(StatusLineItem::CurrentDir); + let model = self + .position(StatusLineItem::ModelName) + .or_else(|| self.position(StatusLineItem::ModelWithReasoning)); + + // 1. Shorten the directory in the middle, keeping its last component. + if let Some(dir) = dir { + let full = self.left[dir].text.as_str(); + let overflow = self.left_line(&texts, false).width() - available; + let target = full.width().saturating_sub(overflow).max(min_dir_width(full)); + texts[dir] = Some(shorten_dir(full, target)); + if let Some(line) = fits(&texts, false) { + return Some(line); + } + } + // 2. Shorten the model name. + if let Some(line) = self.shrink_model(&mut texts, model, available) { + return Some(line); + } + // 3. Drop the directory (and the branch that hangs off it), model back at full length. + if let Some(dir) = dir { + texts[dir] = None; + if self + .left + .get(dir + 1) + .is_some_and(|segment| segment.item == StatusLineItem::GitBranch) + { + texts[dir + 1] = None; + } + if let Some(model) = model { + texts[model] = Some(self.left[model].text.clone()); + } + if let Some(line) = fits(&texts, false) { + return Some(line); + } + if let Some(line) = self.shrink_model(&mut texts, model, available) { + return Some(line); + } + } + // 4. Give the row to the right group. + None + } + + fn shrink_model( + &self, + texts: &mut [Option], + model: Option, + available: usize, + ) -> Option { + let model = model?; + let full = self.left[model].text.as_str(); + let overflow = self.left_line(texts, false).width().checked_sub(available)?; + let current = texts[model].as_deref().map_or(0, UnicodeWidthStr::width); + let target = current + .saturating_sub(overflow) + .max(MODEL_MIN_WIDTH.min(full.width())); + texts[model] = Some(truncate_end(full, target)); + let line = self.left_line(texts, false); + (line.width() <= available).then_some(line) + } + + fn position(&self, item: StatusLineItem) -> Option { + self.left.iter().position(|segment| segment.item == item) + } +} + +/// `left`, padding, then `right` ending at column `width`. +fn compose(mut left: HyperlinkLine, right: HyperlinkLine, width: usize) -> HyperlinkLine { + let right_width = right.width(); + if right_width > width { + let mut right = right; + right.line = truncate_line_with_ellipsis_if_overflow(right.line, width); + return right; + } + let padding = width.saturating_sub(left.width() + right_width); + if padding > 0 && right_width > 0 { + left.line.push_span(Span::raw(" ".repeat(padding))); + } + left.line.spans.extend(right.line.spans); + left +} + +fn last_component(path: &str) -> &str { + path.trim_end_matches(std::path::MAIN_SEPARATOR) + .rsplit(std::path::MAIN_SEPARATOR) + .next() + .unwrap_or(path) +} + +/// `…/last-component`, or the whole path when that is no shorter. +fn min_dir_width(path: &str) -> usize { + (last_component(path).width() + 2).min(path.width()) +} + +/// Middle-truncates `path` to `target` columns, always keeping its last component whole. +fn shorten_dir(path: &str, target: usize) -> String { + if path.width() <= target { + return path.to_string(); + } + let last = last_component(path); + let shortened = center_truncate_path(path, target); + if shortened.ends_with(&format!("{}{last}", std::path::MAIN_SEPARATOR)) { + shortened + } else { + format!("…{}{last}", std::path::MAIN_SEPARATOR) + } +} + +fn truncate_end(text: &str, max_width: usize) -> String { + if text.width() <= max_width { + return text.to_string(); + } + if max_width == 0 { + return String::new(); + } + let mut out = String::new(); + let mut used = 0; + for ch in text.chars() { + let ch_width = ch.width().unwrap_or(0); + if used + ch_width + 1 > max_width { + break; + } + used += ch_width; + out.push(ch); + } + out.push('…'); + out +} + +/// Widest typical value of each right-hand item, so the group keeps one width as values tick. +fn stable_right_width(right: &[StyledStatusSegment]) -> usize { + let typical: Vec = right + .iter() + .map(|segment| { + let widest = match segment.item { + StatusLineItem::ContextUsed => "ctx 100%", + StatusLineItem::ContextRemaining => "ctx 100% left", + StatusLineItem::TokensPerSecond => "99.9 t/s", + _ => "", + }; + StyledStatusSegment { + text: if widest.width() > segment.text.width() { + widest.to_string() + } else { + segment.text.clone() + }, + ..segment.clone() + } + }) + .collect(); + join_status_segments(typical.iter(), /*pull_request_url*/ None).width() +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::style::secondary_text_style; + use pretty_assertions::assert_eq; + + fn segment(item: StatusLineItem, text: &str) -> StyledStatusSegment { + StyledStatusSegment { + item, + text: text.to_string(), + style: secondary_text_style(), + } + } + + fn bar() -> StatusBar { + StatusBar::new( + vec![ + segment(StatusLineItem::ServerEndpoint, "127.0.0.1:8080"), + segment(StatusLineItem::ModelName, "qwen3.6-35b-a3b"), + segment(StatusLineItem::CurrentDir, "~/Downloads/progetto-di-prova"), + segment(StatusLineItem::GitBranch, "main"), + ], + vec![ + segment(StatusLineItem::ContextUsed, "ctx 23%"), + segment(StatusLineItem::TokensPerSecond, "26.8 t/s"), + ], + None, + ) + .expect("bar") + } + + fn text(line: &HyperlinkLine) -> String { + line.line.to_string() + } + + #[test] + fn layout_degrades_left_group_in_order_and_keeps_right_flush() { + let bar = bar(); + // The right group is budgeted at its widest typical width ("ctx 100% · 99.9 t/s"). + let cases = [ + ( + 92, + "127.0.0.1:8080 · qwen3.6-35b-a3b · ~/Downloads/progetto-di-prova (main) ctx 23% · 26.8 t/s", + ), + ( + 90, + "127.0.0.1:8080 · qwen3.6-35b-a3b · ~/…/progetto-di-prova (main) ctx 23% · 26.8 t/s", + ), + ( + 70, + "127.0.0.1:8080 · qwen3.6-35b-a3b ctx 23% · 26.8 t/s", + ), + (50, "127.0.0.1:8080 · qwen3.6-35b… ctx 23% · 26.8 t/s"), + (30, " ctx 23% · 26.8 t/s"), + (10, "ctx 23% ·…"), + ]; + let actual: Vec<(usize, String)> = cases + .iter() + .map(|(width, _)| (*width, text(&bar.layout(*width)))) + .collect(); + let expected: Vec<(usize, String)> = cases + .iter() + .map(|(width, expected)| (*width, expected.to_string())) + .collect(); + assert_eq!(actual, expected); + for (width, line) in &actual { + assert_eq!(line.width(), *width, "{line:?} must end at column {width}"); + } + } +} diff --git a/codex-rs/tui/src/bottom_pane/status_line_setup.rs b/codex-rs/tui/src/bottom_pane/status_line_setup.rs index 03a89589..1c195afd 100644 --- a/codex-rs/tui/src/bottom_pane/status_line_setup.rs +++ b/codex-rs/tui/src/bottom_pane/status_line_setup.rs @@ -52,7 +52,7 @@ const STATUS_LINE_USE_THEME_COLORS_ITEM_ID: &str = "status-line-use-theme-colors /// Some items are conditionally displayed based on availability: /// - Git-related items only show when in a git repository /// - Context items only show when data is available from the API -/// - Tokens per second only shows after the first response finishes +/// - Tokens per second shows `-- t/s` until the first response finishes /// - Thread ID only shows after a session has started #[derive(EnumIter, EnumString, Display, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] #[strum(serialize_all = "kebab_case")] @@ -189,7 +189,7 @@ impl StatusLineItem { "Percentage of context window used (omitted when unknown)" } StatusLineItem::ServerEndpoint => "Model server host:port (omitted without base URL)", - StatusLineItem::TokensPerSecond => "Last response speed in tok/s (omitted until known)", + StatusLineItem::TokensPerSecond => "Last response speed in t/s (-- until known)", StatusLineItem::CodexVersion => "aKode application version", StatusLineItem::ContextWindowSize => { "Total context window size in tokens (omitted when unknown)" @@ -572,11 +572,11 @@ mod tests { ), ( StatusLineItem::ContextUsed.preview_item(), - "Context 23% used".to_string(), + "ctx 23%".to_string(), ), ( StatusLineItem::TokensPerSecond.preview_item(), - "26.8 tok/s".to_string(), + "26.8 t/s".to_string(), ), ( StatusLineItem::CurrentDir.preview_item(), diff --git a/codex-rs/tui/src/bottom_pane/status_line_style.rs b/codex-rs/tui/src/bottom_pane/status_line_style.rs index ffcb81fa..c23afeec 100644 --- a/codex-rs/tui/src/bottom_pane/status_line_style.rs +++ b/codex-rs/tui/src/bottom_pane/status_line_style.rs @@ -5,6 +5,7 @@ use ratatui::style::Style; use ratatui::style::Styled; use ratatui::text::Span; +use super::status_bar::StatusBar; use super::status_line_setup::StatusLineItem; use crate::render::highlight::foreground_style_for_scopes; use crate::style::readable_color_on; @@ -99,6 +100,7 @@ impl StatusLineAccent { } } +#[cfg(test)] pub(crate) fn status_line_from_segments( segments: I, use_theme_colors: bool, @@ -117,6 +119,7 @@ where ) } +#[cfg(test)] fn status_line_from_segments_with_resolver( segments: I, use_theme_colors: bool, @@ -127,19 +130,129 @@ fn status_line_from_segments_with_resolver( where I: IntoIterator, F: Fn(StatusLineAccent) -> Option