Skip to content

feat: add a new signal for new apps entry - #169

Merged
luytan merged 5 commits into
mainfrom
feat-new_app_signal
Aug 8, 2026
Merged

feat: add a new signal for new apps entry#169
luytan merged 5 commits into
mainfrom
feat-new_app_signal

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9550ba17-fa49-48c2-869d-10ba1e307d77

📥 Commits

Reviewing files that changed from the base of the PR and between 883de10 and 1bdc11a.

📒 Files selected for processing (2)
  • crates/cardwire-gui/src/helpers/app_resolver.rs
  • crates/cardwire-gui/src/subscription.rs

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Newly discovered applications now appear automatically in smart-policy settings.
    • Live notifications keep the graphical interface updated when applications are detected.
    • Application metadata and policies are synchronized between the daemon and graphical interface.
  • Bug Fixes

    • Improved reporting for connection, subscription, and daemon disconnection issues.
    • Improved application and icon resolution across capitalization variants.

Walkthrough

The Smart Policy D-Bus interface now reports newly discovered applications. The daemon emits metadata after persistence. The GUI subscribes to the signal, resolves application metadata, and updates its policy state.

Changes

New-app notification flow

Layer / File(s) Summary
Smart Policy signal contract
crates/cardwire-daemon/src/interface/smart.rs, crates/cardwire-daemon/src/file/sql.rs
SmartPolicyInterface exposes new_app_added and stores its signal emitter. DbusAppMetadata::from_app_metadata builds the signal payload.
Daemon discovery emission
crates/cardwire-daemon/src/daemon.rs, crates/cardwire-daemon/src/analyzer/models.rs, crates/cardwire-daemon/src/manager.rs
The daemon initializes and passes the signal emitter to CardwireAnalyzer. The analyzer emits new_app_added after persistence.
GUI notification consumption
crates/cardwire-gui/src/subscription.rs, crates/cardwire-gui/src/message.rs, crates/cardwire-gui/src/app.rs, crates/cardwire-gui/src/helpers/app_resolver.rs
The GUI subscribes through a Smart Policy proxy, dispatches NewAppDiscovered, resolves desktop entries and icons, and inserts the discovered app into smart_state.app_policies.

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

Sequence Diagram(s)

sequenceDiagram
  participant CardwireAnalyzer
  participant SmartPolicyInterface
  participant CardwireSmartPolicy
  participant AppState
  CardwireAnalyzer->>SmartPolicyInterface: emit new_app_added(app metadata)
  SmartPolicyInterface-->>CardwireSmartPolicy: deliver D-Bus signal
  CardwireSmartPolicy-->>AppState: dispatch NewAppDiscovered
  AppState->>AppState: resolve metadata and update smart_state.app_policies
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only repeats the template and provides no change summary, motivation, issue reference, or completed checklist items. Add a concise summary, explain the feature motivation, provide the issue reference or state that none applies, and complete the relevant checklist items.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding a signal for newly discovered application entries.
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/cardwire-gui/src/subscription.rs (1)

636-656: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Register new_app_added before fetching the policy snapshot.

The zbus binding installs the match rule when receive_new_app_added() creates the stream. The current order can miss an app persisted after get_app_policies() reads the database. Create the stream first, send the snapshot, then consume queued signals. Add an integration test for this interval.

🤖 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 `@crates/cardwire-gui/src/subscription.rs` around lines 636 - 656, Reorder the
subscription flow so receive_new_app_added() creates and registers
new_app_stream before calling proxy.get_app_policies(). Send the fetched
snapshot after stream creation, then consume queued new_app_added signals;
preserve the existing error reporting and return behavior. Add an integration
test covering an app persisted between stream registration and the policy
snapshot.
🤖 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.

Outside diff comments:
In `@crates/cardwire-gui/src/subscription.rs`:
- Around line 636-656: Reorder the subscription flow so receive_new_app_added()
creates and registers new_app_stream before calling proxy.get_app_policies().
Send the fetched snapshot after stream creation, then consume queued
new_app_added signals; preserve the existing error reporting and return
behavior. Add an integration test covering an app persisted between stream
registration and the policy snapshot.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 361f6298-3dc3-4c8b-b388-4ef4e3b3e9f6

📥 Commits

Reviewing files that changed from the base of the PR and between cf91557 and 883de10.

📒 Files selected for processing (8)
  • crates/cardwire-daemon/src/analyzer/models.rs
  • crates/cardwire-daemon/src/daemon.rs
  • crates/cardwire-daemon/src/file/sql.rs
  • crates/cardwire-daemon/src/interface/smart.rs
  • crates/cardwire-daemon/src/manager.rs
  • crates/cardwire-gui/src/app.rs
  • crates/cardwire-gui/src/message.rs
  • crates/cardwire-gui/src/subscription.rs

@luytan
luytan merged commit e9f7e5e into main Aug 8, 2026
7 checks passed
@luytan
luytan deleted the feat-new_app_signal branch August 8, 2026 14:10
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