summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers/mesh_supervisor.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-15 22:55:04 +0000
committersoryu <soryu@soryu.co>2026-01-16 01:12:03 +0000
commitb69dc962cd99aa8b478b7c5facbd56bfb63eda27 (patch)
tree9922f60b0da646eaf00165d5348b25e822dfd7b0 /makima/src/server/handlers/mesh_supervisor.rs
parent6ee2e75834bff187b8c262e0798ef365bc21cd59 (diff)
downloadsoryu-b69dc962cd99aa8b478b7c5facbd56bfb63eda27.tar.gz
soryu-b69dc962cd99aa8b478b7c5facbd56bfb63eda27.zip
Add Task Contract Type for one-off adhoc tasks (#2)
Diffstat (limited to 'makima/src/server/handlers/mesh_supervisor.rs')
-rw-r--r--makima/src/server/handlers/mesh_supervisor.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/makima/src/server/handlers/mesh_supervisor.rs b/makima/src/server/handlers/mesh_supervisor.rs
index b45dda5..3fc7dd7 100644
--- a/makima/src/server/handlers/mesh_supervisor.rs
+++ b/makima/src/server/handlers/mesh_supervisor.rs
@@ -1839,9 +1839,14 @@ pub async fn rewind_conversation(
// Determine how many messages to keep
let new_count = if let Some(by_count) = req.by_message_count {
(original_count - by_count).max(0)
- } else if let Some(to_index) = req.to_message_index {
- // Keep messages up to and including the specified index
- (to_index + 1).min(original_count).max(0)
+ } else if let Some(ref to_id) = req.to_message_id {
+ // Find message by ID and keep up to and including it
+ let index = conversation
+ .iter()
+ .position(|msg| msg.get("id").and_then(|v| v.as_str()) == Some(to_id.as_str()))
+ .map(|i| i as i32)
+ .unwrap_or(original_count - 1);
+ (index + 1).min(original_count).max(0)
} else {
// Default to removing last message
(original_count - 1).max(0)