Skip to content

Show what a desktop alert is about and answer an approval from it - #377

Merged
n0rpan merged 13 commits into
mainfrom
desktop/native-notification-actions
Dec 3, 2026
Merged

n0rpan merged 13 commits into
mainfrom
desktop/native-notification-actions

Conversation

@n0rpan

@n0rpan n0rpan commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

A desktop alert said only " · Approval needed" and, with titles on, the thread title. This adds what the alert is about, lets an approval be answered from the notification, and makes saved alert settings come back exactly.

What changes

More in the alert. Change::Notification gains an optional detail line (additive; older clients ignore it, older hosts omit it). The host fills it with:

  • approval: the request's title and its command, or the first line of its detail;
  • question: the first question;
  • failed: the turn's error text;
  • finished: the last assistant message of that turn.

It is one line, at most 240 characters, with control characters removed. The desktop shows it under the thread title only when the new Include request and result details switch is on. The switch is off by default, like Include thread titles. Phone push payloads are unchanged and do not carry the detail.

Allow once / Deny on the notification. With the new Allow once or deny from the notification switch on (off by default, like the phone's opt-in in #367), an approval alert offers the two buttons when the host proved the exact pair (lock_screen from #344). The notification carries an optional approval reference: the request id and the pair, never the token. Each request gets its own alert; a newer approval on the thread, or the host no longer reporting the thread as waiting, closes the older one. On a click the desktop subscribes through the pairing the alert came from, finds that exact request on that thread in the host's snapshot, and sends the snapshot's token and the index from the snapshot's validated pair, without opening the window. Each alert answers at most once. If the request is gone, the host is unpaired, the switch was turned off, or the answer fails or gets no reply in 30 seconds, nothing is approved and the conversation opens instead. Approval and question alerts no longer expire after ten seconds on Linux.

Saved settings. Every switch survives a save and a restart for every combination of values. A settings file that exists but cannot be parsed is renamed to notifications.json.invalid before defaults are used; before, it silently became defaults and the next save overwrote it.

Verification

  • cargo fmt --check, cargo clippy -p ox-desk-core -p ox-host -p ox-host-web -p ox-desktop --all-targets -- -D warnings, and ox-host-protocol --check on the generated contract, on Linux x86_64 with Rust 1.100.0.
  • Tests on Linux x86_64: ox-desk-core (two process tests pass only outside the local sandbox), ox-desktop (174 passed), ox-host-web --features server,client --lib (204 passed, including the untouched push privacy tests). These full runs were before main was merged in; after the merge the notification, projection, catalog and protocol tests and clippy were re-run.
  • New tests cover: the additive wire field; the detail text for each kind; the approval reference set only for a proven pair and delivered to a catalog-only client without the asks; per-request alerts that supersede and resolve; all 512 setting combinations through a real write and load; older settings files; a missing and an invalid settings file; one answer per alert; each button's exact index; and, against a fake host, that an answer is sent only when the snapshot holds that exact request with a valid pair, with the snapshot's token and index, and that only the reply to its own request ends the exchange; and that the detail text is in no push payload.

Not verified

  • A click on a real notification daemon, and an answer round trip against a live host. The host side of a tokened answer_ask from a fresh subscribed connection is the existing path the replica uses.
  • The non-Linux branch. It uses SystemNotificationAction and response.action_id as gpui 0.3.12 declares them; it was not built or run on macOS here, and whether macOS renders the buttons is unknown.
  • ox-host tests were not run locally; only its clippy.

Checked against main at 7f33f06. The branch has #374 merged in, because both change the lines that pick Failed or Finished; until #374 lands, this diff also shows its changes.

🤖 Generated with Claude Code

n0rpan and others added 9 commits December 3, 2026 10:46
Add an optional host-authoritative LockScreenDecisions pair to Ask and AskView, with an omitted-on-None wire field. The host sets it only for a questionless stock Claude tool request or a Codex Command/Files request whose machine decisions are exactly one literal accept and one literal decline. Projection and the paired replica reject anything other than exactly two distinct in-bounds decisions with no questions, so a third choice cannot inherit the pair. UX, push payloads and action dispatch are unchanged.
"Turn failed" came from the transcript's sticky error banner, so a turn that completed or was stopped while an unrelated request or an older turn left an error still raised a failure alert. Decide from the outcome recorded for the finished turn instead.

A child thread's failed turn is delivered to its parent agent as a tool result, and a worker that reports to a parent agent likewise hands its result to the agent. Neither raises a failure alert now; the parent's own turn outcome is what the operator hears about. Host-raised synthetic worker notices are unchanged, and whether such threads raise Finished is unchanged.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
Desktop alerts named only the host and the event, so an approval or a
finished turn said nothing about what it concerned. The host now fills an
additive, bounded `detail` on each notification change: the approval's
title and command or first line, the question's text, the turn's error,
or the end of the last assistant message. The desktop shows it under the
thread title only when "Include request and result details" is on. That
is off by default, like thread titles, because these texts can carry
commands and replies onto a lock screen. Phone push payloads never carry
the detail.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
Saved settings were read with an unwrap_or_default: a notifications file
that existed but did not parse silently became the defaults, and the next
toggle overwrote what the user had written. A missing file now means the
defaults; an existing file that cannot be read or parsed is renamed to
notifications.json.invalid first, so its content survives. Adds the
persisted `actions` flag (off by default) that the next change uses.

Tests cover every combination of the nine saved flags through a real
write and load, files written before the newer keys, a missing file and
an invalid one.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
An approval alert could only open the conversation, so allowing a
simple command meant opening a window and finding the request. When the
host proves an exact allow-once and deny pair for a sole pending
approval, the alert now offers "Allow once" and "Deny" (opt-in, under
"Allow once or deny from the notification", off by default). A button
sends the existing answer through a connection of its own, with the
approval token the host issued, and closes the alert. A missing pairing,
an offline host or a refused answer opens the conversation exactly as a
plain click does.

Each alert takes its approval once, so a second click answers nothing.
Approval and question alerts no longer expire on Linux, so the buttons
stay until used. Non-Linux buttons go through gpui's system notification
actions; they are not verified on macOS from this machine.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
Both switches are off by default because their text can reach a lock
screen; the guide now says what each one shows and when buttons appear.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
An answer sent from a notification waited on the host with no read timeout, so a host that stopped replying would have held the alert open with nothing happening. The exchange now gives up after 30 seconds, and the caller opens the conversation as it does for any failed answer.

The exchange is split from the connection so a fake host can prove it: one subscribe, one answer carrying the host's token and the exact decision index, and only the reply to its own request ends it.

An alert with details on but nothing to say no longer adds an empty line to its body.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
# Conflicts:
#	desktop/ox-desk-core/src/store/projection.rs
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T17:25:43.944110Z f54102e Draft marked ready
🔒 Security Review ✅ Completed 2026-12-03T17:27:36.727407Z f54102e Draft marked ready

Security findings

Advisory findings (1)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82aa10d94d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

Coordination with #371: this PR adds detail to the host notification for desktop, while #371 adds a durable FCM route for the same Finished/Failed events. Please run one combined regression with a nonempty detail: confirm it reaches the opted-in desktop alert but is absent from the serialized FCM relay payload. The current #377 push fixture sets detail to an empty string, so it doesn’t exercise that boundary.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 82aa10d94d

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

n0rpan and others added 2 commits December 3, 2026 14:37
…to its request

The buttons never appeared in production: the desktop looked for the
approval's ask in the same catalog delta, but the host filters asks out of
the catalog stream, so the lookup always found nothing. The tests had used a
synthetic delta that included the asks, so they passed.

A notification now carries the approval it is about as an additive
`approval` reference: the request id and the host-validated allow-once and
deny indices, with no token. The desktop reads the delta's notification
directly. Each approval alert has a tag that includes its request id, so a
second request on the same thread no longer replaces the first alert's
answer. A new approval closes the thread's earlier approval alerts, and a
`Waiting` event closes the approval alerts of threads the host no longer
reports as waiting.

A button press now subscribes, reads the host's snapshot, and answers the
exact request id and thread with that request's token and the index from
the host's own validated pair. Nothing is sent when the snapshot does not
hold that request with a pair, and the conversation opens instead, as before.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
…-actions

# Conflicts:
#	desktop/ox-desk-core/src/store/projection.rs
@n0rpan

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

Re the #371 coordination request: ce84195 adds push_payloads_never_carry_the_alert_detail. It feeds Finished, Failed and Approval notification frames with a distinctive non-empty detail and an approval reference, and asserts the text is in none of the Web Push payload bytes or the native alert fields. It does not serialize the relay's FCM request itself (that needs the queue harness in #371), so the combined FCM check still has to run on top of #371.

@n0rpan

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

/queue ce84195

@n0rpan

n0rpan commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

In line to merge. Commit f54102e is reviewed with nothing blocking; it has entered the merge queue.

@n0rpan

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex security review

Asked for by the maintainer’s queue request, for commit ce84195.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce84195726

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

An approval alert named only the request id, and its "Allow once" was
sent with whatever token the host then held for that id. A runtime can
resolve a request and ask again under the same id on the same thread.
The host mints a fresh token for that ask, but no new notification is
sent because the id did not change, so the old alert's button would have
approved the replacement.

The host now sends, with each approval alert, the opaque reference of the
token it minted for that ask generation, derived by
ox_host_web::approval_ref::ask_ref, the same derivation the push path
uses. An alert whose ask, thread or token cannot be found goes out
without buttons. The desktop shows buttons only for a reference it can
validate, tags alerts by their reference, and sends an answer only when
the live ask's token produces the alert's reference. Otherwise it sends
nothing and reports that the approval is no longer waiting.

The reference field is additive and defaults to empty, so an older host's
alerts still parse and show no buttons. The generated contract is
regenerated to match.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
@n0rpan

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

/queue a55e421

@n0rpan

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex security review

Asked for by the maintainer’s queue request, for commit a55e421.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: a55e421512

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Main now carries the terminal-only failed alert (#374). Keep this
branch's version of the finished and failed alert, which adds the
detail line to the same decision.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
@n0rpan

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

/queue f54102e

@n0rpan

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex security review

Asked for by the maintainer’s queue request, for commit f54102e.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: f54102e28a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@n0rpan

n0rpan commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex security review

Asked again for commit f54102e: the security row of the review summary still names 82aa10d, whose three findings are fixed and resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: f54102e28a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@n0rpan
n0rpan marked this pull request as draft December 3, 2026 17:22
@n0rpan
n0rpan marked this pull request as ready for review December 3, 2026 17:23
@n0rpan
n0rpan added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit 5ddfae1 Dec 3, 2026
106 of 112 checks passed
@n0rpan
n0rpan deleted the desktop/native-notification-actions branch December 3, 2026 18:22
n0rpan added a commit that referenced this pull request Dec 3, 2026
Main now carries the alert details and approval actions (#377). Keep the
approval reference bound before any alert is held, and regenerate the
protocol contract.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant