Repository navigation
fix(niriDS): refresh outputs through the native service - #46
Conversation
Reviewer's GuideUses of the APIRefresh outputs through the native service when available, while retaining the direct niri query as a fallback.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="niriDS/NiriDisplaySettingsService.qml" line_range="90" />
<code_context>
+ // Older niri versions do not emit OutputsChanged. Refresh the native
+ // service instead of treating its nonempty output cache as current.
+ if (typeof NiriService.fetchOutputs === "function") {
+ NiriService.fetchOutputs();
return;
}
</code_context>
<issue_to_address>
**Repeated clicks leave output disabled**
When a user clicks the same output again before the first command and asynchronous refresh update `NiriDS.displays`, `toggleDisable()` reads the unchanged `display.disabled` value for both clicks and sends `off` twice, so the second click does not re-enable the output and the user sees it remain disabled.
Track or apply the in-flight toggle so a second click uses the pending state instead of the stale `display.disabled` value.
</issue_to_address>
### Comment 2
<location path="niriDS/NiriDisplaySettingsService.qml" line_range="89" />
<code_context>
- updateOutputs(NiriService.outputs);
+ // Older niri versions do not emit OutputsChanged. Refresh the native
+ // service instead of treating its nonempty output cache as current.
+ if (typeof NiriService.fetchOutputs === "function") {
+ NiriService.fetchOutputs();
return;
</code_context>
<issue_to_address>
**Output refresh shells out unnecessarily**
When `NiriService.fetchOutputs` is unavailable while `NiriService.outputs` already contains outputs, `setDisplays()` skips the existing `NiriService.outputs` cache and runs `niri msg --json outputs` whenever `fetchOutputs` is unavailable, so refresh bypasses the native service and launches an external command.
Use the existing `NiriService.outputs` cache when the refresh method is unavailable, and avoid the external query when that cache is populated.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: niriDS/NiriDisplaySettingsService.qml:90
| // Older niri versions do not emit OutputsChanged. Refresh the native | ||
| // service instead of treating its nonempty output cache as current. | ||
| if (typeof NiriService.fetchOutputs === "function") { | ||
| NiriService.fetchOutputs(); |
There was a problem hiding this comment.
🟡 Medium · Repeated clicks leave output disabled
When a user clicks the same output again before the first command and asynchronous refresh update NiriDS.displays, toggleDisable() reads the unchanged display.disabled value for both clicks and sends off twice, so the second click does not re-enable the output and the user sees it remain disabled.
Track or apply the in-flight toggle so a second click uses the pending state instead of the stale display.disabled value.
Prompt for AI agents
In `niriDS/NiriDisplaySettingsService.qml` at line 90:
**Repeated clicks leave output disabled**
When a user clicks the same output again before the first command and asynchronous refresh update `NiriDS.displays`, `toggleDisable()` reads the unchanged `display.disabled` value for both clicks and sends `off` twice, so the second click does not re-enable the output and the user sees it remain disabled.
Track or apply the in-flight toggle so a second click uses the pending state instead of the stale `display.disabled` value.| updateOutputs(NiriService.outputs); | ||
| // Older niri versions do not emit OutputsChanged. Refresh the native | ||
| // service instead of treating its nonempty output cache as current. | ||
| if (typeof NiriService.fetchOutputs === "function") { |
There was a problem hiding this comment.
⚪ Low · Output refresh shells out unnecessarily
When NiriService.fetchOutputs is unavailable while NiriService.outputs already contains outputs, setDisplays() skips the existing NiriService.outputs cache and runs niri msg --json outputs whenever fetchOutputs is unavailable, so refresh bypasses the native service and launches an external command.
Use the existing NiriService.outputs cache when the refresh method is unavailable, and avoid the external query when that cache is populated.
Prompt for AI agents
In `niriDS/NiriDisplaySettingsService.qml` at line 89:
**Output refresh shells out unnecessarily**
When `NiriService.fetchOutputs` is unavailable while `NiriService.outputs` already contains outputs, `setDisplays()` skips the existing `NiriService.outputs` cache and runs `niri msg --json outputs` whenever `fetchOutputs` is unavailable, so refresh bypasses the native service and launches an external command.
Use the existing `NiriService.outputs` cache when the refresh method is unavailable, and avoid the external query when that cache is populated.From docs/conventions.md L85-96:
Never require external packages when Dux Shell provides built-in replacements:
| Capability | External Package to Avoid | Dux Shell Native Solution |
| :--- | :--- | :--- |
| **Clipboard** | `wl-clipboard`, `xclip` | `dms cl copy <text>`, `dms cl paste` |
| **Notifications** | `libnotify` (`notify-send`) | `dms notify "<title>" "<message>"` |
| **Screenshots** | `grim`, `slurp`, `flameshot`| `dms screenshot [region\|full\|all]` |
| **Open URL / File** | `xdg-open`, `gio open` | `dms open <url\|path>` |
| **Audio Volume / Mute** | `pactl`, `wpctl` | `AudioService` (`import qs.Services`) |
| **Network / VPN** | `nmcli` | `NetworkService` |
| **Bluetooth** | `bluetoothctl` | `BluetoothService` |
| **Output / Screens** | Polling `hyprctl` / `niri msg` | `CompositorService.screens` / `NiriService` |
What
Refresh outputs through
NiriService.fetchOutputs()instead of treating a nonempty cached output map as current. Retain the existing direct niri query for shells without the native refresh method.Why
On niri builds without
OutputsChangedIPC events, the cached output map can stay stale after a display is disabled. Its indicator stays green and subsequent clicks sendoffagain instead ofon. Requesting a fresh native snapshot lets the existing daemon connection update the display model.How tested
qmllint niriDS/*.qml niriDS/shared/*.qml: exit 0; diagnostic messages and counts match unmodifiedmain.python3 scripts/check_unused_imports.py niriDS: passes with the installed Dux source available to the checker's symbol discovery.python3 scripts/refactor_dcommon.py --check --requires-dms ">=2.0.0"andgit diff --check: pass.off/offon the original code; verifies disabled-on-open state andoff/onwith both native refresh and the direct-query fallback.dms ipc call plugins reload niriDSanddms ipc call niriDS open, then compared the live plugin model withniri msg --json outputs. Plugin-only reload retained the old singleton, so an in-process QML configuration reload was needed to activate the edited service. Live state then matched niri. The final revision's off/on sequence was tested in the mocked harness; no additional physical off/on cycle was performed for that revision.Summary by Sourcery
Refresh niri display settings from the native output service while preserving compatibility with shells that lack native output refresh support.
Bug Fixes:
Summary by CodeRabbit