pub struct Chat { /* private fields */ }Implementations§
Source§impl Chat
impl Chat
pub fn new(state: PathBuf, executable: PathBuf) -> Self
Sourcepub fn discover(state: PathBuf) -> Self
pub fn discover(state: PathBuf) -> Self
Desktop discovers the packaged CLI when a session needs it, not at app startup.
Sourcepub fn close(&self) -> impl Future<Output = ()> + use<>
pub fn close(&self) -> impl Future<Output = ()> + use<>
Stop accepting work, commit durable Stop in SQLite before cancelling owned turns, wait for their saved outcomes and ownership release, and drain all warm ACP children. Verify Runs already admitted remain independent of Chat.
Sourcepub async fn reconcile_interrupted(&self) -> Result<Vec<SessionId>, String>
pub async fn reconcile_interrupted(&self) -> Result<Vec<SessionId>, String>
Reconcile exact turn ownership after a process dies without a final change hint. Returns only sessions this observer actually reconciled.
Sourcepub async fn default_target(
&self,
worktree: &Path,
) -> Result<Option<ChatTarget>, String>
pub async fn default_target( &self, worktree: &Path, ) -> Result<Option<ChatTarget>, String>
The starting target for a new session: the worktree’s last available choice, or the first ready ACP Chat agent, or the first available direct HTTP provider model.
pub async fn default_target_for( &self, worktree: &Path, branch: Option<&Place>, ) -> Result<Option<ChatTarget>, String>
Sourcepub async fn create(
&self,
worktree: &Path,
selection: Option<ChatTarget>,
) -> Result<Session, String>
pub async fn create( &self, worktree: &Path, selection: Option<ChatTarget>, ) -> Result<Session, String>
Persist an empty session, with no target unless one is explicitly selected.
Sourcepub async fn create_for_branch(
&self,
workspace: &Path,
branch: Option<&Place>,
selection: Option<ChatTarget>,
) -> Result<Session, String>
pub async fn create_for_branch( &self, workspace: &Path, branch: Option<&Place>, selection: Option<ChatTarget>, ) -> Result<Session, String>
Create only on the checkout the person selected, not a branch switched in meanwhile.
Sourcepub async fn branches(
&self,
launch: Option<&Path>,
) -> Result<BranchListing, String>
pub async fn branches( &self, launch: Option<&Path>, ) -> Result<BranchListing, String>
Discover the live choices used by the Chat branch picker, independently of Verify search.
Sourcepub async fn set_worktree(
&self,
id: &SessionId,
worktree: &Path,
launch: Option<&Path>,
) -> Result<Session, MoveError>
pub async fn set_worktree( &self, id: &SessionId, worktree: &Path, launch: Option<&Path>, ) -> Result<Session, MoveError>
Rebind the saved conversation to a live choice, excluding active turns in any process. Evicts any warm ACP child owned by this process for the moved session.
Sourcepub async fn list(
&self,
worktree: Option<&Path>,
query: Option<&str>,
) -> Result<Vec<Session>, String>
pub async fn list( &self, worktree: Option<&Path>, query: Option<&str>, ) -> Result<Vec<Session>, String>
Keep the catalog’s activity order while matching every word across its displayed labels.
Find a conversation by its former checkout, including a workspace within the worktree.
Sourcepub async fn latest_for_branch(
&self,
branch: &Place,
) -> Result<Option<Session>, String>
pub async fn latest_for_branch( &self, branch: &Place, ) -> Result<Option<Session>, String>
The most recently active saved session on this branch, even if its checkout is gone.
Prefer the newest usable session for branch navigation. If the checkout moved and none can work on it, keep the newest saved conversation reachable with its diagnostic.
Sourcepub async fn latest_available_for_branch(
&self,
branch: &Place,
) -> Result<Option<Session>, String>
pub async fn latest_available_for_branch( &self, branch: &Place, ) -> Result<Option<Session>, String>
The latest session whose exact checkout can be worked on now.
Sourcepub async fn current_worktree(
&self,
branch: &Place,
) -> Result<Option<PathBuf>, String>
pub async fn current_worktree( &self, branch: &Place, ) -> Result<Option<PathBuf>, String>
The oldest usable checkout anchors Current when there is no Verify workspace. Activity in a newer session must not redirect scans, edits or tools.
Sourcepub async fn set_view(
&self,
id: &SessionId,
view: SessionView,
) -> Result<Session, String>
pub async fn set_view( &self, id: &SessionId, view: SessionView, ) -> Result<Session, String>
Save a view without changing the session’s activity order or requiring a live checkout.
Sourcepub async fn mark_seen(&self, id: &SessionId) -> Result<(), String>
pub async fn mark_seen(&self, id: &SessionId) -> Result<(), String>
Acknowledge the latest settled outcome without changing the session’s activity order. A turn still running will become unseen when it settles, even if this is called now.
Sourcepub fn transcript_size(&self, id: &SessionId) -> Option<u64>
pub fn transcript_size(&self, id: &SessionId) -> Option<u64>
Chat records are append-only. Readers can detect a missed hint without parsing a
transcript, with None covering a session that has not yet accepted a turn.
Sourcepub async fn watermark(
&self,
id: &SessionId,
) -> Result<Option<ChatWatermark>, String>
pub async fn watermark( &self, id: &SessionId, ) -> Result<Option<ChatWatermark>, String>
Lightweight SQLite watermark across (chat_sessions, chat_active_turns, chat_pending_permissions) tracked by Desktop watch.rs alongside transcript_size.
Sourcepub async fn evict_warm_if_stale(&self, id: &SessionId)
pub async fn evict_warm_if_stale(&self, id: &SessionId)
Evict any local warm ACP child whose committed acp_binding.generation has advanced
(called on Change::SessionInvalidated so another process’s move/switch terminates stale
local children promptly).
Sourcepub async fn open(&self, id: &SessionId) -> Result<View, String>
pub async fn open(&self, id: &SessionId) -> Result<View, String>
The model/agent’s streamed text, rich ACP blocks, live permissions, and Run cards.
Sourcepub async fn set_target(
&self,
id: &SessionId,
selection: ChatTarget,
) -> Result<Session, String>
pub async fn set_target( &self, id: &SessionId, selection: ChatTarget, ) -> Result<Session, String>
Save a Chat target for the next turn without adding a message. An accepted turn keeps the target it started with, even if the user changes the picker while it streams.
Sourcepub async fn respond_permission(
&self,
id: &SessionId,
permission_id: &str,
option_id: &str,
) -> Result<bool, String>
pub async fn respond_permission( &self, id: &SessionId, permission_id: &str, option_id: &str, ) -> Result<bool, String>
Respond to a pending ACP permission card (PENDING -> SELECTED in one IMMEDIATE
SQLite transaction) and wake any local owning turn immediately.
Sourcepub async fn trust_workspace(
&self,
worktree: &Path,
agent_id: &AgentId,
) -> Result<TrustRecord, String>
pub async fn trust_workspace( &self, worktree: &Path, agent_id: &AgentId, ) -> Result<TrustRecord, String>
Record explicit machine-local Workspace Trust for an ACP agent on a worktree/repo scope.
Sourcepub fn list_trust(&self) -> Result<Vec<TrustRecord>, String>
pub fn list_trust(&self) -> Result<Vec<TrustRecord>, String>
List all saved machine-local ACP Workspace Trust records.
Sourcepub async fn revoke_trust(
&self,
agent_id: &AgentId,
scope: &TrustScope,
) -> Result<bool, String>
pub async fn revoke_trust( &self, agent_id: &AgentId, scope: &TrustScope, ) -> Result<bool, String>
Revoke a saved Workspace Trust record and terminate any matching warm ACP children.
Sourcepub async fn send(
&self,
id: &SessionId,
text: String,
selection: Option<ChatTarget>,
) -> Result<(), SendError>
pub async fn send( &self, id: &SessionId, text: String, selection: Option<ChatTarget>, ) -> Result<(), SendError>
Start a durable turn and return as soon as it has an accepted user message. The recorder
notifies SessionInvalidated(id) as text, tool outcomes, permissions and Run references arrive.
Sourcepub async fn stop(&self, id: &SessionId) -> Result<bool, String>
pub async fn stop(&self, id: &SessionId) -> Result<bool, String>
Stop the active turn, even if another app owns it. Accepted Verify Runs are independent.
Always commits the SQLite Stop transaction (stop_requested = true + permission
cancellation) BEFORE firing the in-memory CancellationToken.
Sourcepub async fn stop_running(&self) -> Result<(), StopRunningError>
pub async fn stop_running(&self) -> Result<(), StopRunningError>
The desktop’s quit prompt names every running Chat. Deliver the same Stop to those turns even when another process owns them, before the desktop window closes.