Skip to content

feat: use the AvailableModes API in cardwire-cli and -gui - #168

Merged
luytan merged 4 commits into
mainfrom
use-available-modes-api
Aug 8, 2026
Merged

feat: use the AvailableModes API in cardwire-cli and -gui#168
luytan merged 4 commits into
mainfrom
use-available-modes-api

Conversation

@luytan

@luytan luytan commented Aug 8, 2026

Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and if applicable, a related issue.

If this PR introduce a new feature, explain your motivations

Fixes # (issue)

TODO

  • Copy-Paste this line

Checklist:

  • My code follows the style guidelines of this project (cargo fmt)
  • 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 mdBook documentation
  • My changes generate no new warnings (clippy/clang)
  • New and existing unit tests pass locally with my changes (either use nix flake check or wait for the ci)

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@luytan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: aec9f86f-0b99-42d6-a6b2-0d657da63821

📥 Commits

Reviewing files that changed from the base of the PR and between 47b4436 and 9b457ea.

📒 Files selected for processing (3)
  • crates/cardwire-cli/src/main.rs
  • crates/cardwire-gui/src/app.rs
  • crates/cardwire-gui/src/gui_config.rs
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Mode lists are now retrieved dynamically and stay synchronized across the CLI, settings pages, main interface, and system tray.
    • Available modes refresh automatically after GPU changes.
    • Added clearer handling and reporting when the background service is unavailable.
  • Bug Fixes

    • Improved D-Bus connection error handling and startup diagnostics.
    • Primary tray clicks now open the GUI by default instead of switching modes.
    • Updated mode naming for consistent configuration handling.

Walkthrough

The CLI and GUI now retrieve available modes from D-Bus and use them in commands, subscriptions, tray menus, and settings. Mode types support serialization and zbus typing. GUI configuration defaults to OpenGui.

Changes

Dynamic mode availability

Layer / File(s) Summary
Mode contracts and D-Bus retrieval
crates/cardwire-cli/src/args.rs, crates/cardwire-cli/src/dbus.rs, crates/cardwire-gui/src/helpers/dbus.rs, crates/cardwire-gui/src/message.rs, crates/cardwire-gui/src/models.rs, crates/cardwire-gui/src/subscription.rs
Mode types support serde and zbus typing. CLI and GUI D-Bus clients retrieve AvailableModes. GUI state and messages carry the results.
CLI daemon validation and mode output
crates/cardwire-cli/src/main.rs
CLI startup validates daemon reachability. Get and GPU refresh output use dynamically retrieved modes. ServiceUnknown and NameHasNoOwner receive daemon-not-running handling.
GUI mode synchronization
crates/cardwire-gui/src/subscription.rs, crates/cardwire-gui/src/app.rs
The GUI fetches modes at startup and after GPU refreshes. Successful results update state and tray synchronization.
Dynamic mode selection surfaces
crates/cardwire-gui/src/tray.rs, crates/cardwire-gui/src/ui.rs, crates/cardwire-gui/src/gui_config.rs
Tray menus and GUI settings use available modes with enum fallback. PrimaryClickAction and GuiConfig now default to OpenGui.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GUI
  participant CardwireDbus
  participant CardwireDaemon
  GUI->>CardwireDbus: fetch available modes
  CardwireDbus->>CardwireDaemon: call AvailableModes
  CardwireDaemon-->>CardwireDbus: return mode list
  CardwireDbus-->>GUI: return modes or error
  GUI->>GUI: update MainState and tray
Loading

Possibly related PRs

Suggested reviewers: juandelpueblo

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description retains the untouched template and does not summarize the changes, explain motivation, identify an issue, or complete the checklist. Replace the template text with a change summary, motivation, issue reference or none, and accurate checklist selections.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: using the AvailableModes API in both cardwire-cli and cardwire-gui.
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.

@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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@crates/cardwire-cli/src/main.rs`:
- Around line 75-82: The available-mode retrieval errors must not be hidden. At
crates/cardwire-cli/src/main.rs lines 75-82, update the get_available_modes flow
to pass failures through handle_error or emit a clear error and return a nonzero
status instead of producing "err"; at lines 251-258, apply the same explicit
error handling after refresh rather than silently omitting available modes.

In `@crates/cardwire-gui/src/ui.rs`:
- Around line 684-689: Update gui_setting_section and the primary-click mode
selection flow to pass available_modes into GuiConfig::next_primary_click_mode
(or its equivalent) and filter candidates against that list before producing
Message::SetMode. Ensure unavailable configured modes are skipped while
preserving selection among currently available modes.
🪄 Autofix

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: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bb09ac76-8c76-46d7-bd83-c7ff1a8326da

📥 Commits

Reviewing files that changed from the base of the PR and between d37f4a7 and 47b4436.

📒 Files selected for processing (11)
  • crates/cardwire-cli/src/args.rs
  • crates/cardwire-cli/src/dbus.rs
  • crates/cardwire-cli/src/main.rs
  • crates/cardwire-gui/src/app.rs
  • crates/cardwire-gui/src/gui_config.rs
  • crates/cardwire-gui/src/helpers/dbus.rs
  • crates/cardwire-gui/src/message.rs
  • crates/cardwire-gui/src/models.rs
  • crates/cardwire-gui/src/subscription.rs
  • crates/cardwire-gui/src/tray.rs
  • crates/cardwire-gui/src/ui.rs

Comment thread crates/cardwire-cli/src/main.rs Outdated
Comment thread crates/cardwire-gui/src/ui.rs
@luytan
luytan merged commit cf91557 into main Aug 8, 2026
7 checks passed
@luytan
luytan deleted the use-available-modes-api branch August 8, 2026 13:17
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