summaryrefslogtreecommitdiff
path: root/makima/src/daemon/task
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/daemon/task')
-rw-r--r--makima/src/daemon/task/completion_gate.rs21
-rw-r--r--makima/src/daemon/task/state.rs4
2 files changed, 11 insertions, 14 deletions
diff --git a/makima/src/daemon/task/completion_gate.rs b/makima/src/daemon/task/completion_gate.rs
index 69b7c6a..40a6466 100644
--- a/makima/src/daemon/task/completion_gate.rs
+++ b/makima/src/daemon/task/completion_gate.rs
@@ -5,7 +5,7 @@
//! development framework.
//!
//! Format:
-//! ```
+//! ```text
//! <COMPLETION_GATE>
//! ready: true|false
//! reason: "explanation of completion status"
@@ -133,19 +133,18 @@ impl CompletionGate {
/// This is useful when Claude produces multiple completion gates during
/// a long-running task, and we want to use the final status.
pub fn parse_last(text: &str) -> Option<Self> {
+ let start_tag = "<COMPLETION_GATE>";
let end_tag = "</COMPLETION_GATE>";
- let mut last_gate = None;
- let mut search_start = 0;
- while let Some(end_idx) = text[search_start..].find(end_tag) {
- let absolute_end = search_start + end_idx + end_tag.len();
- if let Some(gate) = Self::parse(&text[..absolute_end]) {
- last_gate = Some(gate);
- }
- search_start = absolute_end;
- }
+ // Find the last occurrence of the start tag
+ let start_idx = text.rfind(start_tag)?;
+ let remaining = &text[start_idx..];
+
+ // Find the end tag after the last start tag
+ let end_idx = remaining.find(end_tag)?;
- last_gate
+ // Parse just this last gate
+ Self::parse(&remaining[..end_idx + end_tag.len()])
}
}
diff --git a/makima/src/daemon/task/state.rs b/makima/src/daemon/task/state.rs
index 7b59b62..fe73de1 100644
--- a/makima/src/daemon/task/state.rs
+++ b/makima/src/daemon/task/state.rs
@@ -124,9 +124,7 @@ impl Default for TaskState {
#[cfg(test)]
mod tests {
- #[allow(unused_imports)]
- use crate::daemon::*;
- use super::TaskState;
+ use super::*;
#[test]
fn test_valid_transitions() {