Repository navigation
fix: open links in MarkdownPanelView via explicit OpenURLAction - #3558
Conversation
The rendered `.md` file panel styled hyperlinks via the markdown theme but left them un-clickable: the combination of the `MarkdownPanelPointerObserver` overlay and `.textSelection(.enabled)` suppresses SwiftUI `Link`'s default activation, so the `\.openURL` environment was never invoked and clicks fell through to selection. Wire it explicitly to `NSWorkspace.shared.open`, matching the pattern already used elsewhere in `Sources/`.
|
@psh4607 is attempting to deploy a commit to the Manaflow Team on Vercel. A member of the Team first needs to authorize it. |
|
@codex review |
|
To use Codex here, create an environment for this repo. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesLink Opening Behavior Override
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 13✅ Passed checks (13 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Tip For best results, initiate chat on the files or code changes.
[review] |
@psh4607 I have started the AI code review. It will take a few minutes to complete. |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
Pull request overview
This PR fixes link activation inside the app’s rendered Markdown panel by explicitly wiring a SwiftUI OpenURLAction for the Markdown(panel.content) view, ensuring link clicks are opened via NSWorkspace.shared.open(_:) even when the pointer observer overlay and .textSelection(.enabled) interfere with the default SwiftUI activation path.
Changes:
- Add an explicit
\.openURLenvironment override for the Markdown renderer inMarkdownPanelView. - Route link clicks to
NSWorkspace.shared.open(url)and return.handledfrom theOpenURLAction.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR fixes a bug where links rendered inside
Confidence Score: 5/5Safe to merge — a narrow, well-scoped correctness fix that routes previously dead link clicks to the system URL handler without touching any other code path. The change is seven lines in one file, correctly scoped to the No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant MarkdownPanelView
participant OpenURLAction
participant NSWorkspace
User->>MarkdownPanelView: Click link in rendered Markdown
Note over MarkdownPanelView: Default SwiftUI Link path suppressed by<br/>.textSelection(.enabled) + PointerObserver
MarkdownPanelView->>OpenURLAction: \.openURL environment invoked with url
OpenURLAction->>NSWorkspace: NSWorkspace.shared.open(url)
alt URL opened successfully
NSWorkspace-->>OpenURLAction: true
OpenURLAction-->>MarkdownPanelView: .handled
else No registered handler
NSWorkspace-->>OpenURLAction: false
OpenURLAction-->>MarkdownPanelView: .systemAction (fallback)
end
Reviews (2): Last reviewed commit: "review: surface NSWorkspace.shared.open ..." | Re-trigger Greptile |
…x misleading comment Addresses review feedback on manaflow-ai#3558: - Copilot: returning .handled unconditionally masks failures from NSWorkspace.shared.open (Bool return). Capture the result and fall back to .systemAction on failure so a click never silently no-ops. - Greptile (P2) + Copilot: previous comment blamed the MarkdownPanelPointerObserver overlay together with .textSelection for suppressing default Link activation, contradicting the existing observer comment which (correctly) states the overlay does not intercept clicks. Reword to describe the observed effect (default Link path does not fire reliably) without misattributing the cause.
|
Pushed
Re-requesting reviews for the new commit: @codex review |
@psh4607 I have started the AI code review. It will take a few minutes to complete. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 14646 🏁 Script executed: Length of output: 97 🏁 Script executed: Length of output: 15404
Fix 1 — Failure surfacing: .environment(\.openURL, OpenURLAction { url in
NSWorkspace.shared.open(url) ? .handled : .systemAction
})Correctly captures Fix 2 — Comment accuracy: No other concerns with the implementation. The change remains narrow in scope, idiomatic, and consistent with other If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Hey @lawrencecchen @austinywang — when you get a chance, could one of you authorize the Vercel deploy and take a look? All bot reviews (Codex, CodeRabbit, Greptile, cubic) came back clean. Thanks! |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Fix: links in
MarkdownPanelVieware styled but never opened on clickSummary
OpenURLActionto theMarkdown(panel.content)view inSources/Panels/MarkdownPanelView.swiftso link clicks inside the rendered.mdpanel route throughNSWorkspace.shared.open(url)..link { ForegroundColor(...) }) but clicking them does nothing. The combination ofMarkdownPanelPointerObserver(left-click overlay used for first-click panel focus + event forwarding) and.textSelection(.enabled)interferes with SwiftUILink's default activation path, so the\.openURLenvironment is never invoked. Setting it explicitly mirrors the existingNSWorkspace.shared.open(url)pattern used everywhere else inSources/(e.g.ContentView.swift,SessionIndexView.swift,GhosttyTerminalView.swift,AuthManager.swift, etc. — seegit grep "NSWorkspace.shared.open").Diff:
Markdown(panel.content) .markdownTheme(cmuxMarkdownTheme) .textSelection(.enabled) + // Explicit handler: pointer-observer overlay + .textSelection + // suppress SwiftUI Link's default activation, leaving links + // styled but un-clickable without this. + .environment(\.openURL, OpenURLAction { url in + NSWorkspace.shared.open(url) + return .handled + }) .padding(.horizontal, 24) .padding(.vertical, 16)Net: 7 added lines, 1 file (
Sources/Panels/MarkdownPanelView.swift). No new imports —AppKitandSwiftUIare already imported.Scope (what this does NOT fix)
This PR is intentionally narrow. It fixes only the rendered
.mdfile viewer panel (MarkdownPanelopened viaWorkspace.openOrFocusMarkdownSplit(...)).It does not touch:
Sources/GhosttyTerminalView.swift'sGHOSTTY_ACTION_OPEN_URLcase).BrowserLinkOpenSettings,CmdClickMarkdownRouteSettings,BrowserAvailabilitySettings)..mdpaths in terminals (Route .md file clicks to markdown panel instead of system default #1283).Related issues that this PR does not claim to resolve but might tangentially help:
Testing
xcodebuildbuild locally —GhosttyKit.xcframeworkrequireszig(perCONTRIBUTING.md's./scripts/setup.sh) which isn't installed in my environment. SourceKit-LSP diagnostics on the changed file are clean.OpenURLActionandNSWorkspace.shared.opencall site inSources/— the new code matches the project's existing pattern. TheOpenURLActionAPI andNSWorkspace.shared.open(_:)are both stable AppKit/SwiftUI APIs (macOS 11+ / 10.x+ respectively), well below the project's deployment target.Test quality policysays "Tests must verify observable runtime behavior through executable paths" and "Do not add tests that only verify source code text". A unit test that assertsOpenURLActionis wired would be exactly the AST-shape test that policy forbids. The behavioral test is "open a.mdfile with a link in cmux's markdown panel, click the link, expect default handler to open" — that requires the running app and is therefore appropriate for a manual / E2E check, not a unit test.Demo Video
For UI or behavior changes, include a short demo video (GitHub upload, Loom, or other direct link).
.mdfile with an http/https/file link in cmux's markdown panel and click; before this PR, the click does nothing; after, the URL opens in the default handler>Review Trigger (Copy/Paste as PR comment)
Checklist
zig/ xcframework setup; CI build expected to validateTest quality policy(would only assert AST shape). Verification path is manual / E2E in the running app./releaseflow regenerates itSummary by CodeRabbit