Use server model defaults for fresh TUI startup (#43177)

## Why

Fresh startup could use saved client model and reasoning settings that differ from the app server's effective configuration. A cleared server model could also leave startup using a stale client model from bootstrap.

## What changed

- Reuse the new-session defaults reader at startup to load `model` and `model_reasoning_effort` through `config/read` before `thread/start`, using the appropriate embedded or remote working directory.
- Preserve explicit CLI and selected-profile settings, then apply managed new-thread defaults with the existing precedence rules.
- When the server has no configured model, select the startup model from its model catalog, falling back to the bootstrap default if the catalog is empty.
- Fall back to local defaults when older servers do not support `config/read`; stop startup before thread creation on other read failures.

## Testing

Add request-level tests for defaults and override precedence, working-directory selection, cleared-model fallback, request ordering, unsupported servers, and read failures.

GitOrigin-RevId: e094ba5d5501fdb34c393a0117b34dd93d8d4f2b
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-06 07:31:40 +00:00
1 parent 6af345407d
commit 9587c9ef36
6 files changed
+581 -53

No files matched your search

@@ -51,6 +51,7 @@ enum HistoryCapabilities {
ThreadListFails,
ThreadStartFails,
ConfigReadUnsupported(i64),
ConfigReadFails,
}
/// Returns and resets `(thread/loaded/list, thread/read)` request counts.
@@ -202,6 +203,17 @@ async fn start_recording_app_server_with_history(
message: "unknown variant `config/read`".to_string(),
},
})
} else if history_capabilities == HistoryCapabilities::ConfigReadFails
&& request.method == "config/read"
{
JSONRPCMessage::Error(JSONRPCError {
id: request_id,
error: JSONRPCErrorError {
code: -32603,
data: None,
message: "config temporarily unavailable".to_string(),
},
})
} else if history_capabilities == HistoryCapabilities::ThreadStartFails
&& request.method == "thread/start"
{
@@ -3716,3 +3728,5 @@ fn session_lifecycle_avoids_redundant_subagent_metadata_reads() -> Result<()> {
#[path = "new_session_tests.rs"]
mod new_session_tests;
#[path = "startup_defaults_tests.rs"]
mod startup_defaults_tests;