Skip to content

feat(macos): expose set_activate_ignoring_other_apps.#15223

Open
Kokoro2336 wants to merge 5 commits into
tauri-apps:devfrom
Kokoro2336:feat/set-activate-ignoring-other-apps
Open

feat(macos): expose set_activate_ignoring_other_apps.#15223
Kokoro2336 wants to merge 5 commits into
tauri-apps:devfrom
Kokoro2336:feat/set-activate-ignoring-other-apps

Conversation

@Kokoro2336
Copy link
Copy Markdown
Contributor

This PR closes issue #15017

Expose set_activate_ignoring_other_apps as an API in App.

@Kokoro2336 Kokoro2336 marked this pull request as ready for review April 11, 2026 06:07
@Kokoro2336 Kokoro2336 requested a review from a team as a code owner April 11, 2026 06:07
@Kokoro2336 Kokoro2336 changed the title feat: expose set_activate_ignoring_other_apps. feat(macos): expose set_activate_ignoring_other_apps. Apr 11, 2026
@Kokoro2336
Copy link
Copy Markdown
Contributor Author

Just from a simple test, the new API works as expected.

@Dcatfly
Copy link
Copy Markdown

Dcatfly commented Apr 18, 2026

Is there an expected release version for this PR?

@Kokoro2336
Copy link
Copy Markdown
Contributor Author

Is there an expected release version for this PR?

idk. The pr is waiting for review and you can ask the maintainer.

Comment thread crates/tauri-runtime/src/lib.rs Outdated
Comment thread crates/tauri/src/app.rs Outdated
Comment thread crates/tauri/src/app.rs
@Qodo-Free-For-OSS
Copy link
Copy Markdown

Hi, App::set_activate_ignoring_other_apps unconditionally unwraps self.runtime, so calling it after App::run_return (which take()s the runtime) will panic and crash the app. This makes a PRE-RUN-ONLY misuse result in a hard production crash, unlike similar macOS App APIs that handle the None case.

Severity: action required | Category: reliability

How to fix: Avoid unwrap; mirror existing pattern

Agent prompt to fix - you can give this to your LLM of choice:

Issue description

App::set_activate_ignoring_other_apps uses self.runtime.as_mut().unwrap(), which can panic after the runtime is moved out by App::run_return.

Issue Context

Other macOS-only App methods (e.g. set_activation_policy, set_dock_visibility) avoid panics by using if let Some(runtime) and otherwise delegating to the AppHandle equivalent.

Fix Focus Areas

  • crates/tauri/src/app.rs[1250-1306]
  • crates/tauri/src/app.rs[1279-1285]
  • crates/tauri/src/app.rs[1401-1406]

Implementation notes

  • Change set_activate_ignoring_other_apps to:
    • if let Some(runtime) = self.runtime.as_mut() { runtime.set_activate_ignoring_other_apps(ignore); } else { ... }
  • Prefer adding a matching AppHandle::set_activate_ignoring_other_apps(&self, ...) -> Result<()> (and a RuntimeHandle method in tauri-runtime) so the fallback can be let _ = self.app_handle().set_activate_ignoring_other_apps(ignore); like the other APIs.
  • If you intentionally want a hard failure, replace unwrap() with an explicit expect("...") documenting the PRE-RUN constraint; but this would still be inconsistent with existing APIs.

Found by Qodo code review

@Legend-Master Legend-Master added this to the 2.12 milestone May 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Package Changes Through b47a722

There are 3 changes which include tauri-runtime-wry with minor, tauri-runtime with minor, tauri with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-runtime 2.11.0 2.12.0
tauri-runtime-wry 2.11.0 2.12.0
tauri 2.11.0 2.12.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Kokoro2336
Copy link
Copy Markdown
Contributor Author

Kokoro2336 commented May 2, 2026

The API can only be called when the app starts. It's invalid to call it at runtime. When this happens, we should fail fast. .unwrap() is ok here.

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.

[feat] Expose set_activate_ignoring_other_apps from tao on macOS

5 participants