Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Desktop starts the packaged OX session host on first use. Close and reopen the w

The phone and desktop show live sessions across projects. The phone groups consecutive tool calls into one collapsed row. Tap the count, then a specific call, to read its command and output. Assistant replies render headings, lists, tables and code inline. Start a thread on either device, then open its row on the other to follow the same reply, answer an approval, steer a worker or press Stop. The session settings use the runtime’s confirmed mode, including YOLO. Your selection on one screen stays independent of what you open on the other. Device revocation and disabling remote access take effect on open connections. [Tailscale Serve](https://tailscale.com/kb/1312/serve)

When OX Desktop is in the background, a session alert names the host. Click it to open the thread on that host. Open **Settings → Notifications** to choose alerts for approvals, questions, finished turns, completed Codex goals and failures. If you enable both turn and goal alerts, a turn that completes a goal sends one goal alert. The switches apply to this computer. Turn on **Include thread titles** if you want them in OS notifications. On Wayland, clicking an alert selects the thread, and the compositor determines whether to switch to the OX workspace.
When OX Desktop is in the background, a session alert names the host. Click it to open the thread on that host. Open **Settings → Notifications** to choose alerts for approvals, questions, finished turns, completed Codex goals and failures. If you enable both turn and goal alerts, a turn that completes a goal sends one goal alert. The switches apply to this computer. Turn on **Include thread titles** if you want them in OS notifications. Turn on **Include request and result details** to show what an alert is about, and **Allow once or deny from the notification** to answer an approval from its alert; the buttons appear only for a request that offers exactly “allow once” and “deny”. On Wayland, clicking an alert selects the thread, and the compositor determines whether to switch to the OX workspace.

In OX Mobile, **Home** lists the host's projects and recent threads. **Host settings** manages accounts, credentials, providers, and advanced configuration. Run `ox help settings` for the same map from the CLI. [OX Mobile guide](ox-mobile/README.md#home-and-projects)

Expand Down
105 changes: 105 additions & 0 deletions desktop/ox-desk-core/src/host_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,15 @@ pub enum Change {
event: NotificationKind,
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
goal_reached: bool,
/// One bounded line saying what the alert is about: the request, the
/// question, the error, or the end of the reply. Empty when the host has
/// nothing to say. Phone push payloads never carry it.
#[serde(default, skip_serializing_if = "String::is_empty")]
detail: String,
/// The approval this alert is about, when the host proved its pair. The
/// alert answers exactly this request; it carries no token.
#[serde(default, skip_serializing_if = "Option::is_none")]
approval: Option<ApprovalRef>,
},
Session {
session: SessionView,
Expand Down Expand Up @@ -844,6 +853,23 @@ pub enum Change {
},
}

/// The approval an alert answers: the host's request id and the exact decision
/// indices it proved. The approval token is never sent in a notification; a
/// client fetches it from the catalog when the user presses a button.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct ApprovalRef {
pub id: RequestId,
pub decisions: crate::asks::LockScreenDecisions,
/// The opaque reference of the token the host minted for this ask generation
/// (`ox_host_web::approval_ref::ask_ref`). It is never the token itself. The
/// host fills it before it sends the notification; the projection that builds
/// the notification does not know tokens and leaves it empty. A client that
/// finds it empty or malformed shows the alert without buttons.
#[serde(default)]
pub reference: String,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "snake_case")]
Expand All @@ -854,6 +880,83 @@ pub enum NotificationKind {
Question,
}

#[cfg(test)]
#[test]
fn detail_is_additive_to_the_notification_change() {
let legacy = serde_json::json!({"kind":"notification","thread":"t","title":"Example","event":"approval"});
let parsed: Change = serde_json::from_value(legacy.clone()).unwrap();
assert!(matches!(&parsed, Change::Notification { detail, .. } if detail.is_empty()));
assert_eq!(serde_json::to_value(parsed).unwrap(), legacy);
let next = serde_json::to_value(Change::Notification {
thread: "t".into(),
title: "Example".into(),
event: NotificationKind::Approval,
goal_reached: false,
detail: "Run cargo test".into(),
approval: None,
})
.unwrap();
assert_eq!(next["detail"], "Run cargo test");
assert!(next.get("goal_reached").is_none());
}

#[cfg(test)]
#[test]
fn approval_is_additive_to_the_notification_change() {
let legacy = serde_json::json!({"kind":"notification","thread":"t","title":"Example","event":"approval"});
let parsed: Change = serde_json::from_value(legacy.clone()).unwrap();
assert!(matches!(
&parsed,
Change::Notification { approval: None, .. }
));
assert_eq!(serde_json::to_value(parsed).unwrap(), legacy);
let next = serde_json::to_value(Change::Notification {
thread: "t".into(),
title: "Example".into(),
event: NotificationKind::Approval,
goal_reached: false,
detail: String::new(),
approval: Some(ApprovalRef {
id: RequestId::Number(7),
decisions: crate::asks::LockScreenDecisions {
allow_once: 0,
deny: 1,
},
reference: "r".repeat(43),
}),
})
.unwrap();
assert_eq!(
next["approval"],
serde_json::json!({
"id": 7,
"decisions": {"allow_once": 0, "deny": 1},
"reference": "r".repeat(43)
})
);
// An older host sends no reference: the alert still parses, with none.
let older = serde_json::json!({
"kind": "notification", "thread": "t", "title": "Example", "event": "approval",
"approval": {"id": 7, "decisions": {"allow_once": 0, "deny": 1}}
});
let Change::Notification { approval, .. } = serde_json::from_value(older).unwrap() else {
panic!("expected a notification");
};
assert_eq!(approval.unwrap().reference, "");
assert!(
!next.to_string().contains("token"),
"a notification never carries an approval token: {next}"
);
let back: Change = serde_json::from_value(next).unwrap();
assert!(matches!(
back,
Change::Notification {
approval: Some(_),
..
}
));
}

#[cfg(test)]
#[test]
fn goal_reached_is_additive_to_the_v1_finished_notification() {
Expand Down Expand Up @@ -881,6 +984,8 @@ fn goal_reached_is_additive_to_the_v1_finished_notification() {
title: "Example".into(),
event: NotificationKind::Finished,
goal_reached: true,
detail: String::new(),
approval: None,
})
.unwrap();
assert_eq!(next["goal_reached"], true);
Expand Down
43 changes: 42 additions & 1 deletion desktop/ox-desk-core/src/live_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! observe identical semantics. It has no GPUI, socket or thread dependency:
//! the caller keeps the connection, its reader loop and its reconnection policy.
use crate::host_protocol::{
AskView, Change, Cursor, NotificationKind, Scope, ScopeState, SessionView,
ApprovalRef, AskView, Change, Cursor, NotificationKind, Scope, ScopeState, SessionView,
};
use serde_json::Value;
use std::collections::HashSet;
Expand Down Expand Up @@ -36,6 +36,10 @@ pub struct NotificationNotice {
pub title: String,
pub kind: NotificationKind,
pub goal_reached: bool,
/// What the alert is about, as the host wrote it; empty when it said nothing.
pub detail: String,
/// The approval this alert is about, as the host sent it with the change.
pub approval: Option<ApprovalRef>,
}

/// Decode a `Server::Snapshot` and emit its events in protocol order.
Expand Down Expand Up @@ -91,13 +95,17 @@ pub fn decode_delta<E>(
title,
event,
goal_reached,
detail,
approval,
} => emit(LiveCatalogEvent::Notice(NotificationNotice {
cursor: cursor.clone(),
scope: scope.clone(),
thread,
title,
kind: event,
goal_reached,
detail,
approval,
}))?,
Change::Sessions { sessions } => {
emit(LiveCatalogEvent::Replace(scope.clone(), sessions))?
Expand Down Expand Up @@ -396,6 +404,8 @@ mod tests {
title: "Done".into(),
event: NotificationKind::Finished,
goal_reached: true,
detail: "All green".into(),
approval: None,
}],
);
assert_eq!(
Expand All @@ -407,10 +417,41 @@ mod tests {
title: "Done".into(),
kind: NotificationKind::Finished,
goal_reached: true,
detail: "All green".into(),
approval: None,
})]
);
}

#[test]
fn delta_notification_passes_its_approval_reference_through_unchanged() {
use crate::{asks::LockScreenDecisions, runtime::RequestId};
let approval = ApprovalRef {
id: RequestId::Number(7),
decisions: LockScreenDecisions {
allow_once: 0,
deny: 1,
},
reference: "r".repeat(43),
};
let events = collect_delta(
scope("/a"),
cursor(1),
vec![Change::Notification {
thread: "t".into(),
title: "Run".into(),
event: NotificationKind::Approval,
goal_reached: false,
detail: "Run cargo test".into(),
approval: Some(approval.clone()),
}],
);
let [LiveCatalogEvent::Notice(notice)] = events.as_slice() else {
panic!("expected one notice, got {events:?}");
};
assert_eq!(notice.approval, Some(approval));
}

#[test]
fn an_emit_error_stops_decoding_at_once() {
let mut emitted = 0;
Expand Down
Loading