Skip to content
Merged
Show file tree
Hide file tree
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
529 changes: 132 additions & 397 deletions crates/mcp-config/src/codex/limit.rs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions crates/mcp-config/src/codex/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ pub struct Tail {
pub status: Status,
/// The last turn end read and not yet taken (#294, `limit::turn_end`).
turn_end: Option<super::limit::TurnEnd>,
/// A turn's `task_started` was read and not yet taken (#403): the seat
/// answered the resume typed into it.
turn_started: bool,
/// The reset the last `token_count` reported for its fullest window
/// (#294, `limit::rollout_reset`): what the room is told while the
/// app-server has not said better.
Expand Down Expand Up @@ -199,6 +202,7 @@ impl Tail {
if let Some(end) = super::limit::turn_end(&value) {
self.turn_end = Some(end);
}
self.turn_started |= value["type"] == "event_msg" && value["payload"]["type"] == "task_started";
if let Some(reset) = super::limit::rollout_reset(&value) {
self.resets_at = Some(reset);
}
Expand All @@ -220,6 +224,11 @@ impl Tail {
self.turn_end.take()
}

/// Whether a turn started since the previous call (#403).
pub fn take_turn_started(&mut self) -> bool {
std::mem::take(&mut self.turn_started)
}

/// Whether the rate limits were read since the previous call (#364).
pub fn take_limits_read(&mut self) -> bool {
std::mem::take(&mut self.limits_read)
Expand Down Expand Up @@ -496,6 +505,10 @@ mod tests {
assert_eq!(tail.resets_at, Some(1791613577), "93 is the fuller window in TOKENS");
assert_eq!(tail.take_turn_end(), Some(TurnEnd::UsageLimit));
assert_eq!(tail.take_turn_end(), None);
assert!(!tail.take_turn_started());
tail.feed(lines(&[r#"{"type":"event_msg","payload":{"type":"task_started"}}"#]).as_bytes());
assert!(tail.take_turn_started());
assert!(!tail.take_turn_started(), "taken once");
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/mcp-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub mod hook_activity;
pub mod claude_limit;
pub mod claude_notice;
pub mod claude_resume;
pub mod limit_recovery;
pub mod permission_prompt;
pub mod prompt_hold;
pub mod usage;
Expand Down
150 changes: 0 additions & 150 deletions crates/mcp-config/src/limit_recovery.rs

This file was deleted.

Loading
Loading