From b20d4596a9d188b3fcf924a2b3f60784be73e66c Mon Sep 17 00:00:00 2001 From: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com> Date: Tue, 24 Mar 2026 14:46:17 -0400 Subject: [PATCH] feat(messages): add `since` parameter to get_messages API and MCP tool (#154) --- crates/sprout-cli/src/commands/messages.rs | 4 ++++ crates/sprout-cli/src/main.rs | 14 +++++++++-- crates/sprout-db/src/lib.rs | 2 ++ crates/sprout-db/src/thread.rs | 28 ++++++++++++++++++---- crates/sprout-mcp/src/server.rs | 14 +++++++++-- crates/sprout-relay/src/api/messages.rs | 21 ++++++++++++++-- 6 files changed, 73 insertions(+), 10 deletions(-) diff --git a/crates/sprout-cli/src/commands/messages.rs b/crates/sprout-cli/src/commands/messages.rs index 4f39465bce..53643070c0 100644 --- a/crates/sprout-cli/src/commands/messages.rs +++ b/crates/sprout-cli/src/commands/messages.rs @@ -69,6 +69,7 @@ pub async fn cmd_get_messages( channel_id: &str, limit: Option, before: Option, + since: Option, kinds: Option<&str>, ) -> Result<(), CliError> { validate_uuid(channel_id)?; @@ -77,6 +78,9 @@ pub async fn cmd_get_messages( if let Some(b) = before { path.push_str(&format!("&before={b}")); } + if let Some(s) = since { + path.push_str(&format!("&since={s}")); + } if let Some(k) = kinds { path.push_str(&format!("&kinds={}", percent_encode(k))); } diff --git a/crates/sprout-cli/src/main.rs b/crates/sprout-cli/src/main.rs index 42146cfca8..69b1b5e5a5 100644 --- a/crates/sprout-cli/src/main.rs +++ b/crates/sprout-cli/src/main.rs @@ -97,6 +97,8 @@ enum Cmd { #[arg(long)] before: Option, #[arg(long)] + since: Option, + #[arg(long)] kinds: Option, }, /// Get a message thread @@ -531,10 +533,18 @@ async fn run(cli: Cli) -> Result<(), CliError> { channel, limit, before, + since, kinds, } => { - commands::messages::cmd_get_messages(&client, &channel, limit, before, kinds.as_deref()) - .await + commands::messages::cmd_get_messages( + &client, + &channel, + limit, + before, + since, + kinds.as_deref(), + ) + .await } Cmd::GetThread { channel, diff --git a/crates/sprout-db/src/lib.rs b/crates/sprout-db/src/lib.rs index 3c7188bd86..f895b339b8 100644 --- a/crates/sprout-db/src/lib.rs +++ b/crates/sprout-db/src/lib.rs @@ -641,6 +641,7 @@ impl Db { channel_id: Uuid, limit: u32, before_cursor: Option>, + since_cursor: Option>, kind_filter: Option<&[u32]>, ) -> Result> { thread::get_channel_messages_top_level( @@ -648,6 +649,7 @@ impl Db { channel_id, limit, before_cursor, + since_cursor, kind_filter, ) .await diff --git a/crates/sprout-db/src/thread.rs b/crates/sprout-db/src/thread.rs index decde54e59..cec99c0662 100644 --- a/crates/sprout-db/src/thread.rs +++ b/crates/sprout-db/src/thread.rs @@ -480,14 +480,19 @@ pub async fn get_thread_summary(pool: &PgPool, event_id: &[u8]) -> Result