diff options
| author | Michelle Tilley <michelle@michelletilley.net> | 2026-04-21 10:32:54 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-21 10:32:54 -0700 |
| commit | 0f20ee4eb871907defe7848f0d3e2203cfff057e (patch) | |
| tree | cda9034c4c6e7b5ecf0fe957978284e9138b80ff /crates/atuin-ai/src/session.rs | |
| parent | chore: Clarified note about regular expressions matching in path. (#3427) (diff) | |
| download | atuin-0f20ee4eb871907defe7848f0d3e2203cfff057e.zip | |
feat: AI tool rendering overhaul + edit_file tool (#3423)
Overhaul of how AI tool calls are modeled, rendered, and displayed in
the Atuin AI TUI. Fixes bugs in shell command output capture, implements
the `edit_file` tool with full safety infrastructure, and adds a diff
preview for edits.
Diffstat (limited to 'crates/atuin-ai/src/session.rs')
| -rw-r--r-- | crates/atuin-ai/src/session.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/atuin-ai/src/session.rs b/crates/atuin-ai/src/session.rs index d8314343..848330fc 100644 --- a/crates/atuin-ai/src/session.rs +++ b/crates/atuin-ai/src/session.rs @@ -51,6 +51,9 @@ pub(crate) trait SessionService: Send + Sync { ) -> Result<()>; async fn archive(&self, session_id: &str) -> Result<()>; + + async fn get_metadata(&self, session_id: &str, key: &str) -> Result<Option<String>>; + async fn set_metadata(&self, session_id: &str, key: &str, value: &str) -> Result<()>; } // --------------------------------------------------------------------------- @@ -128,6 +131,14 @@ impl SessionService for LocalSessionService { async fn archive(&self, session_id: &str) -> Result<()> { self.store.archive_session(session_id).await } + + async fn get_metadata(&self, session_id: &str, key: &str) -> Result<Option<String>> { + self.store.get_metadata(session_id, key).await + } + + async fn set_metadata(&self, session_id: &str, key: &str, value: &str) -> Result<()> { + self.store.set_metadata(session_id, key, value).await + } } // --------------------------------------------------------------------------- @@ -310,6 +321,22 @@ impl SessionManager { pub fn invocation_id(&self) -> &str { &self.invocation_id } + + /// Read a metadata value for the current session. + pub async fn get_metadata(&self, key: &str) -> Result<Option<String>> { + if !self.persisted_to_db { + return Ok(None); + } + self.service.get_metadata(&self.session_id, key).await + } + + /// Write a metadata value for the current session. + pub async fn set_metadata(&mut self, key: &str, value: &str) -> Result<()> { + self.ensure_persisted().await?; + self.service + .set_metadata(&self.session_id, key, value) + .await + } } #[cfg(test)] |
