muse_code_sdk/client/list.rs
1//! Listing stored sessions over `session/list`.
2
3use crate::msp::{SessionListFilter, SessionListParams, SessionListResult};
4
5use super::{FacadeResult, MuseClient};
6
7/// Options for [`MuseClient::list_sessions`]. A field left `None` is not sent.
8#[derive(Clone, Debug, Default, PartialEq, Eq)]
9pub struct ListSessionsOptions {
10 /// The page cursor a previous listing returned as `next_cursor`; `None`
11 /// asks for the first page.
12 pub cursor: Option<String>,
13 /// The page size; the server applies its own default and maximum.
14 pub limit: Option<u32>,
15 /// Only sessions whose workspace root is this path.
16 pub workspace_root: Option<String>,
17 /// Only sessions with activity after this RFC 3339 instant.
18 pub updated_after: Option<String>,
19 /// Selects sessions by id, branch, or name and title text. A server that
20 /// applies it echoes it as the result's `applied_filter`.
21 pub filter: Option<SessionListFilter>,
22}
23
24impl MuseClient {
25 /// Lists the host's stored sessions, newest activity first, one page per
26 /// call. A read-only query: it opens and subscribes to nothing.
27 pub async fn list_sessions(
28 &self,
29 options: ListSessionsOptions,
30 ) -> FacadeResult<SessionListResult> {
31 let params = SessionListParams {
32 cursor: options.cursor,
33 limit: options.limit,
34 workspace_root: options.workspace_root,
35 updated_after: options.updated_after,
36 filter: options.filter,
37 };
38 self.shared.command("session/list", ¶ms).await
39 }
40}