Skip to content

fix(linux): keep launcher D-Bus handler alive for the service lifetime - #1032

Merged
Xoshbin merged 1 commit into
Xoshbin:mainfrom
abdelrahman-alshurafa:fix/linux-launcher-dbus-handler-lifetime
Nov 12, 2026
Merged

Xoshbin merged 1 commit into
Xoshbin:mainfrom
abdelrahman-alshurafa:fix/linux-launcher-dbus-handler-lifetime

Conversation

@abdelrahman-alshurafa

@abdelrahman-alshurafa abdelrahman-alshurafa commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1021

What

The crate extraction (0d66e29) left the launcher handler's only strong Arc in a local of start(), so it dropped when start() returned and the endpoint's Weak could never upgrade — every asyar-summon failed with "launcher handler is unavailable" from the first call after startup. LauncherDbusService now owns the handler alongside the connection, as agreed in #1021.

Testing

  • New regression test service_keeps_handler_alive_after_caller_drops_arc: drops the caller's Arc right after start() and completes a Toggle over the bus — the exact scenario the refactor broke. Runs under dbus-run-session, which CI already provides.
  • cargo test -p asyar-platform launcher_dbus: 4/4 green locally under dbus-run-session.
  • Smoke tested on Fedora 45 / Wayland (Intel i915): dev build summons via asyar-summon --dev in ~2–15 ms with the window toggling reliably; pre-fix the same call failed hard on every attempt (reproduced on a completely fresh install).
  • cargo fmt and cargo clippy -p asyar-platform --all-targets clean.
  • pnpm check:ci: all suites pass except the pre-existing asyar-sdk workerEntries failure (sdk-playground entry references window/document), which reproduces identically on main and is unrelated to this change.

Summary by CodeRabbit

  • Bug Fixes
    • Linux launcher actions now remain available for the lifetime of the session-bus service, even after the original caller releases its reference to the action handler. This improves reliability for actions such as toggling and helps prevent them from becoming unavailable during use.

The crate extraction (0d66e29) left the handler's only strong Arc in a local of start(), so it dropped when start() returned and the endpoint's Weak could never upgrade - every asyar-summon failed with 'launcher handler is unavailable' from the first call after startup. LauncherDbusService now owns the handler alongside the connection.

Fixes Xoshbin#1021
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Linux launcher D-Bus service now retains a strong reference to its action handler. A Linux-only session-bus test verifies that the service can dispatch Toggle after the caller drops its reference. The formatter parameter syntax is also updated.

Changes: Linux D-Bus handler lifetime

Layer / File(s) Summary
Retain and verify the handler
asyar-launcher/src-tauri/crates/asyar-platform/src/linux/launcher_dbus.rs
LauncherDbusService stores a strong reference to the handler, and start clones the supplied Arc into the service. A Linux-only session-bus test drops the caller’s reference, invokes Toggle, and checks that the handler records the action. The formatter parameter syntax is also updated.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: xoshbin

Merge Risk: Minimal · up to 119fd

The change keeps the launcher handler alive for the service lifetime, which fixes the "launcher handler is unavailable" failure after startup. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the Linux launcher D-Bus service now keeps its action handler alive for the service lifetime. The raw summary confirms that LauncherDbusService now retains a strong re…
Linked Issues check Passed [#1021] Requirement: LauncherDbusService must own an Arc for the service lifetime, alongside its connection, so the endpoint's Weak handler reference can upgrade after start…
Out of Scope Changes check Passed Whole-PR diff against merge base 23ef13f touches only asyar-platform/src/linux/launcher_dbus.rs. Changes: (1) the handler ownership field and its clone in start(), which implement #1021; (2) the doc …
Full details: Title check

Explanation

The title names the main change: the Linux launcher D-Bus service now keeps its action handler alive for the service lifetime. The raw summary confirms that LauncherDbusService now retains a strong reference to the handler, and the linked objectives describe the same fix for the 'launcher handler is unavailable' failure. The conventional-commit prefix 'fix(linux)' matches the changed file under asyar-platform/src/linux. The title is 70 characters, which is within a reasonable length for a single-sentence title.

Full details: Linked Issues check

Explanation

[#1021] Requirement: LauncherDbusService must own an Arc<dyn LauncherActionHandler> for the service lifetime, alongside its connection, so the endpoint's Weak handler reference can upgrade after start() returns. At head 119fd91, the struct gains a field _handler: Arc&lt;dyn LauncherActionHandler&gt;, and start sets it with Arc::clone(handler) before returning the service. The caller's Arc can drop without losing the handler. The regression test service_keeps_handler_alive_after_caller_drops_arc drops the caller's Arc after start(), performs a Toggle over the session bus, and asserts the handler recorded LauncherAction::Toggle. This covers the reported failure. The test requires a session bus, which the PR states CI provides under dbus-run-session. I did not run the test. The suggested cold-start fallback change is explicitly out of scope per the PR objectives and is not required here.

Full details: Out of Scope Changes check

Explanation

Whole-PR diff against merge base 23ef13f touches only asyar-platform/src/linux/launcher_dbus.rs. Changes: (1) the handler ownership field and its clone in start(), which implement #1021; (2) the doc comment update on LauncherDbusService, which documents the same change; (3) the regression test module, which supports #1021; (4) a signature edit in fmt::Display for LauncherDbusError, changing Formatter&lt;'_&gt; to Formatter. Change (4) does not relate to the bug. It has no behavior effect and appears to be a lint or style edit made during the clippy run. It is minor and does not affect the fix. The app-side src-tauri start() file is not changed in this PR. No unrelated functional change was found.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b8efbc4d-fdce-4c19-9988-cfda30a016a9
Commits

Reviewing files that changed from the base of the PR and between 23ef13f and 119fd91.

Files selected for processing: 1

  • asyar-launcher/src-tauri/crates/asyar-platform/src/linux/launcher_dbus.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@Xoshbin
Xoshbin merged commit 09af2a7 into Xoshbin:main Nov 12, 2026
8 checks passed
@Xoshbin

Xoshbin commented Nov 12, 2026

Copy link
Copy Markdown
Owner

thanks for putting this together and testing it on Fedora! keeping the Arc on LauncherDbusService is super clean and glad you kept asyar-summon strict on errors too.

Xoshbin added a commit that referenced this pull request Nov 13, 2026
* fix(windows): stop caching generic shortcut icons

Start Menu .lnk icons were extracted with SHGetFileInfoW, which returns the
shell's generic shortcut icon (not a failure) while a target is mid-update,
e.g. a Scoop `current` junction being recreated. extract_app_icon then cached
that placeholder, and because a .lnk's own mtime does not change when its
target does, the mtime-based freshness check never invalidated it.

- asyar-platform/windows: resolve .lnk via IShellLinkW and extract from the
  icon location or target with PrivateExtractIconsW; a missing target is a
  retryable miss. Falls back to SHGetFileInfoW. Own COM init via an RAII
  guard, since callers run on pooled threads.
- application/service: negative icon markers expire after an hour instead of
  being trusted until the source mtime changes; one-time purge of cached
  *.lnk.png and markers via an icon cache version file.

* feat(i18n): add French (fr) translation (#1029)

* feat(i18n): add French (fr) translation catalog

Adds a full French catalog (1961 keys, parity with en.json) registered
under the bare fr tag so fr-FR, fr-CA, fr-BE and fr-CH all resolve to it.
Also adds French native strings (tray menu, window titles) in native.rs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H3ViHGkihBGd5YvHKpQMmg

* fix(i18n): French onboarding locale and shorter labels

Load the system locale in the onboarding webview, which never called
i18nService.init() and so always rendered in English.

Shorten five French strings that were truncated or wrapped where the
English fits: settings sidebar (account subtitle, built-in features,
privacy), backup password placeholder, AI onboarding web search card.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(i18n): flatten nested parentheses in French CLI connection label

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H3ViHGkihBGd5YvHKpQMmg

* fix(i18n): avoid doubled "CLI" in French CLI connection description

{name} already ends with "CLI (binary)", so "votre CLI {name} locale"
rendered as "votre CLI Claude Code CLI (claude) locale".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(i18n): shorten French Record Hotkey button

"Enregistrer un raccourci" wrapped onto two lines in the Shortcut
column of the command tables. "Définir" fits and is not confused with
"Enregistrer" (Save).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(i18n): format French locale test and list fr in docs

Prettier wanted the new French assertion on one line, which failed
`pnpm format:check`, and adding the catalog left the language lists in
README and the docs stale.

* fix(i18n): add missing French store installation status key

#1025 added features.store.ui.installation_status_failed to en.json, so the
catalog parity test failed and French Store users saw the English error.

---------

Co-authored-by: Hugo <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Xoshbin <[email protected]>

* chore(repo): add PR template, smoke-test checks, and contribution skill (#1033)

* chore(repo): add PR template, smoke-test checks, and contribution skill

- Add `.github/PULL_REQUEST_TEMPLATE.md` with Before/After User POV, affected areas, manual smoke-test confirmation, AI usage, and Asyar boundaries
- Add `scripts/check-pr.mjs`, unit tests, and `.github/workflows/pr-checks.yml` (with bot and docs/locale-only exemptions)
- Add `.agents/skills/asyar-contribution/SKILL.md` and `.coderabbit.yaml`
- Update `CONTRIBUTING.md` with PR description, smoke-test, and AI-assisted contribution guidelines

* fix(repo): tighten PR check validation and local docs command

* chore(repo): add hot-path performance guardrails to PR checks

* fix(repo): validate each required PR boundary checkbox by label

* fix(linux): keep launcher D-Bus handler alive for the service lifetime (#1032)

The crate extraction (0d66e29) left the handler's only strong Arc in a local of start(), so it dropped when start() returned and the endpoint's Weak could never upgrade - every asyar-summon failed with 'launcher handler is unavailable' from the first call after startup. LauncherDbusService now owns the handler alongside the connection.

Fixes #1021

* fix(shell): make shell.spawn work from extension workers (#1034)

Background workers run as Web Workers, not iframes. shell.spawn failed
there in two ways:

- ShellServiceProxy used window.addEventListener / window.parent, so it
  threw "Can't find variable: window" inside a worker.
- StreamDispatcher only posted stream events to iframes, so a worker
  never received onChunk/onDone/onError.

StreamDispatcher now delivers through postToExtension, which targets the
Web Worker for worker-origin streams and the view iframe otherwise. The
SDK gets a small hostChannel helper (listenToHost/postToHost) that uses
window in an iframe and self in a worker; ShellServiceProxy uses it for
listening and abort.

Fixes #1028

* chore(ci): exempt repository owner PRs from PR description check (#1035)

* chore(ci): exempt repository owner PRs from PR description check

* chore(vscode): always use PR template for pull request descriptions

* fix(sdk): make AiServiceProxy.stream work in extension workers (#1036)

Use listenToHost/postToHost instead of window directly so AI stream
events and aborts work in Web Workers where window is undefined.

* fix(icons): resolve Windows custom scheme URLs and uncrop HiDPI app icons (#1019)

- Support and normalize `http://asyar-{icon,thumb,extension}.localhost/` URLs
  only on Windows in `icons.rs`, `icon.ts`, and `AppIcon.svelte`, while keeping
  `http://*.localhost/` rejected on macOS and Linux to prevent loopback requests
  (fixes the regression introduced after #949 and left open by #1006).
- Emit Windows `http://asyar-icon.localhost/` URLs from `icons/remote.rs` so
  cached remote icons load in WebView2.
- Render Settings → Applications icons through `<AppIcon>` for consistent
  scheme normalization and `object-fit: contain` sizing.
- Fix `getHostPlatform()` matching `/Win/i` against `"darwin"` user agents in
  jsdom fallback mode.
- Query native `BITMAP` dimensions via `GetObjectW` instead of hardcoding `32x32`
  in Windows `extract_icon` (and avoid selecting `hbmColor` before `GetDIBits`),
  so HiDPI icons are not cropped to their top-left corner.
- Bump Windows app icon cache keys (`w2_`) so previously cached cropped PNGs
  regenerate automatically on next sync.

* chore(sdk): release 4.18.0 (#1026)

* fix(sdk,oauth): make OAuth and Settings proxies work in extension workers (#1037)

- Use listenToHost in OAuthServiceProxy and SettingsServiceProxy instead of window
- Deliver oauth callback results to active workerHost in addition to iframes

* chore(sdk): release 4.18.1 (#1038)

* fix(release): mark SDK releases as stable, not prerelease (#1040)

* fix(release): mark SDK releases as stable, not prerelease

* fix(release): derive SDK prerelease flag from version, keep SDK out of latest

* fix(release): read SDK version from asyar-sdk/package.json for prerelease detection

* chore: release 0.1.2-0 (#1039)

* chore(funding): use Patreon as the sole sponsor link (#1042)

* fix(extensions): resolve worker entry reload race and deduplicate error feedback (#1041)

* fix(extensions): resolve worker entry reload race and deduplicate error feedback

- Resolve missing worker entry paths asynchronously via ExtensionManager
  fallback when `asyar:iframe:mount` arrives before reload completes, and
  skip mounting cleanly when blocked by a missing runtime
- Stage extension reloads before swapping `manifestsById` and serialize
  concurrent `reloadExtensions()` calls to prevent `Unknown extension` IPC
  errors during reloads
- Log worker startup and uncaught errors to `logService.error`
- Deduplicate identical diagnostic errors in `FeedbackChannel::publish` so
  dismissing clears them in one click, and clear extension feedback on disable

* fix(extensions): address review feedback on reload serialization and diagnostic matching

* fix(windows): stop caching generic shortcut icons

Start Menu .lnk icons were extracted with SHGetFileInfoW, which returns the
shell's generic shortcut icon (not a failure) while a target is mid-update,
e.g. a Scoop `current` junction being recreated. extract_app_icon then cached
that placeholder, and because a .lnk's own mtime does not change when its
target does, the mtime-based freshness check never invalidated it.

- asyar-platform/windows: resolve .lnk via IShellLinkW and extract from the
  icon location or target with PrivateExtractIconsW; a missing target is a
  retryable miss. Falls back to SHGetFileInfoW. Own COM init via an RAII
  guard, since callers run on pooled threads.
- application/service: negative icon markers expire after an hour instead of
  being trusted until the source mtime changes; one-time purge of cached
  *.lnk.png and markers via an icon cache version file.

* wip: ExtractedIcon outcome (icon fix for #1031)

* fix(windows): soft-cache .lnk placeholder icons and bump icon cache key

Resolve .lnk shortcuts with IShellLinkW and extract icons via
PrivateExtractIconsW so a missing or locked target yields a soft-cached
placeholder instead of the shell's generic shortcut icon cached as
forever-fresh.

- extract_app_icon distinguishes ExtractedIcon::Icon from Placeholder;
  placeholders are written but never stamped with source_mtime, so they
  are re-extracted on the next scan and self-repair when the target
  reappears.
- .missing marker freshness also requires an unchanged source mtime;
  the 1-hour TTL applies on Windows only, so macOS/Linux keep their old
  behaviour.
- Replace the once-off purge of *.lnk.png / *.missing with a cache-key
  version bump (w2_ -> w3_) so old shortcut entries are orphaned instead
  of deleted (clipboard history icons in icon_cache are untouched).
- Update the ignored Windows lnk test to assert ExtractedIcon outcomes,
  and add marker/placeholder tests that run on every OS.

* test(icons): expect unstamped fallback cache after extraction failure

---------

Co-authored-by: Hugo <[email protected]>
Co-authored-by: Hugo <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Xoshbin <[email protected]>
Co-authored-by: abdelrahman-alshurafa <[email protected]>
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.

[Bug]: Linux: asyar-summon always fails with "launcher handler is unavailable" — handler Arc dropped at startup

2 participants