Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions src/codex_app_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ pub enum CodexHoldReason {
Compaction,
NotLoaded,
SystemError,
UnknownStatus,
WaitingOnApproval,
WaitingOnUserInput,
}
Expand Down Expand Up @@ -860,7 +861,7 @@ impl CodexControlState {
turn_id: None,
},
_ => CodexObservedState::Held {
reason: CodexHoldReason::SystemError,
reason: CodexHoldReason::UnknownStatus,
turn_id: None,
},
};
Expand Down Expand Up @@ -915,7 +916,8 @@ impl CodexControlState {
| CodexHoldReason::WaitingOnApproval
| CodexHoldReason::WaitingOnUserInput
| CodexHoldReason::NotLoaded
| CodexHoldReason::SystemError,
| CodexHoldReason::SystemError
| CodexHoldReason::UnknownStatus,
..
} => self.observed.clone(),
// A completion for a turn other than the one believed live is the only evidence here
Expand Down Expand Up @@ -4320,6 +4322,51 @@ mod tests {
);
}

#[test]
fn an_unrecognized_thread_status_has_a_distinct_delivery_hold() {
let mut state = subscribed_state(CodexObservedState::Active {
turn_id: "turn-1".into(),
});

state
.observe(&json!({
"method": "thread/status/changed",
"params": {
"threadId": "thread-main",
"status": { "type": "futureStatus" }
}
}))
.unwrap();
assert_eq!(
state.observed(),
&CodexObservedState::Held {
reason: CodexHoldReason::UnknownStatus,
turn_id: None,
}
);

state
.observe(&json!({
"method": "turn/completed",
"params": { "threadId": "thread-main", "turn": { "id": "turn-1" } }
}))
.unwrap();
assert!(matches!(
state.observed(),
CodexObservedState::Held {
reason: CodexHoldReason::UnknownStatus,
..
}
));

let tmp = tempfile::tempdir().unwrap();
let config = delivery_config(tmp.path());
message::send_to_inbox(&config.inbox, "h.sender", Some("held"), None, &[], "body")
.unwrap();
let mut delivery = inbox_delivery(tmp.path(), config);
assert_eq!(delivery.maybe_request(&state).unwrap(), None);
}

#[test]
fn persisted_control_state_is_bound_to_the_exact_runtime_incarnation() {
let tmp = tempfile::tempdir().unwrap();
Expand Down
Loading