Skip to content

fix(desktop): align tray, shortcuts, and macOS chrome with current CMP desktop guidance#6205

Merged
jamesarich merged 2 commits into
mainfrom
claude/desktop-kotlin-best-practices-3c8843
Jul 10, 2026
Merged

fix(desktop): align tray, shortcuts, and macOS chrome with current CMP desktop guidance#6205
jamesarich merged 2 commits into
mainfrom
claude/desktop-kotlin-best-practices-3c8843

Conversation

@jamesarich

@jamesarich jamesarich commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Audited the desktop shell against JetBrains' official Compose Multiplatform desktop docs (kotlin-multiplatform-dev-docs @ HEAD; newest stable CMP = 1.11.1, which is our pin). The shell already matches current guidance almost everywhere — this PR fixes the three real gaps the audit surfaced, plus a JDK-25 gap in the offline Flatpak manifest that this PR's CI run exposed.

🐛 Bug Fixes

  • Hide-to-tray no longer wipes UI state — closing to the tray dropped the Window from composition, destroying the navigation backstack and scroll positions; restoring from the tray restarted the UI from scratch. Now uses the documented minimize-to-tray pattern (Window(visible = …)) so the compose tree survives the round trip.
  • Keyboard shortcuts now work on Windows/Linux — the handler checked only the meta key, so Cmd+1–4/Comma/Slash/Q were dead on the MSI/Deb/RPM/AppImage builds. Shortcuts now use the platform-conventional modifier: Cmd on macOS, Ctrl elsewhere. The Ctrl path requires Alt to be up, because Windows reports AltGr as Ctrl+Alt — otherwise typing AltGr characters (e.g. @ on German layouts = AltGr+Q) would fire shortcuts, including quit.
  • macOS title bar follows dark mode — added the documented -Dapple.awt.application.appearance=system jvmArg; previously the window chrome stayed light while the app content was dark.
  • Offline Flatpak build provisions the JDKs the 2.8 tree actually needs — the JBR 25 toolchain bump (chore(desktop): bump Compose Desktop runtime from JBR 21 to JBR 25 #6203) raised desktopApp to languageVersion=25, but the offline manifest still shipped only the openjdk21 SDK extension; with toolchain auto-provisioning disabled (the build is offline by design), compileJava failed on both arches. The manifest now ships dual JDKs — openjdk21 for the Gradle daemon (gradle-daemon-jvm.properties pins toolchainVersion=21) and openjdk25 for the desktop toolchain — with the coupling documented. Also realigned the manifest's bundled Gradle dist with the 9.6.1 wrapper (it was silently passing on 9.6.0). Surfaced here rather than on chore(desktop): bump Compose Desktop runtime from JBR 21 to JBR 25 #6203 because verify-flatpak only runs on PRs touching desktop paths.

🧹 Chores

  • Flatpak verification now targets the official packaging repo — CI and scripts/verify-flatpak/verify.sh clone flathub/org.meshtastic.MeshtasticDesktop (what Flathub actually builds, seeded from vidplace7's dev repo on 2026-07-08) instead of the dev fork, including the master-vs-main default-branch fix in the script's refresh path.

🧹 Audit notes (no change needed)

Testing Performed
Full baseline green on the JBR 25 toolchain (re-run after the AltGr guard): spotlessApply spotlessCheck detekt assembleDebug test allTests, 0 failures. The Flatpak manifest fix is exercised by this PR's own verify-flatpak jobs.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • macOS desktop title bars now follow the system light/dark appearance.
    • Desktop windows stay mounted for smoother show/hide transitions.
  • Bug Fixes
    • Keyboard shortcuts now use the correct modifier key across macOS, Windows, and Linux.
  • Build & Packaging
    • Updated the offline Flatpak build to include OpenJDK 25 alongside OpenJDK 21, and bumped the bundled Gradle distribution to 9.6.1.
    • Switched offline Flatpak verification/build to the official Flathub packaging repository, with related documentation updates.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Desktop window visibility now persists across tray transitions, keyboard shortcuts use platform-appropriate modifiers, macOS JVM configuration enables system title-bar appearance, and offline Flatpak verification targets Flathub with OpenJDK 25 and Gradle 9.6.1.

Changes

Desktop behavior and Flatpak verification

Layer / File(s) Summary
Persistent window visibility
desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt
The desktop window remains composed after readiness and is shown or hidden through the visible parameter.
Platform appearance and shortcuts
desktopApp/build.gradle.kts, desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt
macOS system appearance is configured, and shortcut detection selects Cmd on macOS or Ctrl without Alt on other platforms.
Offline Flatpak toolchain
scripts/verify-flatpak/desktop-offline.yaml
The offline manifest adds the OpenJDK 25 SDK extension and installation path alongside OpenJDK 21, and updates the bundled Gradle distribution from 9.6.0 to 9.6.1.
Flathub verification workflow
.github/workflows/verify-flatpak.yml, scripts/verify-flatpak/verify.sh, scripts/verify-flatpak/README.md
The verification workflow and documentation target the official Flathub repository and its master branch, with updated offline rebuild instructions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TrayState
  participant MeshtasticWindow
  participant ComposeWindow
  TrayState->>MeshtasticWindow: provide visibility state
  MeshtasticWindow->>ComposeWindow: show or hide window
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main desktop-shell changes to tray behavior, shortcuts, and macOS appearance.

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

@github-actions github-actions Bot added bugfix PR tag desktop Desktop target labels Jul 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt (1)

361-373: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a type alias to avoid repeated FQN for KeyEvent.

The fully-qualified androidx.compose.ui.input.key.KeyEvent receiver/parameter type (Lines 364, 369) suggests a naming clash with another KeyEvent in this file's imports. A typealias ComposeKeyEvent = androidx.compose.ui.input.key.KeyEvent at the top of the file would improve readability without behavior change. The modifier-detection logic itself (Cmd on macOS, Ctrl elsewhere) is correct.

♻️ Optional refactor
+private typealias ComposeKeyEvent = androidx.compose.ui.input.key.KeyEvent
+
 private val isMacOS = DesktopOS.current() == DesktopOS.MacOS

 /** Platform-conventional shortcut modifier: Cmd on macOS, Ctrl on Windows/Linux. */
-private val androidx.compose.ui.input.key.KeyEvent.isShortcutModifierPressed: Boolean
+private val ComposeKeyEvent.isShortcutModifierPressed: Boolean
     get() = if (isMacOS) isMetaPressed else isCtrlPressed

 /** Handles Cmd/Ctrl-key shortcuts. Returns `true` if the event was consumed. */
 private fun handleKeyboardShortcut(
-    event: androidx.compose.ui.input.key.KeyEvent,
+    event: ComposeKeyEvent,
     multiBackstack: MultiBackstack,
     exitApplication: () -> Unit,
 ): Boolean {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt` around lines 361 -
373, Replace the repeated fully qualified KeyEvent references in the
isShortcutModifierPressed extension and handleKeyboardShortcut with a file-level
typealias such as ComposeKeyEvent, preserving the existing shortcut behavior and
avoiding conflicts with the other KeyEvent import.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt`:
- Around line 361-373: Replace the repeated fully qualified KeyEvent references
in the isShortcutModifierPressed extension and handleKeyboardShortcut with a
file-level typealias such as ComposeKeyEvent, preserving the existing shortcut
behavior and avoiding conflicts with the other KeyEvent import.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e65b15fb-9226-4b24-8500-f5798399076d

📥 Commits

Reviewing files that changed from the base of the PR and between 8ccc53c and 1ef7dcb.

📒 Files selected for processing (2)
  • desktopApp/build.gradle.kts
  • desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 56e0b285-bce5-4e35-9dc7-08e64e4c8840

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef7dcb and 8453071.

📒 Files selected for processing (1)
  • desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt
 __________________________________________________
< I want to be a VS Code extension when I grow up. >
 --------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
📝 Walkthrough

Walkthrough

Desktop window visibility now persists across tray transitions, keyboard shortcuts use platform-appropriate modifiers, and macOS JVM configuration enables system title-bar appearance.

Changes

Desktop behavior

Layer / File(s) Summary
Persistent window visibility
desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt
The desktop window remains composed after readiness and is shown or hidden through the visible parameter.
Platform appearance and shortcuts
desktopApp/build.gradle.kts, desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt
macOS system appearance is configured, and shortcut detection selects Cmd on macOS or Ctrl on other platforms.

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

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the desktop tray, shortcut, and macOS appearance updates in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@github-actions github-actions Bot added the repo Repository maintenance label Jul 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
scripts/verify-flatpak/verify.sh (1)

58-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Rename VID_REPO to reflect the Flathub repository.

The variable now points to Flathub, so the stale VID_REPO name can mislead future maintenance and cause incorrect repository updates.

-VID_REPO="https://github.com/flathub/org.meshtastic.MeshtasticDesktop.git"
+FLATHUB_REPO="https://github.com/flathub/org.meshtastic.MeshtasticDesktop.git"

Update all references accordingly. As per coding guidelines, keep naming aligned with AGENTS.md and the Flatpak verification guidance in scripts/verify-flatpak/README.md.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/verify-flatpak/verify.sh` around lines 58 - 60, Rename the VID_REPO
variable to a name that clearly identifies the Flathub repository, following
conventions in AGENTS.md and scripts/verify-flatpak/README.md, and update every
reference to the variable throughout scripts/verify-flatpak/verify.sh.

Source: Coding guidelines

.github/workflows/verify-flatpak.yml (1)

77-80: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Pin the clone to the same branch used by the local verifier.

This clone follows GitHub’s default branch, while scripts/verify-flatpak/verify.sh:99-100 explicitly resets to origin/master. If the Flathub default changes, CI and local verification can build different packaging revisions.

Canonical fix
           git clone --depth 1 --recurse-submodules \
+            --branch master \
             https://github.com/flathub/org.meshtastic.MeshtasticDesktop.git \

As per coding guidelines, keep this workflow aligned with AGENTS.md and the CI verification playbook in .skills/testing-ci/SKILL.md.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/verify-flatpak.yml around lines 77 - 80, Update the “Clone
the Flathub packaging repo” step to explicitly clone the master branch, matching
the origin/master reset performed by verify.sh and keeping CI aligned with local
verification.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/verify-flatpak.yml:
- Around line 77-80: Update the “Clone the Flathub packaging repo” step to
explicitly clone the master branch, matching the origin/master reset performed
by verify.sh and keeping CI aligned with local verification.

In `@scripts/verify-flatpak/verify.sh`:
- Around line 58-60: Rename the VID_REPO variable to a name that clearly
identifies the Flathub repository, following conventions in AGENTS.md and
scripts/verify-flatpak/README.md, and update every reference to the variable
throughout scripts/verify-flatpak/verify.sh.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dd2f09e6-6598-49c9-b319-84ef7a65acce

📥 Commits

Reviewing files that changed from the base of the PR and between 031d214 and 42003af.

📒 Files selected for processing (4)
  • .github/workflows/verify-flatpak.yml
  • scripts/verify-flatpak/README.md
  • scripts/verify-flatpak/desktop-offline.yaml
  • scripts/verify-flatpak/verify.sh
✅ Files skipped from review due to trivial changes (1)
  • scripts/verify-flatpak/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/verify-flatpak/desktop-offline.yaml

@jamesarich
jamesarich force-pushed the claude/desktop-kotlin-best-practices-3c8843 branch from 42003af to 8453071 Compare July 10, 2026 22:17
@jamesarich

Copy link
Copy Markdown
Collaborator Author

Trimmed the 4 Flatpak/JDK-25 commits off this branch — they now live (identical patches) in #6208, which owns the JDK 25 story. This PR is back to purely the CMP desktop fixes.

Heads-up on CI: verify-flatpak's offline job will fail here until #6208 merges — main's offline manifest still only ships openjdk21 while desktopApp already requires a JDK 25 toolchain, which is exactly what those trimmed commits were fixing. Land #6208 first, then update this branch to green it up.

jamesarich and others added 2 commits July 10, 2026 18:36
…P desktop guidance

Audit of the desktop shell against JetBrains' official Compose
Multiplatform desktop docs (CMP 1.11.1, our pin) surfaced three gaps:

- Hide-to-tray dropped the Window from composition, destroying the
  navigation backstack and scroll positions; use the documented
  Window(visible=) pattern so the UI tree survives a tray round trip
- Keyboard shortcuts checked only the meta key, leaving them dead on
  the Windows/Linux distributions; use the platform-conventional
  modifier (Cmd on macOS, Ctrl elsewhere)
- Add -Dapple.awt.application.appearance=system so the macOS title bar
  follows the system dark theme

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Windows reports AltGr as Ctrl+Alt, so typing AltGr characters (e.g. @ on
German layouts = AltGr+Q) would have fired shortcuts — including quit.
Require Alt up on the Ctrl path. Also import KeyEvent instead of
repeating the FQN (no clash exists in this file).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jamesarich
jamesarich force-pushed the claude/desktop-kotlin-best-practices-3c8843 branch from 8453071 to d9f87f3 Compare July 10, 2026 23:36
@jamesarich
jamesarich enabled auto-merge July 10, 2026 23:40
@jamesarich
jamesarich added this pull request to the merge queue Jul 10, 2026
Merged via the queue into main with commit a57c144 Jul 10, 2026
20 checks passed
@jamesarich
jamesarich deleted the claude/desktop-kotlin-best-practices-3c8843 branch July 10, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag desktop Desktop target repo Repository maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant