Skip to content

Update mirror-displays extension - #26445

Merged
raycastbot merged 4 commits into
raycast:mainfrom
leodbrs:ext/mirror-displays
Apr 2, 2026
Merged

raycastbot merged 4 commits into
raycast:mainfrom
leodbrs:ext/mirror-displays

Conversation

@leodbrs

@leodbrs leodbrs commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Screencast

Checklist

@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: mirror-displays Issues related to the mirror-displays extension platform: macOS labels Mar 18, 2026
@raycastbot

raycastbot commented Mar 18, 2026 •

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

🔔 @yonbergman you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

📋 Quick checkout commands
BRANCH="ext/mirror-displays"
FORK_URL="https://github.com/leodbrs/raycast-extensions.git"
EXTENSION_NAME="mirror-displays"
REPO_NAME="raycast-extensions"

git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run dev

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

@leodbrs
leodbrs marked this pull request as ready for review March 18, 2026 21:56
Copilot AI review requested due to automatic review settings March 18, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the Mirror Displays Raycast extension from a background “toggle” command to an interactive list UI that lets the user choose mirroring direction or disable mirroring, implemented via a Swift/CoreGraphics helper script.

Changes:

  • Replaced AppleScript keyboard-emulation toggle with a view-based List UI and explicit actions (Mac → External, External → Mac, Off).
  • Added a Swift script (mirror.swift) using CoreGraphics to configure display mirroring, including multi-external handling.
  • Updated extension metadata (command mode/title/description) and changelog entry.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
extensions/mirror-displays/src/mirror-displays.tsx New List-based command that executes the Swift helper and shows toasts.
extensions/mirror-displays/src/mirror-displays.ts Removes prior AppleScript “toggle mirroring” implementation.
extensions/mirror-displays/package.json Switches command to view mode, updates command title/description, adds contributor.
extensions/mirror-displays/assets/mirror.swift Adds CoreGraphics-based mirroring configuration script.
extensions/mirror-displays/CHANGELOG.md Documents the new UI + Swift/CoreGraphics migration.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +2 to +12
import { exec } from "child_process";
import { promisify } from "util";
import { join } from "path";

const execAsync = promisify(exec);

export default function Command() {
async function handleAction(source: "mac" | "external" | "off") {
try {
const scriptPath = join(environment.assetsPath, "mirror.swift");
await execAsync(`swift "${scriptPath}" ${source}`);
Comment on lines +18 to +22
const output = (e.stdout || "") + "\n" + (e.stderr || "");
if (output.includes("No external displays detected")) {
await showToast({ title: "No external display found", style: Toast.Style.Failure });
} else {
await showToast({ title: "Failed to configure mirroring", message: String(e), style: Toast.Style.Failure });
Comment on lines +7 to +9
CGGetOnlineDisplayList(0, nil, &displayCount)
var displays = [CGDirectDisplayID](repeating: 0, count: Int(displayCount))
CGGetOnlineDisplayList(displayCount, &displays, &activeCount)
let mode = args[1]

var config: CGDisplayConfigRef?
CGBeginDisplayConfiguration(&config)
<List.Item
icon={Icon.Monitor}
title="External -> Mac"
subtitle="Mirror the external display onto the MacBook screen"
async function handleAction(source: "mac" | "external" | "off") {
try {
const scriptPath = join(environment.assetsPath, "mirror.swift");
await execAsync(`swift "${scriptPath}" ${source}`);
Comment thread extensions/mirror-displays/CHANGELOG.md Outdated
@@ -1,3 +1,9 @@
# Mirror Displays Changelog

## [New Features & Bugfixes] - {PR_MERGE_DATE}
@greptile-apps

greptile-apps Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR modernizes the Mirror Displays extension by replacing the fragile AppleScript keyboard-emulation approach with a proper CoreGraphics Swift script and upgrading the command from a background no-view toggle to a full Raycast List view that lets users choose the mirroring direction or disable it entirely.

Key changes and outstanding items:

  • Missing metadata/ folder: The command mode changed from no-view to view, which requires a metadata/ folder with Raycast-styled screenshots before the extension can be published to the store.
  • Unused dependency: @raycast/utils is still listed in dependencies but is no longer imported anywhere after runAppleScript was removed — it should be dropped.
  • Swift script argument ordering: Argument count validation occurs after display detection, which gives misleading output when running the script manually without arguments. The Raycast UI always passes an argument so this does not affect end users.
  • handleAction inside component: The handler is redefined on each render; moving it outside the component would be a minor improvement.

Confidence Score: 3/5

  • Not ready to merge — the missing metadata/ folder is a store publishing requirement for view-type commands.
  • The core logic (Swift script + TypeScript UI) is sound, but the change from no-view to view mode introduces a mandatory store requirement (screenshots in metadata/) that has not been fulfilled. The unused @raycast/utils dependency is a minor cleanup item. Everything else looks correct.
  • extensions/mirror-displays/package.json — mode changed to "view" but required metadata/ folder with screenshots is absent.

Important Files Changed

Filename Overview
extensions/mirror-displays/src/mirror-displays.tsx New view-type command replacing the old no-view AppleScript toggle; implements a List UI with three mirroring options. Minor: handleAction is recreated on every render and could be moved outside the component.
extensions/mirror-displays/assets/mirror.swift New Swift script using CoreGraphics to configure display mirroring. Logic is correct; minor issue is that argument validation happens after display detection, making manual invocation without arguments slightly misleading.
extensions/mirror-displays/package.json Command mode changed from no-view to view, contributor added. Two issues: (1) missing required metadata/ folder with screenshots for the store, and (2) @raycast/utils dependency is now unused and should be removed.
extensions/mirror-displays/CHANGELOG.md New changelog entry added at the top with {PR_MERGE_DATE} placeholder and a clear description of changes. Correctly ordered and formatted.
extensions/mirror-displays/src/mirror-displays.ts Old no-view AppleScript implementation removed, replaced by the new tsx file.

Comments Outside Diff (1)

  1. extensions/mirror-displays/package.json, line 25 (link)

    P2 Unused @raycast/utils dependency

    The previous implementation used runAppleScript from @raycast/utils, but the new mirror-displays.tsx no longer imports anything from this package. It can be removed to keep the extension lean.

Last reviewed commit: "Initial contribution..."

"mode": "no-view"
"title": "Mirror Displays",
"description": "Choose which display to mirror, or turn off mirroring.",
"mode": "view"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Missing metadata/ folder with screenshots

The command mode was changed from "no-view" to "view", which means this extension now renders a UI and is required to include a metadata/ folder with Raycast-styled screenshots for the store.

Please add a metadata/ folder at extensions/mirror-displays/metadata/ containing at least one screenshot of the List view. See the docs for format requirements.

Rule Used: What: Extensions with view-type commands must incl... (source)

const execAsync = promisify(exec);

export default function Command() {
async function handleAction(source: "mac" | "external" | "off") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 handleAction recreated on every render

handleAction is defined inside the component body, so it is recreated on every render. Consider moving it outside the component or wrapping it with useCallback to avoid unnecessary allocations (especially since the function captures no component state or props).

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +40 to +44
let args = CommandLine.arguments
if args.count < 2 {
print("Usage: swift mirror.swift [mac|external|off]")
exit(1)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Argument count check placed after display detection

The usage/argument validation (lines 40–44) runs after the external-display check (lines 35–38). This means running swift mirror.swift with no arguments on a Mac with no external displays will print "No external displays detected." rather than the usage hint. While this doesn't affect the Raycast UI flow (an argument is always supplied by the TypeScript caller), it makes the script harder to test manually. Moving the argument count check to the top of the script would be more idiomatic and self-documenting.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

- Fix metadata screenshot size to required 2000x1250px
- Fix review feedback: remove unused dep, move handler, fix Swift arg order, add metadata screenshot
@yonbergman

Copy link
Copy Markdown
Contributor

@leodbrs Loved the approach here !

@0xdhrv 0xdhrv self-assigned this Apr 2, 2026
- Added error handling for display retrieval in mirror.swift
- Updated README and CHANGELOG for clarity and consistency
- Improved user feedback for display configuration errors
- Refactored command handling for better readability and maintainability

@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 41a12f0 into raycast:main Apr 2, 2026
2 checks passed
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

@raycastbot

Copy link
Copy Markdown
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

ariesly15 pushed a commit to ariesly15/raycast-extensions that referenced this pull request Apr 2, 2026
- chore: 更新 delink 扩展变更日志并移除旧版本记录
- Merge branch \'raycast:main\' into main
- Update CODEOWNERs (41a12f0)
- Update mirror-displays extension (raycast#26445)
ariesly15 pushed a commit to ariesly15/raycast-extensions that referenced this pull request Apr 10, 2026
- feat[extensions/qq-mail]: 添加QQ邮箱扩展及配置文件
- Merge branch \'raycast:main\' into main
- Update CODEOWNERs (9944a1b)
- [XKCD Comics] Add viewing history (raycast#26704)
- refactor: 增加useCallback并更新tsconfig配置
- Update CODEOWNERs (9b7c8a4)
- Add Kafka UI extension (raycast#26259)
- Merge branch \'raycast:main\' into main
- refactor: 简化 Action.CopyToClipboard 组件调用 (url-parse.tsx)
- chore: 移除 delink 扩展中的图标配置项
- chore: 删除图标文件并更新配置引用新图标
- Update CODEOWNERs (756e9da)
- Update ascii-art-wallpaper extension (raycast#26707)
- Update CODEOWNERs (23ee8a8)
- Add paper-agent extension (raycast#26367)
- Merge branch \'raycast:main\' into main
- chore: 更新 delink 扩展变更日志并移除旧版本记录
- Update CODEOWNERs (768930b)
- Add nocal extension (raycast#26482)
- Update CODEOWNERs (7c0e492)
- Add caaals extension (raycast#26443)
- Merge branch \'raycast:main\' into main
- docs: 更新 delink 扩展文档及快捷键说明
- Update CODEOWNERs (41a12f0)
- Update mirror-displays extension (raycast#26445)
- chore: 更新 delink 扩展的版本信息为初始发布版
- docs: 调整 delink 扩展快捷键说明顺序
- Merge branch \'raycast:main\' into main
- feat:up
- Update CODEOWNERs (2134dff)
- Update hetzner extension (raycast#26705)
- Update CODEOWNERs (840e5a9)
- Add ram-prices extension (raycast#26564)
- Update CODEOWNERs (45fad15)
- Add habitica-todos extension (raycast#26446)
- Update CODEOWNERs (3e686e1)
- Add Bundles extension (raycast#25680)
- Update CODEOWNERs (f6261fd)
- Update tmux-cheatsheet extension (raycast#26379)
- Changelog Alignment (raycast#26824)
- Update prism-launcher extension (raycast#26816)
- Merge branch \'raycast:main\' into main
- feat: add metadata folder and language setting
- Update picgo extension (raycast#26818)
- Update CODEOWNERs (bd7023d)
- Add clockodo extension (raycast#26432)
- feat: add raycast extension delink
- Update CODEOWNERs (868aef4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension fix / improvement Label for PRs with extension's fix improvements extension: mirror-displays Issues related to the mirror-displays extension platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants