Skip to content

Add opt-in receive confirmation to omdrop-core - #123

Draft
marselnenaj wants to merge 3 commits into
netmojo-systems:mainfrom
marselnenaj:feat/receive-approval
Draft

marselnenaj wants to merge 3 commits into
netmojo-systems:mainfrom
marselnenaj:feat/receive-approval

Conversation

@marselnenaj

@marselnenaj marselnenaj commented Nov 8, 2026 •

Copy link
Copy Markdown

Incoming files and links are currently accepted automatically while Omdrop is visible. This adds opt-in Ask First to omdrop-core, with Accept and Decline before a transfer is accepted. Auto-Accept remains the default.

Choose either mode in the panel or with omdrop receive-mode ask|auto. The setting is saved atomically and read by the running Rust receiver. The Python fallback keeps its existing behavior and does not display this control.

Receiver and desktop behavior

  • On Omarchy, use omarchy-notification-send and its native action buttons. Its default omarchy-action identity remains visible under Do Not Disturb. Other desktops retain notify-send --wait; libnotify is an optional dependency for that fallback.
  • Native buttons call omdrop receive-answer TOKEN accept|decline. A fresh 128-bit token addresses one socket in a private, user-owned runtime directory. Replies cannot create requests; normal completion removes the socket, and the service cleans up the directory on stop. Late clicks cannot approve another transfer.
  • Decline, invalid answers, helper failures, and the 30-second deadline refuse the request. Closing a native notification now refuses it promptly. A daemon-scoped NotificationClosed subscription is established before display; a 500 ms grace period lets an already-launched Accept/Decline action finish before the request is rejected. Closures of unrelated notifications and forged signals from another sender do not match. A sending connection that closes releases its prompt early.
  • Only one prompt may be pending. Its connection is protected from idle-connection eviction; concurrent requests receive 503 instead of queuing prompts. Other idle connections remain evictable.
  • Contacts Only checks precede the prompt. Explicit approval authorizes one upload on the same TLS connection. Direct uploads and uploads following an accepted link are refused in Ask First mode. An automatically accepted Ask does not carry approval across a switch into Ask First.
  • Ask First refuses mixed files/links Asks before prompting or writing. Link prompts show destination hosts; file prompts show the count, reported aggregate size (or unknown), and a bounded name preview.
  • Terminal changes refresh the panel immediately through the wrapper.

Peer text is bounded, escaped, and passed as separate arguments without shell evaluation. A pending decision has a 30-second deadline and ends earlier on disconnect; closing the notification can take up to two additional seconds. Existing connection, archive-member, byte-budget and free-space limits remain in force. Reply tokens grant no access outside the receiver's private runtime directory.

Core is 0.1.13, the plugin minimum core version is 0.1.13, and the updated package revision is 3. The service grants write access only to the dedicated reply directory in addition to its existing writable paths.

Validation

  • cargo test --locked --workspace: 539 passed, 1 existing ignored.
  • cargo clippy --locked --workspace --all-targets -- -D warnings: passed.
  • cargo fmt --all --check and git diff --check: passed.
  • Python baseline on unmodified main: 417 passed.
  • Updated Python suite: 418 passed, including receive-mode panel refresh. Both suites used isolated runtime directories.
  • New regressions cover the two-silent-dial attack at a connection cap of 2, same-connection Auto-Accept → Ask First, mixed transfers, early sender cancellation, native reply cleanup and replay, invalid tokens, count/size/host disclosure, and the generic notification fallback. Additional regressions verify immediate dismissal, acceptance after the toast closes, and daemon/request-id scoping on an isolated D-Bus.

Manual desktop integration used a temporary Rust receiver on localhost only and the live Omarchy notification service, whose delivery rules match stock Delivery.js. With Do Not Disturb enabled, the native request appeared in the live notification store as omarchy-action; nothing was saved before approval. Running the displayed receive-answer action command produced Ask 200 and Upload 200 with the exact synthetic payload. A late reply failed. The original DND state was restored. A follow-up loopback probe closed the actual Omarchy notification through its D-Bus API: Ask returned 403 in 0.559 seconds, no file was stored, and a late acceptance failed. The Accept/upload probe also passed after this change. These synthetic checks exercise the native action command and notification delivery, not a physical GUI click or Apple timeout compatibility.

The installed, packaged receiver was then checked through localhost under its real systemd service restrictions (including the private runtime directory). With DND enabled, its prompt stayed live; a second concurrent Ask returned 503. Closing the first notification returned 403 in 0.552 seconds and revoked late replies. A valid Accept command delivered 100 ms after notification closure still returned 200, exercising the action-command grace period. An unanswered request returned 403 after 30.038 seconds and also revoked late replies. These checks sent no Upload body and saved no file in Downloads. DND was restored afterwards.

GitHub-hosted Tests and Core (Rust) runs for this fork commit are currently action_required, awaiting maintainer approval. They have not executed; the passing results above are local checks. The re-review label workflow was skipped.

These changes address the five findings in the review, plus the item-summary and sender-cancellation suggestions.

Hardware and remaining validation

Development machine: M1 MacBook Air, BCM4378 (14e4:4425), kernel 7.1.12-2-20261017.20-sep-ARCH, brcmfmac-awdl-dkms 0.10.5-1, Omarchy 4.5.0-3, Qt 6.12.0, Quickshell 0.3.2.r7.g2b4501a-1. Firmware: BCM4378/3, 18.20.383.15.7.8.150 (FWID 01-b37727a5), recorded during initial development.

The revised Rust receiver is now provisioned on the development machine for Apple-device testing: local omdrop-core 0.1.13-3.1 test package, debug profile, commit 7303c73. Binaries and the polkit policy were installed through pacman at their fixed root-owned package paths; no checkout-built root helper was executed as root. Ask First is enabled; visibility is bounded by a 15-minute test window. The user has now tried Accept and Decline from an iPhone and reports that both appear to work. The live receiver journal confirms a refused Ask (403), plus an accepted Ask (200) followed by Upload 200 and a saved file. Another accepted Ask did not have a subsequent upload; these observations establish a successful transfer, not a success-rate or timeout claim. The sender reports only the generic model string iPhone; exact model and iOS version remain to be confirmed. These phone trials used the preceding 0.1.13-2.1 test build; dismissal handling in 0.1.13-3.1 still needs a phone retest. Automated tests and the earlier synthetic desktop probe did not drive the live radio.

Draft pending real iPhone/Mac validation: Accept, Decline, dismissal, timeout, links, Auto-Accept, native button clicks, DND, sender cancellation, and two simultaneous senders. Also record each device/OS, how long it waits for Ask, and its presentation of 403 versus 503. Synthetic TLS clients establish enforcement but do not establish Apple timeout compatibility. Desktop-specific toast sizing is outside this PR.

@netmojo

netmojo commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the draft PR. "Ask First" is a useful feature, and the core of it holds up: approval is checked again on /Upload, Contacts Only runs before the prompt, a bad setting fails closed, and notify-send gets the peer's text as separate arguments. Leaving the Python receiver alone is the right call. Two things are worth settling before you mark it ready: how the prompt behaves under Omarchy's "Do Not Disturb" mode, and a connection that can be closed while its prompt is on screen. Neither is a hole in the approval check itself. Three smaller fixes and the version bumps follow. Each finding below gives the file and line it refers to at 125800b.

Before marking ready

1. With Do Not Disturb on, every request is declined without being shown

The notification uses --app-name=Omdrop and critical urgency. Omarchy's notification daemon (omarchy.notifications, Quickshell) lets only two kinds of notification through Do Not Disturb: app omarchy-action, or app notify-send at critical urgency (/usr/share/omarchy/shell/plugins/notifications/Delivery.js:11-15). Anything else is muted: the daemon files it into history and stops tracking it (Service.qml:602-605, 719-729). The user never sees the Accept button, and the sender is declined, at the latest when the 30-second timeout ends.

Choose the behaviour on purpose and test it on stock Omarchy:

  • Use omarchy-notification-send when it exists. It is the plugin's convention everywhere else (bin/omdrop, links.rs, identity.rs), it gets through Do Not Disturb, and the daemon draws its --action <label> <program> buttons. Its buttons run a command rather than reporting an action key, so the receiver needs a way to hear the answer: for example, an omdrop receive-answer <token> accept|decline command that writes to a private file under $XDG_RUNTIME_DIR/omdrop/, with a fresh random token for each request. Keep notify-send --wait for desktops that don't run Omarchy's shell.
  • Alternatively, when Do Not Disturb is on, refuse the request at once with a clear log line and say so in the README. Don't leave the sender waiting 30 seconds for a prompt nobody can see.

2. Anyone in range can close a prompting connection

set_waiting(id, true) runs at the top of the request loop (server.rs:784), and only upload() clears it (server.rs:1310). During the 30-second prompt, the /Ask connection is therefore the longest-waiting one, which makes it the first one admit() closes once the connection cap is reached (server.rs:644-664). The prompt stays on screen and keeps holding consent_prompt, so the sender's retry gets 503.

We reproduced it with a scratch test: approver sleeping 1.5 s, max_connections = 2, and two silent dials during the prompt:

WARNING root: 2 connections already open; closing the longest-waiting one, from ::1, ...
PROBE prompting Ask result after 2 silent dials: Err("client saw connection closed")
WARNING root: /Ask rejected: another receive request is pending
PROBE retry immediately after: 503

The defaults are 64 connections, 8 per peer, so in Everyone mode this takes about eight source addresses. Only one connection can prompt at a time, so it is safe to call self.server.set_waiting(self.id, false) before the approver runs. Please add the scenario above as a test.

Should fix

3. Approval from Auto-Accept carries over into Ask First

user_approved = true is set after every Ask that isn't a link (server.rs:1271), including Asks answered in Auto-Accept with no prompt. A scratch test confirms it: mode auto, /Ask returns 200, mode changed to ask, then /Upload on the same connection returns 200 and stores the file, with no prompt shown. This affects only a transfer already accepted before the switch; it is not a general way around Ask First. It does contradict the README, which says the choice applies immediately.

Either set the flag only when the approver returned true, or, if letting an already accepted transfer finish is intended, say so in the README. In both cases, test it on one connection: receive_mode_changes_apply_to_the_running_receiver opens a fresh connection for each request, so it misses this.

4. A mixed files-and-links Ask stores links the user never saw

approval::request shows the Files names and falls back to Items only when there are none. An Ask whose TransferType holds both links and files is handled as a link transfer (server.rs:1188, 1270). Accepting it stores the URLs from Items, which the prompt never showed, and refuses the upload of the file it did show. A scratch test with Files: [holiday.jpg] and Items: [https://unseen.example/x]:

PROBE mixed Ask: 200
PROBE stored after Ask: ["unseen.example-x.url"]
WARNING root: /Upload rejected: upload requires an accepted receive request
PROBE upload of the file the user saw: 403

A second, end-to-end test ran the real approval::request against a stand-in notify-send. The prompt body it received was Constructed sender and holiday.jpg, with no URL, and the Ask still stored a shortcut to the undisclosed link.

Build the prompt from what accepting the Ask will actually do. For a links Ask, list the link hosts. Alternatively, refuse an Ask that mixes both kinds in Ask First mode.

5. Terminal changes to the mode don't refresh the panel

receive-mode is missing from changes_panel in bin/omdrop (line 134). After omdrop receive-mode auto in a terminal, an open panel keeps showing ASK FIRST until its next poll, up to 10 seconds, while the receiver is already in Auto-Accept. Add it to the list. Changes made in the panel already refresh it.

Suggestions

  • Show the item count and total size in the prompt, not just the first three names: iPhone · 12 photos, 48 MB. That is the information a user needs to decide.
  • If the sender cancels or drops while the prompt is up, the notification stays for the rest of its 30 seconds, and other senders get 503 until then. Peeking at the socket during the wait (0 bytes or an error means the sender has gone) would let you close the prompt and release the lock early.

Hardware tests before marking ready

Your list (Accept, Decline, dismiss, timeout, links, Auto-Accept) covers the main paths. Please also record:

  • How long an iPhone and a Mac wait for the /Ask answer before giving up, and what each shows for 403 compared with 503.
  • Behaviour with Do Not Disturb on, under whichever design you choose for item 1.
  • Cancelling on the iPhone while the prompt is up.
  • Two senders at once: what the second one sees.

What we ran

  • Full workspace (cargo test --locked --workspace) at 125800b: 527 passed, 1 ignored, with clippy -D warnings and fmt --check clean, run in a network-isolated sandbox on aarch64 Linux (M1 Pro).
  • Scratch tests for items 2, 3, and 4 against the receiver's test fixture.
  • Separate TLS smoke tests of the receiver in that sandbox for items 3 and 4. For item 3, no prompt was shown and the file was written. For item 4, the prompt body the notifier received held only the file name.
  • Item 1: we evaluated the shipped daemon's filter with an Omdrop critical notification under Do Not Disturb (muted) against notify-send and omarchy-action (shown). We didn't turn on Do Not Disturb on a live desktop.
  • bin/omdrop: a wrapper fixture confirms visibility triggers one panel refresh and receive-mode none.

@marselnenaj

Copy link
Copy Markdown
Author

Thanks for the detailed review and reproductions. The five findings are addressed in da65fdf and 7303c73:

  1. DND: Omarchy now uses omarchy-notification-send with native actions and its default omarchy-action identity. Actions reply through a fresh, private, one-use Unix socket via omdrop receive-answer. Other desktops retain notify-send --wait.
  2. Connection eviction: the prompting connection is marked non-waiting before the approver runs. A regression reproduces the two-silent-dial scenario with max_connections = 2 and verifies the approved transfer survives.
  3. Mode switching: only explicit approval sets user_approved. A same-connection regression covers Auto-Accept Ask → switch to Ask First → Upload, which now receives 403.
  4. Mixed transfers: Ask First rejects mixed files/links before prompting or storing anything. Link previews use destination hosts; file previews include the count and reported total size, or “size unknown.”
  5. Panel refresh: receive-mode is included in changes_panel, with a wrapper regression for both modes.

Sender cancellation now releases the pending prompt early. Closing the native notification also declines promptly: NotificationClosed is subscribed before display and matched to the daemon and notification ID. A 500 ms grace period preserves an action command already launched as the toast closes. Tests cover dismissal, delayed Accept, unrelated IDs, and forged close signals on an isolated D-Bus. The package revision is now 0.1.13-3.

Local validation: 539 Rust tests passed, 1 existing ignored; 418 Python tests passed; Clippy with -D warnings, formatting, and diff checks passed.

I also checked the installed receiver under its real systemd restrictions using localhost and the live Omarchy daemon with stock delivery rules. Under DND, the prompt remained visible; a concurrent Ask received 503; dismissal returned 403 in 0.552 s; an unanswered request returned 403 after 30.038 s. Late replies were refused. An Accept command delivered after toast closure still succeeded. No Upload was sent in these checks, and DND was restored afterwards.

An iPhone trial on the preceding test build produced Ask 200, Upload 200, and a saved file; the owner reports that Accept and Decline appear to work. Exact model/iOS details and the expanded Apple-device matrix remain outstanding, including the new dismissal behavior, sender-side timeout/status presentation, cancellation, and two real senders. I am keeping this draft until that evidence is available rather than treating synthetic clients as Apple interoperability proof.

The GitHub Tests and Core (Rust) workflows are currently action_required. Could you approve those fork workflow runs when convenient? The PR description contains the updated implementation and test evidence as well.

@netmojo

netmojo commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

All five findings and both suggestions from the first review are fixed at 7303c73. We reran our probes from that review against this commit, and each now shows the fixed behaviour. Two things remain worth fixing, one of them a gap we missed in the first round, plus a packaging nit.

Item At 125800b At 7303c73
2. Two silent dials during a prompt (max_connections = 2) Ask connection closed; retry got 503 Ask 200; next Ask 200
3. Auto-Accept Ask, switch to Ask First, Upload on the same connection 200, file stored 403, nothing stored
4. Mixed files + links Ask 200, undisclosed link stored 400, nothing stored (dictionary and array TransferType)

Items 1 and 5 are covered by your own tests, and we read the code paths for both.

Should fix

1. Approval doesn't limit what the upload contains

The prompt shows the Files names and the sum of their FileSize values, but /Upload never compares the archive with them. A probe approved an Ask listing one holiday.jpg with a reported size of 3 bytes. The upload on that connection then stored a.sh, b.desktop, and c.txt, 30 bytes in total, with status 200. The first review missed this. It exists at 125800b too.

Ask First is still worth shipping, since it stops unsolicited transfers. But the prompt describes what the sender claims, not what will land in Downloads, and a user may reasonably read it as the second. Do one of these:

  • Say so in the README: names, count, and size in the prompt come from the sender and aren't checked against the upload.
  • Or refuse an Upload that holds more files than the approved Ask listed. Check what iPhones and Macs put in Files during the hardware tests first. Media conversion can change names and sizes, so an exact match on those would likely refuse real transfers.

2. Refusals that aren't the user's choice leave no trace

approval::request returns false without a log line when the D-Bus session connection fails, the reply socket can't be created, or the notification helper fails to start or exits non-zero. The receiver then logs only receive request declined or timed out, which is also all the journal would have shown for the first review's Do Not Disturb (DND) problem: every request refused, with no reason. Log why each request ended: declined, timed out, dismissed, sender gone, or notification failure (with the error).

Before merge

  • Set pkgrel=1 in core/PKGBUILD. 0.1.13 hasn't been released, and the -2 and -3 builds were local test packages.

Suggestions

  • Clicking the card body declines, because omarchy-notification-send runs the first action on a card click and Decline comes first. Failing closed is right. A user who clicks the toast expecting to open something will be surprised, so mention it in the README and add a card-body click to the hardware tests.
  • In Everyone mode, one sender can hold the only prompt slot back to back, 30 seconds per Ask, so other senders get 503. A short per-peer cooldown after a decline or timeout would limit that. It can be a follow-up.
  • The explicit ReadWritePaths=%t/omdrop/receive-requests is redundant. RuntimeDirectory= is already writable under ProtectSystem=strict, including after the ReadWritePaths= reset in the drop-in that omdrop dir writes. Keeping it is harmless.

Hardware tests

Your list is complete for the design you chose. Please add:

  • A card-body click, as above.
  • What an iPhone and a Mac put in each Files entry for a photo, a video, and a document, if you take the second option in item 1.

What we ran

  • At 7303c73 on aarch64 Linux (M1 Pro), rustc 1.93.1: cargo test --locked --workspace 539 passed, 1 ignored. clippy -D warnings and fmt --check are clean. Python suite: 418 passed, 1 skipped.
  • Our first-round probes, updated for the new approver signature, plus the upload-contents probe. The patch and log are kept with our review notes, outside this PR.
  • systemd-run --user on systemd 262 with this unit's ProtectSystem=strict, ProtectHome=read-only, and RuntimeDirectory= settings, with and without a ReadWritePaths= reset: the service bound a socket in $RUNTIME_DIRECTORY both times, and the home directory stayed read-only.
  • Read omarchy-notification-send and the notification plugin's Service.qml on Omarchy 4.5.0-3 for the action, card-click, and close order. We did not raise a live prompt.
  • origin/main (517afeb) merges with this branch without conflicts.

We approved the Tests and Core (Rust) runs for 7303c73.

@netmojo
netmojo force-pushed the feat/receive-approval branch from 7303c73 to 1a29aac Compare November 23, 2026 01:57
@netmojo

netmojo commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

We rebased this branch onto main at 17da695 and force-pushed it. The head is now 1a29aac (was 7303c73). You're still the author of all three commits. If you have local commits, rebase them onto the new head before pushing.

The conflicts were all version numbers:

  • omdrop-core is now 0.1.18. main released up to 0.1.17 since this PR opened. That covers CORE_MIN in bin/omdrop, core/Cargo.toml, core/Cargo.lock, and the README's "omdrop-core 0.1.18 or newer".
  • pkgrel=1 in core/PKGBUILD, as asked in the second review. The -2 and -3 bumps are dropped.

No code changed. The only other difference: the omdrop-proto dependency of omdrop-cli is already on main, so it no longer appears in the second commit.

At 1a29aac on aarch64 Linux: cargo fmt --check and clippy -D warnings are clean, cargo test --locked --workspace passed 584 with 1 ignored, and the Python suite passed 426.

The two should-fix items from the second review and the hardware tests are still open. If you rebuild your test package, use this head.

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.

2 participants