Skip to content

feat: Finder integration (right-click compress + dock drop)#15

Merged
JBolanle merged 6 commits into
mainfrom
feat/finder-right-click
May 19, 2026
Merged

feat: Finder integration (right-click compress + dock drop)#15
JBolanle merged 6 commits into
mainfrom
feat/finder-right-click

Conversation

@JBolanle
Copy link
Copy Markdown
Owner

Summary

Adds three new ways to compress PDFs without opening the app's main window — all routed through a single headless code path:

  • Right-click → Open With → compress[pdf] — works after installing the app to /Applications, via Tauri fileAssociations and a RunEvent::Opened handler. The PDF is compressed with the saved Output, Naming, and Default-preset settings; no window appears; a native notification reports the result.
  • Right-click → Compress with compress[pdf] — top-level Finder entry installed from the in-app Advanced drawer. Ships an Automator Quick Action (Compress PDF.workflow) bundled in Resources; the in-app Install button copies it to ~/Library/Services/. The workflow shells open -b com.pdfcompressor "$@" so it routes back through the same Apple Event.
  • Drop PDFs onto the Dock icon — free byproduct of the file association.

The right-click flow always writes a _compressed.pdf sibling regardless of the in-app Overwrite setting — Finder context has no preview/confirm step, so it refuses to destroy originals.

Also refactored the settings UI: stacked radios collapsed into segmented controls, and a new Advanced disclosure houses the Default preset (so the per-file Quality preset and the headless default don't visually collide).

Commit summary

  • 56c2aa5 feat: Open With → compress[pdf] + headless compression + single-instance + RunEvent::Opened
  • 71192c0 refactor: segmented-control settings layout (Raycast-style preference rows)
  • e6de9bb refactor: Default preset moved into Advanced drawer
  • 639fcec feat: Quick Action bundle + in-app install/remove
  • 935226d fix(clippy): two trivially-derivable lints
  • 6add143 chore: bump version to 1.5.0

Test plan

  • cargo test — 62/62 pass (new tests in quick_action::tests, headless::tests, settings::tests)
  • npm test — 99/99 pass (new tests for Advanced drawer + Quick Action row)
  • cargo clippy -- -D warnings — clean
  • cargo audit — exit 0 (existing warnings only, all pre-existing transitive Linux GTK deps not used on macOS)
  • npm run check — clean
  • Post-merge smoke test on the universal DMG built by release.yml after tagging v1.5.0:
    • Open With → compress[pdf] from right-click
    • Install Quick Action from Advanced drawer, then right-click → "Compress with compress[pdf]"
    • Drag PDFs onto Dock icon
    • Settings UI persistence

🤖 Generated with Claude Code

JBolanle and others added 6 commits May 19, 2026 11:17
Adds a headless compression path triggered by macOS's open-document
event so users can right-click a PDF, choose "Open With → compress[pdf]",
and get a native notification when the work is done — no main window,
no in-app interaction needed.

The flow always writes a `_compressed.pdf` sibling and never overwrites
the original, even if the in-app Overwrite setting is enabled, because
the Finder context has no preview/confirm step. Output folder and
preset are still read from the user's saved settings, and a new
"Finder right-click preset" control in the settings panel lets users
choose Max/Balanced/Minimal as the default.

- tauri.conf.json: declare PDF file association (role: Viewer);
  start the main window hidden so headless launches don't flash a UI
- Cargo.toml: add tauri-plugin-single-instance and tokio (time)
- compress.rs: extract compress_files_inner returning outcomes so
  the headless flow can tally success/failure for the notification
- headless.rs (new): filter PDF paths, force Suffix naming, run
  compression, post a summary notification
- lib.rs: install single-instance plugin, handle RunEvent::Opened,
  defer window-show 400ms so file-open launches stay headless
- settings.rs: add default_preset field with serde default for
  migration
- DetailPanel.svelte: new "Finder right-click preset" radios

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The settings block at the bottom of DetailPanel was reading as a
SwiftUI System Settings form — three field headers, ten stacked radio
rows, a long hint paragraph — which is exactly what the project's
design context calls out as the thing to avoid. Replaces it with a
Raycast-style preference layout: one horizontal row per setting,
single-word label on the left, segmented control on the right.

- Three settings collapse from ~10 rows to 3
- Real <input type="radio"> kept inside styled <label class="segment">
  so keyboard nav and ARIA semantics stay intact
- Conditional detail rows (folder picker, overwrite warning) appear
  indented under their parent setting, aligned to the control column
- Section heading dropped; the subtle divider above is the separator
- Long right-click hint replaced with a native title tooltip on the
  "Right-click" label
- Folder path: bumped to accent blue so the selected value reads as
  meaningful, uses direction: rtl so long paths truncate from the
  start (you always see the leaf folder)
- Choose button: bg-overlay + full border + accent hover, sits flush
  on the panel background instead of in a chip container

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The Default preset segmented control showed the same three labels
(Max/Balanced/Minimal) as the per-file Quality control above, creating
a confusing collision when a user was looking at a selected file —
two identical-looking selectors visible at once. Folds Default preset
into a collapsed-by-default Advanced disclosure so the per-file
Quality preset is the only preset selector visible during normal use.

Output and Naming stay visible: they affect every compression (in-app
and right-click), and Naming has the destructive overwrite warning
that needs to be glanceable.

- Custom Svelte disclosure with Svelte's slide transition, 180ms with
  cubicOut easing; respects prefers-reduced-motion
- Hand-pathed SVG chevron rotates 90° on expand
- aria-expanded + aria-controls; content conditionally rendered so
  screen readers don't announce the collapsed setting
- Two new tests: drawer collapsed by default, click expands and
  reveals the radios

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Ships an Automator Quick Action bundled inside the .app's Resources
and an in-app Install button in the Advanced drawer that copies it to
~/Library/Services/. Once installed, "Compress with compress[pdf]"
appears at the top level of Finder's right-click menu — no more
nesting under Open With.

The workflow runs `open -b com.pdfcompressor "$@"` so the same
RunEvent::Opened handler that powers Open With and Dock drops also
catches Quick Action invocations. Backend wiring is purely the
installer; the compression code path is unchanged.

- resources/Compress PDF.workflow/ — static Automator bundle with
  NSServices restricted to Finder + PDFs (filename avoids brackets
  because Tauri's bundle.resources glob reads them as a character
  class; user-facing menu label is set inside the bundle's Info.plist)
- quick_action.rs — install/is_installed/uninstall commands plus a
  recursive directory-copy helper that wipes the destination first so
  re-installing replaces stale files
- DetailPanel Advanced drawer — new row with status text ("Not
  installed" in tertiary, "Installed" in accent blue) and a button
  that toggles between Install/Remove with busy state and toast
  feedback. Re-reads state every time the drawer opens.
- README — new Finder integration section documenting all three
  entry points: Open With, Quick Action, drop on Dock icon

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
CI runs cargo clippy with -D warnings. The previous Finder integration
work introduced two trivially-fixable lints:

- compress.rs: hand-written `impl Default for Preset` is mechanically
  derivable — switch to `#[derive(Default)]` with `#[default]` on
  the Balanced variant.
- headless.rs: a match arm with `(n, 0) if n == 1` is a redundant
  guard — collapse to `(1, 0)`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Minor bump for the Finder integration release:
- right-click → Open With → compress[pdf]
- top-level "Compress with compress[pdf]" Quick Action (install via
  the in-app Advanced drawer)
- drop PDFs onto the Dock icon
- segmented-control settings UI with an Advanced disclosure

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@JBolanle JBolanle merged commit 6a0ae8b into main May 19, 2026
6 checks passed
@JBolanle JBolanle deleted the feat/finder-right-click branch May 19, 2026 21:25
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