Explain session creation failures during server shutdown (#52721)

## Why

Graceful shutdown rejects new sessions with an invalid-request error. Give clients a structured shutdown reason and show command center users why session creation is paused.

## What changed

- Add `data: {"reason":"serverShuttingDown"}` to app-server shutdown admission errors while retaining JSON-RPC code `-32600`.
- Show a dedicated shutdown message explaining the wait for active turns and automatic reconnection for non-embedded servers. Recognize older servers by their exact draining message only when error data is absent, and preserve retained-worktree cleanup guidance.
- Keep the command center reconnect presentation when a shutdown error covers the initial overview and no conversation is open.

## Testing

Extend admission and WebSocket shutdown assertions, add embedded and daemon shutdown message snapshots, and cover reconnection with a shutdown error over the initial command center.

GitOrigin-RevId: f167144c0ddc77872afdf3daac8bb1c89f3425b4
This commit is contained in:
Eric Traut
2026-10-09 23:16:46 +00:00
committed by copyberry
parent 4aa94dce27
commit 07757f448f
12 changed files with 154 additions and 20 deletions
+3 -1
View File
@@ -8,7 +8,9 @@ pub(crate) const OVERLOADED_ERROR_CODE: i64 = -32001;
pub const INPUT_TOO_LARGE_ERROR_CODE: &str = "input_too_large";
pub(crate) fn server_draining_error() -> JSONRPCErrorError {
invalid_request("Server is draining; retry after reconnecting")
let mut error = invalid_request("Server is draining; retry after reconnecting");
error.data = Some(serde_json::json!({ "reason": "serverShuttingDown" }));
error
}
pub(crate) fn invalid_request(message: impl Into<String>) -> JSONRPCErrorError {