Skip to content

Swarm Fix: [BUG] [alpha] TerminalLinkProvider fallback uses window.open when shell_open fails#38290

Open
hinzwilliam52-ship-it wants to merge 1 commit intoPlatformNetwork:mainfrom
hinzwilliam52-ship-it:fix-bug-alpha-terminallinkprovider-fallback-1774488685
Open

Swarm Fix: [BUG] [alpha] TerminalLinkProvider fallback uses window.open when shell_open fails#38290
hinzwilliam52-ship-it wants to merge 1 commit intoPlatformNetwork:mainfrom
hinzwilliam52-ship-it:fix-bug-alpha-terminallinkprovider-fallback-1774488685

Conversation

@hinzwilliam52-ship-it
Copy link

@hinzwilliam52-ship-it hinzwilliam52-ship-it commented Mar 26, 2026

Description

Brief description of the changes in this PR.

Related Issue

Fixes #(issue number)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Performance improvement
  • Code refactoring

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Testing

Describe the tests you ran to verify your changes.

# Example commands
cargo test
cargo clippy

Screenshots (if applicable)

Add screenshots to help explain your changes.

Summary by CodeRabbit

  • Documentation
    • Added proposal documentation outlining improvements to external URL handling when terminal link operations fail, including alternative mechanisms for shell-based URL opening.

…open when shell_open fails

Signed-off-by: hinzwilliam52-ship-it <hinzwilliam52@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

A new proposal document FIX_PROPOSAL.md has been added describing a fix for Tauri's TerminalLinkProvider behavior. The proposal recommends replacing the current fallback-to-window.open approach with Tauri's shell opening mechanism as the primary fallback when shell_open fails.

Changes

Cohort / File(s) Summary
Documentation Proposal
FIX_PROPOSAL.md
New proposal document detailing a recommended fix for TerminalLinkProvider fallback behavior, replacing window.open with tauri::shell::open for external URL handling.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A proposal hops into view,
Tauri's links need a fix, it's true!
Shell opening takes the stage,
A better way written on this page,
Documentation blooms, fresh and new! 📋✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: proposing a fix for TerminalLinkProvider's fallback behavior when shell_open fails, which aligns with the FIX_PROPOSAL.md document added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@FIX_PROPOSAL.md`:
- Around line 1-6: The comment is asking to clarify whether the fix belongs in
frontend or backend: update TerminalLinkProvider to use Tauri's JS API rather
than falling back to window.open; replace the fallback in TerminalLinkProvider
with a call to `@tauri-apps/api/shell.open` (or use invoke to call a dedicated
backend command that uses tauri::api::shell::open or tauri::Window::open) so the
link opens in the system browser; locate the fallback code in
TerminalLinkProvider (where window.open is used) and change it to call the JS
shell.open or an invoke('open_external', { url }) bridge to Rust (if you prefer
backend), ensuring the chosen layer (frontend TerminalLinkProvider vs Rust
tauri::Window) is documented in the PR description.
- Around line 28-39: The snippet uses the JavaScript invoke("shell_open", ...)
and an unused Window import and calls tauri::shell::open(...) with the wrong
signature; fix by removing the incorrect invoke usage and the unused Window
import, then implement the correct Tauri shell API for your targeted version:
for Tauri v1 use tauri::api::shell::open(path, Option<Program>, &ShellScope)
providing a valid ShellScope, or for Tauri v2 initialize and call the Shell
plugin API (or switch to tauri-plugin-opener and call open_path()/openUrl());
update the call site replacing tauri::shell::open with the proper module path
and required parameters (ShellScope or plugin instance) so the code compiles.
- Around line 7-22: The snippet misuses frontend invoke and window APIs: replace
the invalid invoke("shell_open", ...) call with the proper Rust API (e.g.,
tauri::api::shell::open(&app.shell_scope, "https://example.com", None) for Tauri
v1 or use the recommended tauri-plugin-opener/opener.open_url(...) approach for
v2), remove the incorrect WindowBuilder::new(tauri::generate_handler![]) /
.build(tauri::generate_context!()) usage (do not call generate_handler! or
generate_context! when building windows) and drop the unused Window import; also
ensure the required "shell-open" feature and tauri.conf.json permissions (or the
appropriate plugin and Cargo features) are enabled so the call opens the URL in
the system external browser rather than creating an embedded window.
- Around line 1-41: The proposal mixes frontend and backend Tauri APIs; update
TerminalLinkProvider to use the correct API for its runtime: if
TerminalLinkProvider is frontend/TypeScript, replace the incorrect Rust-like
snippets with a try { await invoke('shell_open', { url: link }); } catch { await
open(link); } flow using invoke and open from `@tauri-apps/api` (reference:
invoke, open, TerminalLinkProvider); if TerminalLinkProvider is Rust/backend,
remove any frontend invoke/open usage and call tauri::api::shell::open(&url,
None).ok() (reference: tauri::api::shell::open) and remove the WindowBuilder
approach since it’s not appropriate for opening external URLs. Ensure the code
paths and imports match the chosen context and remove mixed-language examples
(WindowBuilder, invoke) so only the correct API remains.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aef9a05a-711c-46d3-919a-1e90328e2645

📥 Commits

Reviewing files that changed from the base of the PR and between ec21e1b and 6d6625f.

📒 Files selected for processing (1)
  • FIX_PROPOSAL.md

Comment on lines +1 to +6
To address the issue of `TerminalLinkProvider` falling back to `window.open` when `shell_open` fails, we need to implement a more reliable fallback mechanism that works within the Tauri framework.

Given the constraints and the goal of opening a URL externally in a way that's compatible with Tauri, we can utilize the `tauri::Window` API to launch the URL. This approach ensures that the URL is opened in the default system browser, providing a consistent user experience across different platforms.

Here's a concise code snippet that demonstrates how to achieve this:

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Clarify whether this is a frontend or backend fix.

The proposal mentions TerminalLinkProvider falling back to window.open (a browser/JavaScript API), but then proposes Rust code solutions. If TerminalLinkProvider is a frontend TypeScript/JavaScript component, the fix should likely be implemented in the frontend code using Tauri's JavaScript API (invoke, @tauri-apps/api/shell), not in Rust backend code. Please clarify the context and intended implementation layer.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@FIX_PROPOSAL.md` around lines 1 - 6, The comment is asking to clarify whether
the fix belongs in frontend or backend: update TerminalLinkProvider to use
Tauri's JS API rather than falling back to window.open; replace the fallback in
TerminalLinkProvider with a call to `@tauri-apps/api/shell.open` (or use invoke to
call a dedicated backend command that uses tauri::api::shell::open or
tauri::Window::open) so the link opens in the system browser; locate the
fallback code in TerminalLinkProvider (where window.open is used) and change it
to call the JS shell.open or an invoke('open_external', { url }) bridge to Rust
(if you prefer backend), ensuring the chosen layer (frontend
TerminalLinkProvider vs Rust tauri::Window) is documented in the PR description.

Comment on lines +1 to +41
To address the issue of `TerminalLinkProvider` falling back to `window.open` when `shell_open` fails, we need to implement a more reliable fallback mechanism that works within the Tauri framework.

Given the constraints and the goal of opening a URL externally in a way that's compatible with Tauri, we can utilize the `tauri::Window` API to launch the URL. This approach ensures that the URL is opened in the default system browser, providing a consistent user experience across different platforms.

Here's a concise code snippet that demonstrates how to achieve this:

```rust
use tauri::{Window, WindowBuilder};

// Assuming `link` is the URL you want to open
let link = "https://example.com";

// Attempt to open the link using shell_open
if let Err(_) = invoke("shell_open", link) {
// Fallback: Open the link using tauri::Window
WindowBuilder::new(tauri::generate_handler![])
.title("External Link")
.url(link)
.build(tauri::generate_context!())
.expect("Failed to create window");
}
```

However, since creating a new window just to open a link might not be the most efficient or user-friendly approach, we can also consider using the `webview` API provided by Tauri to open the link in the default browser. Unfortunately, Tauri's API does not directly support launching external URLs without creating a new window or using `shell_open`.

An alternative and more straightforward approach, considering the limitations, is to use the `open` command provided by Tauri, which allows you to open a URL in the system's default browser:

```rust
use tauri::Window;

// Assuming `link` is the URL you want to open
let link = "https://example.com";

// Attempt to open the link using shell_open
if let Err(_) = invoke("shell_open", link) {
// Fallback: Open the link using the open command
tauri::shell::open(link).expect("Failed to open link");
}
```

This approach is more in line with the expected behavior and provides a reliable fallback when `shell_open` fails, ensuring that the URL is opened in the default system browser. No newline at end of file
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

fd -type f -name "FIX_PROPOSAL.md"

Repository: PlatformNetwork/bounty-challenge

Length of output: 246


🏁 Script executed:

git ls-files | head -20

Repository: PlatformNetwork/bounty-challenge

Length of output: 564


🏁 Script executed:

find . -name "Cargo.toml" -o -name "package.json" | head -10

Repository: PlatformNetwork/bounty-challenge

Length of output: 117


🏁 Script executed:

cat -n FIX_PROPOSAL.md

Repository: PlatformNetwork/bounty-challenge

Length of output: 2444


🏁 Script executed:

cat -n Cargo.toml

Repository: PlatformNetwork/bounty-challenge

Length of output: 1121


🏁 Script executed:

cat -n Cargo.toml | head -50

Repository: PlatformNetwork/bounty-challenge

Length of output: 1121


🏁 Script executed:

grep -r "TerminalLinkProvider" --include="*.rs" --include="*.ts" --include="*.tsx"

Repository: PlatformNetwork/bounty-challenge

Length of output: 58


🏁 Script executed:

grep -r "shell_open\|tauri::" --include="*.rs" | head -20

Repository: PlatformNetwork/bounty-challenge

Length of output: 58


🏁 Script executed:

fd -name "*.rs" | head -20

Repository: PlatformNetwork/bounty-challenge

Length of output: 306


🏁 Script executed:

fd -name "*.ts" -o -name "*.tsx" | head -20

Repository: PlatformNetwork/bounty-challenge

Length of output: 306


🏁 Script executed:

cat -n README.md 2>/dev/null || echo "No README.md found"

Repository: PlatformNetwork/bounty-challenge

Length of output: 11196


🏁 Script executed:

git log --oneline --all | grep -i "terminal\|link\|window" | head -10

Repository: PlatformNetwork/bounty-challenge

Length of output: 581


🏁 Script executed:

git log --all --oneline --grep="TerminalLinkProvider\|terminallinkprovider"

Repository: PlatformNetwork/bounty-challenge

Length of output: 179


🏁 Script executed:

git show 6d6625f

Repository: PlatformNetwork/bounty-challenge

Length of output: 50391


🏁 Script executed:

find . -name "*.md" -type f | xargs grep -l "TerminalLinkProvider\|shell_open" 2>/dev/null

Repository: PlatformNetwork/bounty-challenge

Length of output: 93


Proposal contains API confusion — requires revision.

The proposal mixes frontend and backend Tauri APIs. The code snippets show:

  • Line 14: invoke("shell_open", link) — this is a frontend function, not valid in Rust
  • Lines 16-20: WindowBuilder::new() with invalid arguments; this pattern doesn't create external URL windows in Tauri
  • Line 37: tauri::shell::open() is the correct Rust API but contradicts earlier snippets

Correct approaches:

For TypeScript/Frontend (Cortex IDE likely uses this):

import { open } from '@tauri-apps/api/shell';

try {
  await invoke('shell_open', { url: link });
} catch {
  await open(link);
}

For Rust backend:

use tauri::api::shell;

shell::open(&url, None).ok(); // Returns Result, no unwrap needed

Clarify which context applies to TerminalLinkProvider and revise accordingly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@FIX_PROPOSAL.md` around lines 1 - 41, The proposal mixes frontend and backend
Tauri APIs; update TerminalLinkProvider to use the correct API for its runtime:
if TerminalLinkProvider is frontend/TypeScript, replace the incorrect Rust-like
snippets with a try { await invoke('shell_open', { url: link }); } catch { await
open(link); } flow using invoke and open from `@tauri-apps/api` (reference:
invoke, open, TerminalLinkProvider); if TerminalLinkProvider is Rust/backend,
remove any frontend invoke/open usage and call tauri::api::shell::open(&url,
None).ok() (reference: tauri::api::shell::open) and remove the WindowBuilder
approach since it’s not appropriate for opening external URLs. Ensure the code
paths and imports match the chosen context and remove mixed-language examples
(WindowBuilder, invoke) so only the correct API remains.

Comment on lines +7 to +22
```rust
use tauri::{Window, WindowBuilder};

// Assuming `link` is the URL you want to open
let link = "https://example.com";

// Attempt to open the link using shell_open
if let Err(_) = invoke("shell_open", link) {
// Fallback: Open the link using tauri::Window
WindowBuilder::new(tauri::generate_handler![])
.title("External Link")
.url(link)
.build(tauri::generate_context!())
.expect("Failed to create window");
}
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check Tauri version and API documentation for shell::open

# Find Cargo.toml to determine Tauri version
fd -t f "Cargo.toml" -x grep -H "tauri"

# Search for existing shell::open usage patterns in the codebase
rg -n "shell::open|api::shell" --type rust -C 3

Repository: PlatformNetwork/bounty-challenge

Length of output: 58


🌐 Web query:

What is the correct Rust API to open a URL in the default system browser in Tauri v1.x and v2.x? Specifically, how to use shell::open from Rust backend code?

💡 Result:

Tauri v1.x (core API): use tauri::api::shell; shell::open(&app.shell_scope, "https://example.com", None).unwrap; Requires "shell-open-api" feature enabled on tauri crate and "shell": {"open": true} in tauri.conf.json allowlist. Tauri v2.x (plugins): For shell.open (deprecated since 2.1.0, use opener instead): Add tauri-plugin-shell to Cargo.toml, .plugin(tauri_plugin_shell::init), use app.shell.open("https://example.com", None). Requires ShellExt trait and shell:allow-open permission in capabilities. Recommended: tauri-plugin-opener Add tauri-plugin-opener = "2", .plugin(tauri_plugin_opener::init), in setup: let opener = app.opener; opener.open_url("https://example.com", None). Requires opener:allow-open-url permission. Note: shell::open refers to the old v1 core API; v2 uses plugins with similar method on app extension.

Citations:


Multiple critical API errors in the first code snippet.

This code snippet contains several fundamental issues with Tauri API usage:

  1. invoke("shell_open", link) is invalid in Rust: invoke is a JavaScript/TypeScript function from @tauri-apps/api/tauri, not a Rust function. In Rust backend code, use:

    • Tauri v1.x: tauri::api::shell::open(&app.shell_scope, "https://example.com", None) (requires "shell-open-api" feature in Cargo.toml and "shell": {"open": true} in tauri.conf.json)
    • Tauri v2.x: tauri-plugin-shell or tauri-plugin-opener (recommended). For example, with opener: app.opener.open_url("https://example.com", None) (requires appropriate feature plugins and permissions)
  2. WindowBuilder::new(tauri::generate_handler![]) is incorrect: WindowBuilder::new() does not accept a handler array. The generate_handler! macro is used when creating the Tauri app to register commands, not when building windows.

  3. .build(tauri::generate_context!()) is incorrect: The build() method requires a reference to App or AppHandle, not a Context.

  4. Unused import: Window is imported but never used.

  5. Wrong approach: This would open the URL in a new Tauri window (embedded webview), not in the system's default external browser, defeating the stated purpose.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@FIX_PROPOSAL.md` around lines 7 - 22, The snippet misuses frontend invoke and
window APIs: replace the invalid invoke("shell_open", ...) call with the proper
Rust API (e.g., tauri::api::shell::open(&app.shell_scope, "https://example.com",
None) for Tauri v1 or use the recommended
tauri-plugin-opener/opener.open_url(...) approach for v2), remove the incorrect
WindowBuilder::new(tauri::generate_handler![]) /
.build(tauri::generate_context!()) usage (do not call generate_handler! or
generate_context! when building windows) and drop the unused Window import; also
ensure the required "shell-open" feature and tauri.conf.json permissions (or the
appropriate plugin and Cargo features) are enabled so the call opens the URL in
the system external browser rather than creating an embedded window.

Comment on lines +28 to +39
```rust
use tauri::Window;

// Assuming `link` is the URL you want to open
let link = "https://example.com";

// Attempt to open the link using shell_open
if let Err(_) = invoke("shell_open", link) {
// Fallback: Open the link using the open command
tauri::shell::open(link).expect("Failed to open link");
}
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

❓ Verification inconclusive

Script executed:

#!/bin/bash
# Find the actual shell::open usage in the codebase to determine correct API

rg -n "use tauri.*shell" --type rust -C 2
rg -n "shell::open" --type rust -C 3

Repository: PlatformNetwork/bounty-challenge


Repository: PlatformNetwork/bounty-challenge
Exit code: 1


What is the correct function signature for tauri::shell::open in Tauri v1.x versus v2.x? Include parameter types and return types.


Tauri v1.x (JavaScript): open(path: string, openWith?: string): Promise from '@tauri-apps/api/shell' Tauri v1.x (Rust): tauri::api::shell::open(path: impl Into, with: Optiontauri::api::shell::Program, scope: &ShellScope) -> Result<, Error> Tauri v2.x (JavaScript, deprecated in shell plugin): open(path: string, openWith?: string): Promise from '@tauri-apps/plugin-shell'. Recommended: use '@tauri-apps/plugin-opener' with openPath(path: string, openWith?: string): Promise or openUrl(url: string, openWith?: string): Promise Tauri v2.x (Rust): shell.open(&self, path: impl Into, with: Option<tauri_plugin_shell::open::Program>) -> Result<, Error> on the Shell instance (deprecated since 2.1.0, use tauri-plugin-opener::OpenerExt instead with opener.open_path(path: &str, with: Option<&str>) -> Result<, Error> etc.)

Citations:


Incorrect invoke() usage and incomplete Tauri shell API implementation.

Issues in this snippet:

  1. invoke() error persists: invoke("shell_open", link) is JavaScript API, not valid Rust code.

  2. Unused import: Window is imported but never used.

  3. Incomplete API implementation: The signature tauri::shell::open(link) is missing required parameters and context:

    • Tauri v1.x: API is tauri::api::shell::open(path, with: Option<Program>, scope: &ShellScope) -> Result<(), Error>. Requires a ShellScope parameter and optional program reference.
    • Tauri v2.x: Access via the Shell plugin instance (requires initialization), or use the newer recommended tauri-plugin-opener (v2.1.0+) with open_path() or openUrl() methods.

The code snippet oversimplifies the API call and won't compile as written. Verify which Tauri version this is targeting and use the appropriate module path and parameters.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@FIX_PROPOSAL.md` around lines 28 - 39, The snippet uses the JavaScript
invoke("shell_open", ...) and an unused Window import and calls
tauri::shell::open(...) with the wrong signature; fix by removing the incorrect
invoke usage and the unused Window import, then implement the correct Tauri
shell API for your targeted version: for Tauri v1 use
tauri::api::shell::open(path, Option<Program>, &ShellScope) providing a valid
ShellScope, or for Tauri v2 initialize and call the Shell plugin API (or switch
to tauri-plugin-opener and call open_path()/openUrl()); update the call site
replacing tauri::shell::open with the proper module path and required parameters
(ShellScope or plugin instance) so the code compiles.

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