Skip to content

Add sidecar-display extension - #29572

Merged
raycastbot merged 9 commits into
raycast:mainfrom
chiptoma:ext/sidecar-display
Aug 23, 2026
Merged

raycastbot merged 9 commits into
raycast:mainfrom
chiptoma:ext/sidecar-display

Conversation

@chiptoma

@chiptoma chiptoma commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Sidecar Display connects an iPad over Sidecar and forces it to extend
instead of mirror — from a hotkey or the menu bar — without ever writing or
relocating the Mac's main display.

Two interchangeable engines sit behind one interface, auto-selected:

  • BetterDisplay — drives the betterdisplaycli binary (needs the
    BetterDisplay app). Proven and low-maintenance.
  • Native — no runtime dependency. A small Swift helper connects/disconnects
    via the private SidecarCore framework loaded at runtime with dlopen
    (the binary links nothing private), and controls mirror state through
    public CoreGraphics.

Features

  • Connect / Disconnect / Fix Mirroring commands, plus a Sidecar Status
    menu bar with a one-click Auto-Reconnect toggle.
  • Auto-Reconnect background command that restores a link dropped on its own
    (e.g. waking from sleep), with configurable backoff and a heartbeat that never
    abandons a wanted link.
  • Fix Mirroring clears macOS Sidecar's own mirror mode — which is invisible
    to every display API — by reconnecting the main BetterDisplay virtual screen.

Safety

The extension never writes or power-cycles the main display; mirroring always
keeps the current main as master, and both mode writes are refused when the iPad
is itself main. These invariants are enforced on every path and proven by
headless unit tests (no hardware needed).

Note for reviewers (private framework)

The native engine uses the private SidecarCore framework via runtime
dlopen/selectors and public CoreGraphics — no opaque binary is committed;
the Swift ships as auditable source, compiled by extensions-swift-tools.
If the private-API use is a concern, the BetterDisplay engine is a full-featured,
dependency-free-of-private-APIs fallback and can ship on its own.

Tested on macOS 26 with an iPad over Sidecar, both engines.

Screencast

Checklist

- build(publish): drop swift/.build before ray publish copies
- docs: point CLAUDE and CONTRIBUTING at ARCHITECTURE.md
- docs: move architecture detail out of README
- refactor(lib): extract shared betterdisplaycli plumbing
- docs: refresh store screenshots for auto-reconnect toggle
- feat(auto-reconnect): add on/off toggle and consistent HUD messaging
- fix(auto-reconnect): clear sidecar mirror mode after background reconnect
- build: adopt typescript 6.0.3 and tighten dependabot pin
- chore: bump the dev-dependencies group across 1 directory with 3 updates (raycast#6)
- chore: bump actions/setup-node from 4 to 7 (raycast#3)
- chore: bump actions/cache from 4 to 6 (raycast#2)
- chore: bump actions/checkout from 4 to 7 (raycast#1)
- chore: bump @raycast/api from 1.104.22 to 1.104.23 (raycast#5)
- ci(dependabot): ignore typescript and @types/node major bumps
- test: convert the suite to TypeScript on node:test
- chore: consolidate ignores, tighten tsconfig, and normalise the scripts
- docs: correct the branch-protection description
- chore: gate publishing on store readiness and document the release flow
- docs: add a workflows runbook and correct the safety claims
- refactor: align names with their user-facing features and enforce the limits
- chore: add store screenshots and correct the description wording
- docs: comprehensive README, contributing guide, and repo polish
- refactor: compile the native engine from Swift source, not a bundled binary
- test: cover the virtual-screen reconnect with a stub CLI
- chore: add changelog, release workflow, and validated publish path
- fix: add error handling and feedback to menu-bar actions, enforce typecheck
- fix: drop the ineffective redetect method and harden the virtual-screen reconnect
- feat: add a lighter "redetect displays" mirror-fix method
- feat: automatic engine default, smarter mirror fix, and message polish
- feat: only fix mirroring on a fresh connect, not every time
- feat: fix Sidecar mirror mode by reconnecting virtual screens
- feat: add an option to show the device name in the menu bar
- fix: detect a mirrored Sidecar display in the native engine
- fix: hold the display mode through the macOS rearrange window after connect
- feat: add a native no-dependency engine (SidecarCore + CoreGraphics)
- refactor: introduce a SidecarBackend interface behind the orchestration
- fix: make the menu-bar item friendly to Bartender and other menu managers
- feat: make auto-reconnect timing configurable and drop the toggle command
- fix: keep auto-reconnect alive after sleep instead of giving up
- feat: add background auto-reconnect and a menu-bar status command
- fix: never touch the main display when connecting an unreachable iPad
- feat: initial release of sidecar-display Raycast extension
@raycastbot raycastbot added new extension Label for PRs with new extensions platform: macOS labels Jul 19, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

Congratulations on your new Raycast extension! 🚀

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 15 business days.

Once the PR is approved and merged, the extension will be available on our Store.

@greptile-apps

greptile-apps Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new Sidecar Display extension that connects an iPad via Apple Sidecar and forces it into extend (or mirror) mode without touching the main display. It ships a bundled Swift helper that drives SidecarCore via dlopen and controls mirror state through public CoreGraphics, with a full TypeScript orchestration layer on top.

  • Four commands (connect-sidecar, disconnect-sidecar, fix-mirroring, auto-reconnect) plus a menu-bar status item with per-device actions, presence detection, and a one-click Auto-Reconnect toggle.
  • A pure-function keep-alive state machine (keepalive.ts) governs background reconnect attempts with exponential backoff, probe debouncing, transport-policy filtering, and a configurable give-up budget that only accrues while the iPad is provably nearby.
  • The only finding is a hardcoded date in CHANGELOG.md that should be the {PR_MERGE_DATE} placeholder.

Confidence Score: 5/5

  • Safe to merge after fixing the changelog date placeholder.
  • The core logic is well-guarded: the main display is never written, mirror writes are skipped when the iPad is the main display, the keep-alive machine handles sleep gaps and probe flicker correctly, and the Swift bridge properly cancels display config transactions on every failure path. The only change needed is a one-line fix in the changelog.
  • No files require special attention beyond the changelog placeholder fix.

Important Files Changed

Filename Overview
extensions/sidecar-display/CHANGELOG.md Uses a hardcoded date instead of the required {PR_MERGE_DATE} placeholder.
extensions/sidecar-display/package.json Well-structured manifest: includes $schema, correct System category, macOS-only platform, and all dependency fields look accurate.
extensions/sidecar-display/src/lib/keepalive.ts Pure state machine with thorough debouncing, budget accumulation, and sleep-gap handling. Logic is well-guarded and matches the unit tests.
extensions/sidecar-display/src/sidecar-status.tsx Menu-bar command uses auto-generated Preferences type correctly, uses launchCommand (not deeplinks) for menu refresh, and properly surfaces errors via toast.
extensions/sidecar-display/src/auto-reconnect.ts Background command correctly gates reconnects on intent, transport policy, and the keep-alive decision, and only surfaces errors when manually invoked.
extensions/sidecar-display/src/lib/sidecar.ts Orchestration layer correctly guards against writing the main display, polls with a stable-reads threshold, and is fully engine-agnostic for testability.
extensions/sidecar-display/swift/Sources/Sidecar/SidecarBridge.swift setMirror correctly calls CGCancelDisplayConfiguration on both failure paths (configure and complete), and the dlopen approach keeps the binary free of private-framework links.
extensions/sidecar-display/src/lib/preferences.ts Uses auto-generated Preferences type throughout; no manual interface redefinition. Preference parsing is robust with numeric clamping and fallbacks.
extensions/sidecar-display/eslint.config.mjs Correctly uses defineConfig from eslint/config per ESLint v9 convention, with appropriate quality and import-hygiene rules.

Reviews (9): Last reviewed commit: "Update CHANGELOG.md and optimise images" | Re-trigger Greptile

Comment thread extensions/sidecar-display/.prettierrc Resolved
chiptoma added 3 commits July 19, 2026 15:58
- style: reflow README to printWidth 120
- style: adopt printWidth 120 per Raycast store standard
- fix(swift): cancel display configuration when completion fails
@chiptoma
chiptoma marked this pull request as ready for review July 20, 2026 13:38
- feat(auto-reconnect): gate reconnects on a silent presence probe
- docs: add project TODO

@0xdhrv 0xdhrv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your contribution 🔥

We already have a Sidecar extension in the Store:

The existing extension already lets users connect and disconnect an iPad as a second display from Raycast.

This PR adds more Sidecar functionality, including:

  • Choosing between extend and mirror modes
  • Automatically reconnecting after the connection drops
  • Showing the connection status in the menu bar
  • Detecting whether the iPad is nearby
  • Fixing mirroring issues
  • Supporting multiple Sidecar devices

Could these features be added to the existing Sidecar extension instead of introducing another extension for the same workflow?

This would keep Sidecar-related functionality in one extension while improving the existing extension with connection status, display-mode controls, and automatic reconnection.
As mentioned in our extension guidelines here ↗

@0xdhrv
0xdhrv marked this pull request as draft August 5, 2026 16:41
@0xdhrv 0xdhrv self-assigned this Aug 5, 2026
@chiptoma

chiptoma commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look.

The overlap is narrower than the feature list suggests — these aren't two implementations of the same thing with different polish. They're different mechanisms.

The existing extension drives the System Settings UI through AppleScript. It opens the Displays pane and clicks the device popup by accessibility-tree index:

set popUpButton to menu button 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
on error
  set popUpButton to pop up button 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1

Two hardcoded paths because the hierarchy moved in Tahoe. It requires Accessibility permission, opens a window on every use, and breaks whenever Apple reshuffles that pane.

This extension talks to SidecarCore directly and controls mirroring through public CoreGraphics. No System Settings, no AppleScript, no Accessibility permission.

That difference is why the features you listed can't simply be added to the existing extension. UI scripting can only issue clicks — it has no way to ask a question. Auto-reconnect needs to read whether the link is up. Presence detection needs to read whether the iPad is within reach. The menu-bar status needs both. None of those are reachable by clicking buttons in a settings pane, so they aren't features to port; they're consequences of the engine.

There's also a safety dimension. macOS decides which display becomes main when Sidecar attaches, and it can pick the iPad. This extension refuses to write or relocate the main display on every path, and that invariant is enforced by tests. An earlier iteration of mine got it wrong: it scrambled every window and caused a logout. That's documented in docs/ARCHITECTURE.md, along with the reasoning behind each guard.

So I don't think folding these together produces one better extension — it would mean discarding the existing implementation and replacing it wholesale with this one, which is a different proposition from what you're asking.

- fix(auto-reconnect): reconnect promptly when the cable goes back in
- docs: correct the TODO status and record what is outstanding
@0xdhrv
0xdhrv marked this pull request as ready for review August 21, 2026 18:25
- Remove redundant contributor, architecture, workflow, security, and TODO documents
- Simplify the README around setup, commands, preferences, and limitations
- Add extension keywords and clarify user-facing configuration descriptions
- Reduce background refresh intervals to once per minute
- Rename the lint autofix script and add a preference placeholder
- Remove outdated metadata screenshots and normalize test compiler formatting

@0xdhrv 0xdhrv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, approved ✅

@raycastbot
raycastbot merged commit a3ef6fc into raycast:main Aug 23, 2026
1 check passed
@github-actions

Copy link
Copy Markdown
Contributor

@raycastbot

Copy link
Copy Markdown
Collaborator

🎉 🎉 🎉

Such a great contribution deserves a reward, but unfortunately we couldn't find your Raycast account based on your GitHub username (@chiptoma).

Please link your GitHub account to your Raycast account to receive your credits and soon be able to exchange them for some swag.

chiptoma added a commit to chiptoma/sidecar-display that referenced this pull request Aug 24, 2026
The extension shipped with raycast/extensions#29572. Replace the
"not yet published" note with the Store link and the deep link, and
tick off the merge-gated TODO items.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new extension Label for PRs with new extensions platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants