Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: allow stopping auto-detected meetings from overlay button

Louis Beaumont403d5b7320e9
diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rs
index 94c6eb5e3..39ad257f8 100644
--- a/crates/screenpipe-db/src/db.rs
+++ b/crates/screenpipe-db/src/db.rs
@@ -6787,6 +6787,15 @@ LIMIT ? OFFSET ?
Ok(row.0 > 0)
}
+ pub async fn get_most_recent_active_meeting_id(&self) -> Result<Option<i64>, SqlxError> {
+ let row: Option<(i64,)> = sqlx::query_as(
+ "SELECT id FROM meetings WHERE meeting_end IS NULL ORDER BY id DESC LIMIT 1",
+ )
+ .fetch_optional(&self.pool)
+ .await?;
+ Ok(row.map(|r| r.0))
+ }
+
pub async fn list_meetings(
&self,
start_time: Option<&str>,
diff --git a/crates/screenpipe-engine/src/routes/meetings.rs b/crates/screenpipe-engine/src/routes/meetings.rs
index dbd67d6c3..97c4f612c 100644
--- a/crates/screenpipe-engine/src/routes/meetings.rs
+++ b/crates/screenpipe-engine/src/routes/meetings.rs
@@ -216,7 +216,9 @@ pub(crate) async fn meeting_status_handler(
state.db.has_active_meeting().await.unwrap_or(false)
};
- Ok(JsonResponse(json!({ "active": any_active })))
+ Ok(JsonResponse(
+ json!({ "active": any_active, "manual": manual_active }),
+ ))
}
#[oasgen]
@@ -273,12 +275,30 @@ pub(crate) async fn stop_meeting_handler(
*lock
};
- let id = id.ok_or_else(|| {
- (
- StatusCode::BAD_REQUEST,
- JsonResponse(json!({"error": "no active manual meeting"})),
- )
- })?;
+ // If no manual meeting, find any active meeting (auto-detected) and end it.
+ // This lets users stop auto-detected meetings (Google Meet, Zoom, etc.)
+ // from the overlay button.
+ let id = match id {
+ Some(id) => id,
+ None => {
+ let active_id = state
+ .db
+ .get_most_recent_active_meeting_id()
+ .await
+ .map_err(|e| {
+ (
+ StatusCode::INTERNAL_SERVER_ERROR,
+ JsonResponse(json!({"error": e.to_string()})),
+ )
+ })?;
+ active_id.ok_or_else(|| {
+ (
+ StatusCode::BAD_REQUEST,
+ JsonResponse(json!({"error": "no active meeting"})),
+ )
+ })?
+ }
+ };
let now = Utc::now().format("%Y-%m-%dT%H:%M:%S%.3fZ").to_string();