Files
codex/codex-rs/tui/src/session_queue_commands_tests.rs
Eric Traut 83d015375e Add a command to queue messages for existing sessions (#39092)
## What changed

- Add `codex queue --thread <THREAD> --message <TEXT>` to submit a text message through the `thread/queue/add` app-server API.
- Resolve active sessions by UUID or exact name across interactive, exec, and custom sources, and reject ambiguous names.
- Support local and explicit remote app servers while reporting incompatible servers and configuration overrides instead of silently changing the target.
- Reject empty messages and image attachments.

## Testing

- Add CLI coverage for remote submission, validation, unsupported servers, and local-daemon routing.
- Add session lookup and queue tests for stale, non-interactive, custom, and duplicate session names.

GitOrigin-RevId: 44c233f752b63a85c85b92fa6da303336e4ddeca
2026-08-17 22:44:37 +00:00

54 lines
1.7 KiB
Rust

use codex_app_server_client::TypedRequestError;
use codex_app_server_protocol::JSONRPCErrorError;
use codex_app_server_protocol::experimental_required_message;
use color_eyre::Report;
use pretty_assertions::assert_eq;
use super::JSONRPC_INVALID_REQUEST;
use super::JSONRPC_METHOD_NOT_FOUND;
use super::THREAD_QUEUE_ADD_METHOD;
use super::is_unsupported_queue_error;
#[test]
fn recognizes_only_definitively_unsupported_queue_errors() {
for (code, message, unsupported) in [
(
JSONRPC_METHOD_NOT_FOUND,
"Method not found".to_string(),
true,
),
(
JSONRPC_INVALID_REQUEST,
experimental_required_message(THREAD_QUEUE_ADD_METHOD),
true,
),
(
JSONRPC_INVALID_REQUEST,
"Invalid request: unknown variant `thread/queue/add`, expected `thread/list`"
.to_string(),
true,
),
(
JSONRPC_INVALID_REQUEST,
"queue cannot contain more than 100 submissions".to_string(),
false,
),
] {
let error = Report::new(TypedRequestError::Server {
method: THREAD_QUEUE_ADD_METHOD.to_string(),
source: JSONRPCErrorError {
code,
message,
data: None,
},
});
assert_eq!(is_unsupported_queue_error(&error), unsupported);
}
let transport_error = Report::new(TypedRequestError::Transport {
method: THREAD_QUEUE_ADD_METHOD.to_string(),
source: std::io::Error::new(std::io::ErrorKind::TimedOut, "request timed out"),
});
assert!(!is_unsupported_queue_error(&transport_error));
}