Shell 16: core-autostart (#808) #861

Closed
charles wants to merge 0 commits from shell-16-core-autostart into shell
Owner

What

fluxer-core::shell::autostart (plan Task 16; spec §6, §7.3):

  • reconcile(desired, actual) -> Option<ShellCommand>: on + Off/Stale → SetAutostart(true); off + On → SetAutostart(false); DisabledBySystem and Unavailable → nothing.
  • Reducer (shell::autostart::reduce, called from App::apply right after persist): stores ShellEvent::Autostart in app.shell.autostart and asks for the reconcile command when the state arrives, when settings load, and when "Launch Flaxative at login" flips. Each command is asked once (ShellState::autostart_asked), so if the platform reports the entry still wrong after a failed write, the store does not ask again in a loop. Flipping the switch clears that guard.
  • desktop_model(app) / desktop_model_for(app, DesktopOs) → DesktopSettingsModel { sections: [DesktopSection { title: "Desktop window", rows }] }. Each DesktopRow { key, label, description, value, enabled, note } has toggle(on) -> ShellAction::SetSetting(..). Rows and descriptions follow DesktopSettingsTab.tsx:170-261, in its order. "Use dark taskbar badge" is shown on Windows only. "Start minimized" is disabled unless autostart (on and offered) and the tray icon are on. The tray rows are disabled when the tray icon is off. They are also disabled, with a note, when no tray host shows it (NoHost/NoWatcher). Autostart is disabled with its reason when Unavailable, and noted (still usable) when DisabledBySystem.
  • AutostartUnavailable::text(), TRAY_UNAVAILABLE_NOTE, DISABLED_BY_SYSTEM_NOTE.

Strings

Copied from the fork (DesktopSettingsTab.tsx, UserMessageDescriptors.ts): "Desktop window", "Launch {productName} at login" (as "Launch Flaxative at login"), "Start minimized", "When launched at login, start in the system tray instead of opening the window", "Remember window size and position", "Show system tray icon", "Use colored tray icon", "Show the full-color {productName} icon instead of a monochrome one that matches your taskbar.", "Use dark taskbar badge", "Draw the unread badge on the {productName} taskbar button in dark gray instead of red.", "Minimize to tray", "Close to tray".
New strings (spec / plan Task 38): "Your desktop has no system tray. On GNOME, install the AppIndicator extension.", "Turned off in Windows settings.", "Only available for an installed build.", and one more that this task adds: "Not available in a development build." (AutostartUnavailable::DevelopmentBuild).

Tests

crates/fluxer-core/tests/shell_autostart.rs covers the plan's tests: reconcile_cases, disabled_by_system_not_overwritten, start_minimized_needs_autostart_and_tray, rows_per_os_and_availability, unavailable_reasons_have_text. It also adds store_reconciles_when_the_state_arrives_and_on_a_change, nothing_is_asked_before_the_state_is_known, state_before_settings_reconciled_on_load, a_failed_change_is_not_retried_in_a_loop and toggles_are_setting_changes. I saw these tests fail first (the module was missing), then pass. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passes locally. No desktop-gated tests apply: this task is pure core code.

Deviations from the plan

  • Row labels use the original's strings, "Show system tray icon" and "Remember window size and position", not the plan's short forms "Show tray icon" and "Remember size & position" (Global Constraints: strings are the original's).
  • reconcile(false, Stale) → SetAutostart(false). The plan's table does not list this case. A stale entry was written by the switch, so turning the switch off removes it (Review Focus 8).
  • Outside the task's file list: crates/fluxer-core/src/app.rs (the reducer call after persist, the same pattern as Tasks 8–13). ShellState gains the autostart_asked field in shell/mod.rs. tests/shell_ports.rs drops the autostart events from the stub-reducer test, as Task 8 did for the tray.
  • desktop_model_for(app, DesktopOs) is added next to desktop_model(app) so that the per-OS rows can be tested on Linux.

Nothing here needs a manual check on Windows (no cfg(windows) code; DesktopOs::current() uses cfg!(windows)).

Stacked on: shell-6-core-shell-ports-settings (already merged into shell)

Closes #808

🤖 Generated with Claude Code

https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K

## What `fluxer-core::shell::autostart` (plan Task 16; spec §6, §7.3): - `reconcile(desired, actual) -> Option<ShellCommand>`: on + `Off`/`Stale` → `SetAutostart(true)`; off + `On` → `SetAutostart(false)`; `DisabledBySystem` and `Unavailable` → nothing. - Reducer (`shell::autostart::reduce`, called from `App::apply` right after `persist`): stores `ShellEvent::Autostart` in `app.shell.autostart` and asks for the `reconcile` command when the state arrives, when settings load, and when "Launch Flaxative at login" flips. Each command is asked once (`ShellState::autostart_asked`), so if the platform reports the entry still wrong after a failed write, the store does not ask again in a loop. Flipping the switch clears that guard. - `desktop_model(app)` / `desktop_model_for(app, DesktopOs)` → `DesktopSettingsModel { sections: [DesktopSection { title: "Desktop window", rows }] }`. Each `DesktopRow { key, label, description, value, enabled, note }` has `toggle(on) -> ShellAction::SetSetting(..)`. Rows and descriptions follow `DesktopSettingsTab.tsx:170-261`, in its order. "Use dark taskbar badge" is shown on Windows only. "Start minimized" is disabled unless autostart (on and offered) and the tray icon are on. The tray rows are disabled when the tray icon is off. They are also disabled, with a note, when no tray host shows it (`NoHost`/`NoWatcher`). Autostart is disabled with its reason when `Unavailable`, and noted (still usable) when `DisabledBySystem`. - `AutostartUnavailable::text()`, `TRAY_UNAVAILABLE_NOTE`, `DISABLED_BY_SYSTEM_NOTE`. ## Strings Copied from the fork (`DesktopSettingsTab.tsx`, `UserMessageDescriptors.ts`): "Desktop window", "Launch {productName} at login" (as "Launch Flaxative at login"), "Start minimized", "When launched at login, start in the system tray instead of opening the window", "Remember window size and position", "Show system tray icon", "Use colored tray icon", "Show the full-color {productName} icon instead of a monochrome one that matches your taskbar.", "Use dark taskbar badge", "Draw the unread badge on the {productName} taskbar button in dark gray instead of red.", "Minimize to tray", "Close to tray". New strings (spec / plan Task 38): "Your desktop has no system tray. On GNOME, install the AppIndicator extension.", "Turned off in Windows settings.", "Only available for an installed build.", and one more that this task adds: "Not available in a development build." (`AutostartUnavailable::DevelopmentBuild`). ## Tests `crates/fluxer-core/tests/shell_autostart.rs` covers the plan's tests: `reconcile_cases`, `disabled_by_system_not_overwritten`, `start_minimized_needs_autostart_and_tray`, `rows_per_os_and_availability`, `unavailable_reasons_have_text`. It also adds `store_reconciles_when_the_state_arrives_and_on_a_change`, `nothing_is_asked_before_the_state_is_known`, `state_before_settings_reconciled_on_load`, `a_failed_change_is_not_retried_in_a_loop` and `toggles_are_setting_changes`. I saw these tests fail first (the module was missing), then pass. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passes locally. No desktop-gated tests apply: this task is pure core code. ## Deviations from the plan - Row labels use the original's strings, "Show system tray icon" and "Remember window size and position", not the plan's short forms "Show tray icon" and "Remember size & position" (Global Constraints: strings are the original's). - `reconcile(false, Stale)` → `SetAutostart(false)`. The plan's table does not list this case. A stale entry was written by the switch, so turning the switch off removes it (Review Focus 8). - Outside the task's file list: `crates/fluxer-core/src/app.rs` (the reducer call after `persist`, the same pattern as Tasks 8–13). `ShellState` gains the `autostart_asked` field in `shell/mod.rs`. `tests/shell_ports.rs` drops the autostart events from the stub-reducer test, as Task 8 did for the tray. - `desktop_model_for(app, DesktopOs)` is added next to `desktop_model(app)` so that the per-OS rows can be tested on Linux. Nothing here needs a manual check on Windows (no `cfg(windows)` code; `DesktopOs::current()` uses `cfg!(windows)`). Stacked on: shell-6-core-shell-ports-settings (already merged into shell) Closes #808 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
shell::autostart: reconcile(desired, actual), the store asking for it once
per answer when the state arrives, the settings load or the switch flips,
and desktop_model(app), the "Desktop window" section of
DesktopSettingsTab.tsx:170-261 with the notes of spec §6 and §7.3.

Refs #808

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Author
Owner

Review: Shell 16, core-autostart (independent reviewer)

Reviewed git diff 158c90dd..origin/shell-16-core-autostart (5fa37ab4) cold.

Plan tests (Step 1): reconcile_cases, disabled_by_system_not_overwritten, start_minimized_needs_autostart_and_tray, rows_per_os_and_availability, unavailable_reasons_have_text are all there and assert what the plan asks. There are also 5 extra store tests: reconcile on report, on load and on toggle, no ask before the state is known, and no retry loop.

Interfaces: AutostartState::{Off, On, Stale, DisabledBySystem, Unavailable(DevelopmentBuild|NotInstalled)} comes from Task 6 unchanged. reconcile(desired, actual) -> Option<ShellCommand> and desktop_model(app) -> DesktopSettingsModel exist as written, plus desktop_model_for(app, DesktopOs) for Task 38's per-OS goldens. ShellState gains autostart_asked. Default covers it, and no struct literal exists outside shell/mod.rs.

Invariants: fluxer-core imports nothing from iced, wgpu, winit, reqwest or tungstenite and does no I/O. No tracing and no secrets in the diff. No server data reaches the new code.

Parity spot-checks against fluxer-soundboard (all match):

  • Row order and strings match DesktopSettingsTab.tsx:170-258: Launch at login, Start minimized, Remember window size and position, Show system tray icon, Use colored tray icon, Use dark taskbar badge (Windows only), Minimize to tray, Close to tray. The plan's short labels ("Show tray icon", "Remember size & position") are not the original's strings. Using the original's strings is correct under Global Constraints.
  • The original disables "Start minimized" when !autostartEnabled || !showTrayIcon. It disables colored / minimize / close when !showTrayIcon. This PR does the same, and also disables those rows when no tray host exists (spec §6).
  • Descriptions match the original with {productName} = Flaxative: "When launched at login, start in the system tray instead of opening the window", "Show the full-color Flaxative icon...", "Draw the unread badge on the Flaxative taskbar button in dark gray instead of red."
  • Stale repair at start matches repairLinuxAutostartEntry.

Review Focus 6: every unavailable state is typed and has text: AutostartUnavailable::text(), TRAY_UNAVAILABLE_NOTE and DISABLED_BY_SYSTEM_NOTE. The strings match the ones Task 38 quotes.

Gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in the review worktree: all steps passed (EXIT=0), and shell_autostart is 10/10.

Findings

  1. minor: reconcile(false, DisabledBySystem) returns None, which differs from the original. The original's disableAutostart deletes the Run value whatever StartupApproved says. Here, if a user who turned Flaxative off in Windows "Startup apps" also turns the in-app switch off, our Run value stays. If they later turn it back on in Startup apps, the client starts at login against the switch, which is the concern of Review Focus 8. The plan's wording ("DisabledBySystem is left alone") supports what the PR does, so this is not blocking. Suggestion: off + DisabledBySystem → SetAutostart(false), which deletes only our Run value and never writes StartupApproved. Otherwise Task 19 should open a follow-up issue.
  2. minor: DesktopRow::toggle panics (unreachable!) for InputHook / PortalConsent. The model never builds those rows, but DesktopRow's fields are pub, so a caller can build one. Returning Option<ShellAction>, or making the fields read-only, would remove the panic path. It is not reachable from server data.
  3. minor: when the entry is DisabledBySystem, the launch row shows the setting's value (on) with a note. The original shows the system state (off). The spec asks for it to be "shown", and the note makes the reason clear, so this is acceptable as is. It is noted only for Task 38's golden.
  4. minor (note): reconcile(false, Stale) → SetAutostart(false) is not in the plan's list. It is consistent with Review Focus 8 (the switch removes what it created), and I agree with it.

Verdict: APPROVED. No blocking findings and the local gate is green.

## Review: Shell 16, core-autostart (independent reviewer) Reviewed `git diff 158c90dd..origin/shell-16-core-autostart` (5fa37ab4) cold. **Plan tests (Step 1):** `reconcile_cases`, `disabled_by_system_not_overwritten`, `start_minimized_needs_autostart_and_tray`, `rows_per_os_and_availability`, `unavailable_reasons_have_text` are all there and assert what the plan asks. There are also 5 extra store tests: reconcile on report, on load and on toggle, no ask before the state is known, and no retry loop. **Interfaces:** `AutostartState::{Off, On, Stale, DisabledBySystem, Unavailable(DevelopmentBuild|NotInstalled)}` comes from Task 6 unchanged. `reconcile(desired, actual) -> Option<ShellCommand>` and `desktop_model(app) -> DesktopSettingsModel` exist as written, plus `desktop_model_for(app, DesktopOs)` for Task 38's per-OS goldens. `ShellState` gains `autostart_asked`. `Default` covers it, and no struct literal exists outside `shell/mod.rs`. **Invariants:** fluxer-core imports nothing from iced, wgpu, winit, reqwest or tungstenite and does no I/O. No `tracing` and no secrets in the diff. No server data reaches the new code. **Parity spot-checks against `fluxer-soundboard` (all match):** - Row order and strings match `DesktopSettingsTab.tsx:170-258`: Launch at login, Start minimized, Remember window size and position, Show system tray icon, Use colored tray icon, Use dark taskbar badge (Windows only), Minimize to tray, Close to tray. The plan's short labels ("Show tray icon", "Remember size & position") are not the original's strings. Using the original's strings is correct under Global Constraints. - The original disables "Start minimized" when `!autostartEnabled || !showTrayIcon`. It disables colored / minimize / close when `!showTrayIcon`. This PR does the same, and also disables those rows when no tray host exists (spec §6). - Descriptions match the original with `{productName}` = Flaxative: "When launched at login, start in the system tray instead of opening the window", "Show the full-color Flaxative icon...", "Draw the unread badge on the Flaxative taskbar button in dark gray instead of red." - Stale repair at start matches `repairLinuxAutostartEntry`. **Review Focus 6:** every unavailable state is typed and has text: `AutostartUnavailable::text()`, `TRAY_UNAVAILABLE_NOTE` and `DISABLED_BY_SYSTEM_NOTE`. The strings match the ones Task 38 quotes. **Gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in the review worktree: **all steps passed (EXIT=0)**, and `shell_autostart` is 10/10. ### Findings 1. **minor**: `reconcile(false, DisabledBySystem)` returns `None`, which differs from the original. The original's `disableAutostart` deletes the `Run` value whatever `StartupApproved` says. Here, if a user who turned Flaxative off in Windows "Startup apps" also turns the in-app switch off, our `Run` value stays. If they later turn it back on in Startup apps, the client starts at login against the switch, which is the concern of Review Focus 8. The plan's wording ("DisabledBySystem is left alone") supports what the PR does, so this is not blocking. Suggestion: off + `DisabledBySystem` → `SetAutostart(false)`, which deletes only our `Run` value and never writes `StartupApproved`. Otherwise Task 19 should open a follow-up issue. 2. **minor**: `DesktopRow::toggle` panics (`unreachable!`) for `InputHook` / `PortalConsent`. The model never builds those rows, but `DesktopRow`'s fields are `pub`, so a caller can build one. Returning `Option<ShellAction>`, or making the fields read-only, would remove the panic path. It is not reachable from server data. 3. **minor**: when the entry is `DisabledBySystem`, the launch row shows the setting's value (on) with a note. The original shows the system state (off). The spec asks for it to be "shown", and the note makes the reason clear, so this is acceptable as is. It is noted only for Task 38's golden. 4. **minor (note)**: `reconcile(false, Stale)` → `SetAutostart(false)` is not in the plan's list. It is consistent with Review Focus 8 (the switch removes what it created), and I agree with it. **Verdict: APPROVED.** No blocking findings and the local gate is green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Merged into shell by hand (the merge API returns 405); the commits are in the branch.

Merged into `shell` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-18 06:53:50 +00:00
Author
Owner

Review: Shell 16 core-autostart (independent reviewer)

Scope: git diff 31c8a1273..origin/shell-16-core-autostart is empty, because the branch head is the #861 merge commit already on shell. I reviewed the task's own commit 5fa37ab4f instead: shell/autostart.rs, tests/shell_autostart.rs, the ShellState::autostart_asked field, the hook in App::apply and the README.

Checks

  1. Plan tests: all five tests the plan names exist and assert what the plan says: reconcile_cases, disabled_by_system_not_overwritten, start_minimized_needs_autostart_and_tray, rows_per_os_and_availability and unavailable_reasons_have_text. There are five more: store reconciliation, no command before the state is known, repair on load, no retry loop, and toggles.
  2. Interfaces: AutostartState::{Off, On, Stale, DisabledBySystem, Unavailable(DevelopmentBuild | NotInstalled)}, reconcile(bool, AutostartState) -> Option<ShellCommand> and desktop_model(&App) -> DesktopSettingsModel all exist as the plan writes them. The task also adds desktop_model_for(&App, DesktopOs).
  3. Invariants: no new dependencies, no I/O, no logging and no secrets in fluxer-core. Nothing from the server reaches this code.
  4. Parity, checked against DesktopSettingsTab.tsx:170-261 in the fork:
    • The row order matches the original: Launch, Start minimized, Remember window size and position, Show system tray icon, Use colored tray icon, Use dark taskbar badge (Windows only), Minimize to tray, Close to tray. The plan's own labels were paraphrases; the code uses the original's.
    • The strings match the original's descriptors: the colored-icon and dark-badge descriptions, and "When launched at login, start in the system tray…".
    • The disabled rules match. "Start minimized" needs autostart and the tray icon; the colored icon, minimize and close rows need the tray icon.
  5. Review Focus 6: satisfied. A typed Unavailable state carries its text, and DisabledBySystem and the missing tray host each show a note.
  6. Gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passed in the review worktree ("all steps passed", exit 0). shell_autostart ran 10 of 10 tests.

Findings

  • [blocking] The switch never removes the Run value when Windows reports DisabledBySystem.
    • What happens: reconcile(false, DisabledBySystem) returns None. If the user turns "Launch Flaxative at login" off while Windows "Startup apps" shows it disabled, the Forked.Flaxative Run value is never deleted, at any start.
    • Why it matters: if the user later re-enables the entry in Startup apps, Flaxative launches at login even though its switch is off. That breaks Review Focus 8 ("removed by the switch that created them").
    • The original behaves differently: fluxer_desktop/src/main/Autostart.ts:529-552 (disableAutostart) always deletes the Run value.
    • The platform side already supports the fix: WindowsAutostart::disable deletes only our value and never writes StartupApproved.
    • Fix: return SetAutostart(false) for (false, DisabledBySystem), keep (true, DisabledBySystem) -> None, and update the reconcile_cases row and disabled_by_system_not_overwritten. The autostart_asked guard already prevents a loop.
  • [minor] DesktopRow::toggle reaches unreachable! for ShellSettingKey::InputHook or PortalConsent. DesktopRow has public fields, so another crate can build such a row and panic. No server data reaches this path. Suggestion: return Option, or keep the key's change in the row.
  • [minor] settings.rs (:371) already has a key-to-bool-change mapping, which bool_change duplicates.
  • [minor, Task 19 coordination] On Linux, Hidden=true is reported as Off, so with the switch on, reconcile rewrites the entry at the next start. The original's repair (Autostart.ts:579-591) skips hidden or X-GNOME-Autostart-enabled=false entries. A desktop's "disable" of our entry is therefore overridden; this is the Linux equivalent of DisabledBySystem. Consider a follow-up.

Verdict: changes requested. One blocking finding ((false, DisabledBySystem) must remove our Run value). CI is green.

## Review: Shell 16 core-autostart (independent reviewer) Scope: `git diff 31c8a1273..origin/shell-16-core-autostart` is empty, because the branch head is the #861 merge commit already on `shell`. I reviewed the task's own commit `5fa37ab4f` instead: `shell/autostart.rs`, `tests/shell_autostart.rs`, the `ShellState::autostart_asked` field, the hook in `App::apply` and the README. **Checks** 1. **Plan tests:** all five tests the plan names exist and assert what the plan says: `reconcile_cases`, `disabled_by_system_not_overwritten`, `start_minimized_needs_autostart_and_tray`, `rows_per_os_and_availability` and `unavailable_reasons_have_text`. There are five more: store reconciliation, no command before the state is known, repair on load, no retry loop, and toggles. 2. **Interfaces:** `AutostartState::{Off, On, Stale, DisabledBySystem, Unavailable(DevelopmentBuild | NotInstalled)}`, `reconcile(bool, AutostartState) -> Option<ShellCommand>` and `desktop_model(&App) -> DesktopSettingsModel` all exist as the plan writes them. The task also adds `desktop_model_for(&App, DesktopOs)`. 3. **Invariants:** no new dependencies, no I/O, no logging and no secrets in `fluxer-core`. Nothing from the server reaches this code. 4. **Parity, checked against `DesktopSettingsTab.tsx:170-261` in the fork:** - The row order matches the original: Launch, Start minimized, Remember window size and position, Show system tray icon, Use colored tray icon, Use dark taskbar badge (Windows only), Minimize to tray, Close to tray. The plan's own labels were paraphrases; the code uses the original's. - The strings match the original's descriptors: the colored-icon and dark-badge descriptions, and "When launched at login, start in the system tray…". - The disabled rules match. "Start minimized" needs autostart and the tray icon; the colored icon, minimize and close rows need the tray icon. 5. **Review Focus 6:** satisfied. A typed `Unavailable` state carries its text, and `DisabledBySystem` and the missing tray host each show a note. 6. **Gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passed in the review worktree ("all steps passed", exit 0). `shell_autostart` ran 10 of 10 tests. **Findings** - **[blocking] The switch never removes the Run value when Windows reports `DisabledBySystem`.** - What happens: `reconcile(false, DisabledBySystem)` returns `None`. If the user turns "Launch Flaxative at login" off while Windows "Startup apps" shows it disabled, the `Forked.Flaxative` Run value is never deleted, at any start. - Why it matters: if the user later re-enables the entry in Startup apps, Flaxative launches at login even though its switch is off. That breaks Review Focus 8 ("removed by the switch that created them"). - The original behaves differently: `fluxer_desktop/src/main/Autostart.ts:529-552` (`disableAutostart`) always deletes the Run value. - The platform side already supports the fix: `WindowsAutostart::disable` deletes only our value and never writes `StartupApproved`. - Fix: return `SetAutostart(false)` for `(false, DisabledBySystem)`, keep `(true, DisabledBySystem) -> None`, and update the `reconcile_cases` row and `disabled_by_system_not_overwritten`. The `autostart_asked` guard already prevents a loop. - **[minor]** `DesktopRow::toggle` reaches `unreachable!` for `ShellSettingKey::InputHook` or `PortalConsent`. `DesktopRow` has public fields, so another crate can build such a row and panic. No server data reaches this path. Suggestion: return `Option`, or keep the key's change in the row. - **[minor]** `settings.rs` (`:371`) already has a key-to-bool-change mapping, which `bool_change` duplicates. - **[minor, Task 19 coordination]** On Linux, `Hidden=true` is reported as `Off`, so with the switch on, `reconcile` rewrites the entry at the next start. The original's repair (`Autostart.ts:579-591`) skips hidden or `X-GNOME-Autostart-enabled=false` entries. A desktop's "disable" of our entry is therefore overridden; this is the Linux equivalent of `DisabledBySystem`. Consider a follow-up. **Verdict: changes requested.** One blocking finding (`(false, DisabledBySystem)` must remove our Run value). CI is green.

Pull request closed

Sign in to join this conversation.
No description provided.