Skip to content

Commit e70f345

Browse files
committed
feat(gpui): offer End and Recover for remote workspace threads
A start that fails with a lifecycle code, such as session_ended or session_active, leaves a prompt in a GPUI global holding buzz-remote-sessions' RecoveryPrompts. A start or recovery that works clears it. Prompts live in memory only. The thread banner shows each prompt in its thread with the desktop's buttons: Recover from checkpoint (unless the provider said there is none) and Start fresh, End session, or Check session while it ends. End's reply state picks the next banner. When the agent's provider cannot end and recover sessions, the banner offers only Dismiss. Signed-off-by: Tee8z <[email protected]>
1 parent 1b512a9 commit e70f345

2 files changed

Lines changed: 481 additions & 9 deletions

File tree

‎apps/buzz-gpui/crates/app/src/agent_plugins/remote_workspace/mod.rs‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! Built only with the `voltage-sandbox` feature.
66
77
pub mod config;
8+
mod recovery;
89
mod settings;
910

1011
use crate::agent_activity::local::WorkOutcome;
@@ -31,7 +32,9 @@ const START: Duration = Duration::from_secs(11 * 60);
3132
pub fn init(cx: &mut App) {
3233
if let Err(error) = crate::agents2::register_type(PLUGIN, Arc::new(RemoteWorkspace), cx) {
3334
tracing::error!(%error, "could not register the remote workspace agent type");
35+
return;
3436
}
37+
recovery::init(cx);
3538
}
3639

3740
struct RemoteWorkspace;
@@ -93,15 +96,17 @@ impl AgentType for RemoteWorkspace {
9396
let Some(relay) = relay else {
9497
return Task::ready(Err("The agent is not running in a community".into()));
9598
};
96-
let runtime = crate::runtime::Runtime::handle(cx);
97-
let started = runtime.spawn(deliver(delivery, relay));
98-
cx.background_spawn(async move {
99-
match started.await {
100-
Ok(Ok(Some((_, Err(error))))) => Err(error.message),
101-
Ok(Ok(_)) => Ok(()),
102-
Ok(Err(error)) => Err(error),
103-
Err(_) => Err("The start was cancelled".into()),
104-
}
99+
let name = delivery.agent.name.clone();
100+
let started = crate::runtime::Runtime::handle(cx).spawn(deliver(delivery, relay));
101+
cx.spawn(async move |cx| {
102+
let sent = started
103+
.await
104+
.map_err(|_| "The start was cancelled".to_string())??;
105+
let Some(sent) = sent else {
106+
return Ok(());
107+
};
108+
cx.update(|cx| recovery::started(&sent, &name, cx));
109+
sent.1.map_err(|error| error.message)
105110
})
106111
}
107112

0 commit comments

Comments
 (0)