Repository navigation
Update mirror-displays extension - #26445
Conversation
|
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 commandsBRANCH="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 devWe're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days. |
There was a problem hiding this comment.
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.
| 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}`); |
| 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 }); |
| 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}`); |
| @@ -1,3 +1,9 @@ | |||
| # Mirror Displays Changelog | |||
|
|
|||
| ## [New Features & Bugfixes] - {PR_MERGE_DATE} | |||
Greptile SummaryThis 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 Key changes and outstanding items:
Confidence Score: 3/5
Important Files Changed
|
| "mode": "no-view" | ||
| "title": "Mirror Displays", | ||
| "description": "Choose which display to mirror, or turn off mirroring.", | ||
| "mode": "view" |
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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!
| let args = CommandLine.arguments | ||
| if args.count < 2 { | ||
| print("Usage: swift mirror.swift [mac|external|off]") | ||
| exit(1) | ||
| } |
There was a problem hiding this comment.
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
|
@leodbrs Loved the approach here ! |
- 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
|
Published to the Raycast Store: |
|
🎉 🎉 🎉 We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag. |
- chore: 更新 delink 扩展变更日志并移除旧版本记录 - Merge branch \'raycast:main\' into main - Update CODEOWNERs (41a12f0) - Update mirror-displays extension (raycast#26445)
- 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)
Description
Screencast
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder