Shell 8: core-tray-model-and (#800) #853

Closed
charles wants to merge 0 commits from shell-8-core-tray-model-and into shell
Owner

What this builds

fluxer-core::shell::tray (Desktop shell plan, Task 8; spec §6):

  • tray_model(&App) -> Option<TrayModel>, a pure selector: tooltip (D/DesktopTray.ts:312-315, D/UnreadBadge.ts), indicator (badge not empty), appearance (Colored with "Use colored tray icon", else Mono) and the menu in the original's order (D/DesktopTray.ts:407-532): Show / Hide Flaxative · Open settings · — · Status ▸ (radio) · [in voice: — · Mute / Unmute microphone · Deafen / Undeafen · Disconnect from {channel} | Disconnect from voice] · — · [Update Flaxative now] · [Check for updates] · [Copy build info] · — · Restart Flaxative · Quit Flaxative.
  • Each TrayAction reduced to existing actions or commands: ToggleWindow → Hide / Show from the window's visibility, ShowWindow → Show, OpenSettings → Show + OpenSettings(None) (the window commands asked of shell::window with window::request(WindowIntent::{Toggle, Show}), which decides and emits them), SetStatus → SetStatus { duration: None }, ToggleMute / ToggleDeafen / DisconnectVoice → ToggleSelfMute / ToggleSelfDeaf / LeaveVoice, UpdateNow → UpdateAction::ButtonClicked, CheckForUpdates → UpdateAction::CheckNow, CopyBuildInfo → Effect::Clipboard(Text(..)), Restart → ShellCommand::Restart, Quit → WindowCommand::Quit.
  • shell::tray::sync runs after every App::apply: Effect::Shell(ShellCommand::Tray(model)) only when the model changed since the last one sent (app.shell.tray_model), RemoveTray when it went away.
  • ShellEvent::TrayAvailability is stored in app.shell.tray, which the window rules (Task 9) read.

Joined with Task 9 (window rules)

Task 9 landed in shell first with its own window-visibility state and its own "show the hidden window" rules. Per the orchestrator's decision, shell::window is the single owner of the window's visibility and of every show / hide decision:

  • ShellState::window_visible and this task's "show when the tray goes away" rule (in tray::reduce and tray::sync) are deleted; UserAction::WindowVisible no longer feeds the tray.
  • The first row ("Show" / "Hide Flaxative") and the icon's click read app.shell.window.shown() (new accessor: visible and not minimised, from the window's WindowRequest::Shown / Hidden / Minimized reports).
  • The rows ask for a change with window::request(shell, WindowIntent::{Show, Toggle}, effects) (new, in window.rs); the tray never emits WindowCommand::Show / Hide itself.
  • The tray reports its availability in app.shell.tray; window::reduce (now run after tray::reduce) shows a hidden window when it becomes anything but Available (new arm), next to its existing ShowTrayIcon(false), grace-timer and Hidden rules. Every show cancels the start's tray grace, so a late timer cannot show twice.
  • Second instance: Task 10 (shell::instance) landed in shell during the join and answers InstanceMessage::Activate { token } with one WindowCommand::Raise (un-minimise, show, focus) or Activate(token). The Show arm first added to window::reduce for it was dropped so activation is not answered twice; the test asserts exactly one raising command and no extra Show. (Routing Task 10's raise through window::request is a possible follow-up if the window module should emit it too.)
  • shell::tray::sync runs after Task 13's badge::follow, so the tooltip shows the badge the event left.

Strings copied from fluxer_desktop/src/main/MainI18n.ts ({appName} = Flaxative): Show {appName}, Hide {appName}, Open settings, Status, Online, Idle, Do not disturb, Invisible, Mute microphone, Unmute microphone, Deafen, Undeafen, Disconnect from {channel} (channel bidi-isolated with U+2068/U+2069 as isolateBidiText), Disconnect from voice, Update {appName} now, Check for updates, Copy build info, Restart {appName}, Quit {appName}, Unread messages, Unread messages: {count}.

How it was tested

  • New crates/fluxer-core/tests/shell_tray.rs: menu_rows_per_state (logged out, logged in, in voice, muted, deafened, a named channel, a DM call, update offered, updater with nothing offered, hidden window), rows_carry_their_actions, status_radio_follows_presence, tooltip_per_badge, appearance_follows_colored_setting, no_model_without_icon_or_tray, model_emitted_only_on_change, every_action_maps, copy_build_info_of_a_development_build, tray_lost_while_hidden_shows_window_once, tray_icon_turned_off_while_hidden_shows_window_once, tray_show_clicked_shows_window_once, second_instance_activation_raises_window_once, close_to_tray_hide_shows_in_the_menu; every_action_maps checks the toggle hides, then shows (and shows a minimised window). Seen failing (no module) before the implementation, passing after. The join's tests were seen failing on the plain-merged tree (icon off while hidden sent Show twice; close-to-tray Hide left the menu at "Hide"; the menu ignored WindowRequest::Hidden), passing after.
  • tests/shell_window.rs (Task 9): hidden_without_any_tray_is_shown_at_once now asserts no window command or timer (the tray's menu changing to "Show" is an expected effect).
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No desktop-only tests in this task (pure core).

Deviations and notes for the reviewer

  • Outside tray.rs: app.rs gets two calls (shell::tray::reduce next to shell::reduce, which returns the follow-up actions the rows stand for; shell::tray::sync after the reducers). shell::reduce takes only &mut ShellState, so the tray reducer, which needs the updater's build info and returns follow-ups, is called beside it rather than changing its signature (other wave tasks add arms to it). ShellState gains tray_model.
  • tests/shell_ports.rs: the tray actions and availability events, and Instance(Activate), are removed from the "stubs change nothing" inputs, since they now have behaviour.
  • No model before the platform reports availability (app.shell.tray == None): the runtime (Task 33) reports TrayAvailability first, Disabled for --no-tray. This keeps every existing test's effects unchanged and avoids a tray flash before the settings say "Show tray icon" is off. NoHost / NoWatcher keep the model so the item stays registered for a host that appears later.
  • Window visibility is the window module's (WindowState::shown(), the original's isVisible() && !isMinimized()), from what the window reports; see the join above.
  • "In voice" = VoiceConnection::is_live() (connected, reconnecting, or moving), and the mute / deafen labels follow the user's own switches (LocalVoiceState), as the original's LocalVoiceState.getSelfMute().
  • "Update Flaxative now" shows for UpdateStatus::Available | Ready; "Check for updates" unless the updater is Disabled (development build or no platform), as shouldDisableModuleUpdatesForLaunch.
  • "Copy build info" copies {Channel} Desktop {version|dev} ({commit}) from UpdateState::build(), after the first part of formatClientBuildInfo; the original's OS / Electron parts have no equivalent in core. Task 33 may replace it with debug_info if wanted.
  • Tray Quit uses WindowCommand::Quit (spec §6); Restart uses ShellCommand::Restart.
  • Adjacent separators are collapsed (the original leaves two in a row when no update / build rows apply; Electron collapses them).

Stacked on: origin/shell-6-core-shell-ports-settings (already merged into shell; the merge was a no-op).

Closes #800

🤖 Generated with Claude Code

https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K

## What this builds `fluxer-core::shell::tray` (Desktop shell plan, Task 8; spec §6): - `tray_model(&App) -> Option<TrayModel>`, a pure selector: tooltip (`D/DesktopTray.ts:312-315`, `D/UnreadBadge.ts`), `indicator` (badge not empty), `appearance` (`Colored` with "Use colored tray icon", else `Mono`) and the menu in the original's order (`D/DesktopTray.ts:407-532`): Show / Hide Flaxative · Open settings · — · Status ▸ (radio) · [in voice: — · Mute / Unmute microphone · Deafen / Undeafen · Disconnect from {channel} | Disconnect from voice] · — · [Update Flaxative now] · [Check for updates] · [Copy build info] · — · Restart Flaxative · Quit Flaxative. - Each `TrayAction` reduced to existing actions or commands: `ToggleWindow` → `Hide` / `Show` from the window's visibility, `ShowWindow` → `Show`, `OpenSettings` → `Show` + `OpenSettings(None)` (the window commands asked of `shell::window` with `window::request(WindowIntent::{Toggle, Show})`, which decides and emits them), `SetStatus` → `SetStatus { duration: None }`, `ToggleMute` / `ToggleDeafen` / `DisconnectVoice` → `ToggleSelfMute` / `ToggleSelfDeaf` / `LeaveVoice`, `UpdateNow` → `UpdateAction::ButtonClicked`, `CheckForUpdates` → `UpdateAction::CheckNow`, `CopyBuildInfo` → `Effect::Clipboard(Text(..))`, `Restart` → `ShellCommand::Restart`, `Quit` → `WindowCommand::Quit`. - `shell::tray::sync` runs after every `App::apply`: `Effect::Shell(ShellCommand::Tray(model))` only when the model changed since the last one sent (`app.shell.tray_model`), `RemoveTray` when it went away. - `ShellEvent::TrayAvailability` is stored in `app.shell.tray`, which the window rules (Task 9) read. ## Joined with Task 9 (window rules) Task 9 landed in `shell` first with its own window-visibility state and its own "show the hidden window" rules. Per the orchestrator's decision, `shell::window` is the single owner of the window's visibility and of every show / hide decision: - `ShellState::window_visible` and this task's "show when the tray goes away" rule (in `tray::reduce` and `tray::sync`) are deleted; `UserAction::WindowVisible` no longer feeds the tray. - The first row ("Show" / "Hide Flaxative") and the icon's click read `app.shell.window.shown()` (new accessor: visible and not minimised, from the window's `WindowRequest::Shown` / `Hidden` / `Minimized` reports). - The rows ask for a change with `window::request(shell, WindowIntent::{Show, Toggle}, effects)` (new, in `window.rs`); the tray never emits `WindowCommand::Show` / `Hide` itself. - The tray reports its availability in `app.shell.tray`; `window::reduce` (now run after `tray::reduce`) shows a hidden window when it becomes anything but `Available` (new arm), next to its existing `ShowTrayIcon(false)`, grace-timer and `Hidden` rules. Every show cancels the start's tray grace, so a late timer cannot show twice. - Second instance: Task 10 (`shell::instance`) landed in `shell` during the join and answers `InstanceMessage::Activate { token }` with one `WindowCommand::Raise` (un-minimise, show, focus) or `Activate(token)`. The `Show` arm first added to `window::reduce` for it was dropped so activation is not answered twice; the test asserts exactly one raising command and no extra `Show`. (Routing Task 10's raise through `window::request` is a possible follow-up if the window module should emit it too.) - `shell::tray::sync` runs after Task 13's `badge::follow`, so the tooltip shows the badge the event left. Strings copied from `fluxer_desktop/src/main/MainI18n.ts` (`{appName}` = Flaxative): `Show {appName}`, `Hide {appName}`, `Open settings`, `Status`, `Online`, `Idle`, `Do not disturb`, `Invisible`, `Mute microphone`, `Unmute microphone`, `Deafen`, `Undeafen`, `Disconnect from {channel}` (channel bidi-isolated with U+2068/U+2069 as `isolateBidiText`), `Disconnect from voice`, `Update {appName} now`, `Check for updates`, `Copy build info`, `Restart {appName}`, `Quit {appName}`, `Unread messages`, `Unread messages: {count}`. ## How it was tested - New `crates/fluxer-core/tests/shell_tray.rs`: `menu_rows_per_state` (logged out, logged in, in voice, muted, deafened, a named channel, a DM call, update offered, updater with nothing offered, hidden window), `rows_carry_their_actions`, `status_radio_follows_presence`, `tooltip_per_badge`, `appearance_follows_colored_setting`, `no_model_without_icon_or_tray`, `model_emitted_only_on_change`, `every_action_maps`, `copy_build_info_of_a_development_build`, `tray_lost_while_hidden_shows_window_once`, `tray_icon_turned_off_while_hidden_shows_window_once`, `tray_show_clicked_shows_window_once`, `second_instance_activation_raises_window_once`, `close_to_tray_hide_shows_in_the_menu`; `every_action_maps` checks the toggle hides, then shows (and shows a minimised window). Seen failing (no module) before the implementation, passing after. The join's tests were seen failing on the plain-merged tree (icon off while hidden sent `Show` twice; close-to-tray `Hide` left the menu at "Hide"; the menu ignored `WindowRequest::Hidden`), passing after. - `tests/shell_window.rs` (Task 9): `hidden_without_any_tray_is_shown_at_once` now asserts no window command or timer (the tray's menu changing to "Show" is an expected effect). - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No desktop-only tests in this task (pure core). ## Deviations and notes for the reviewer - **Outside `tray.rs`**: `app.rs` gets two calls (`shell::tray::reduce` next to `shell::reduce`, which returns the follow-up actions the rows stand for; `shell::tray::sync` after the reducers). `shell::reduce` takes only `&mut ShellState`, so the tray reducer, which needs the updater's build info and returns follow-ups, is called beside it rather than changing its signature (other wave tasks add arms to it). `ShellState` gains `tray_model`. - `tests/shell_ports.rs`: the tray actions and availability events, and `Instance(Activate)`, are removed from the "stubs change nothing" inputs, since they now have behaviour. - **No model before the platform reports availability** (`app.shell.tray == None`): the runtime (Task 33) reports `TrayAvailability` first, `Disabled` for `--no-tray`. This keeps every existing test's effects unchanged and avoids a tray flash before the settings say "Show tray icon" is off. `NoHost` / `NoWatcher` keep the model so the item stays registered for a host that appears later. - Window visibility is the window module's (`WindowState::shown()`, the original's `isVisible() && !isMinimized()`), from what the window reports; see the join above. - "In voice" = `VoiceConnection::is_live()` (connected, reconnecting, or moving), and the mute / deafen labels follow the user's own switches (`LocalVoiceState`), as the original's `LocalVoiceState.getSelfMute()`. - "Update Flaxative now" shows for `UpdateStatus::Available | Ready`; "Check for updates" unless the updater is `Disabled` (development build or no platform), as `shouldDisableModuleUpdatesForLaunch`. - "Copy build info" copies `{Channel} Desktop {version|dev} ({commit})` from `UpdateState::build()`, after the first part of `formatClientBuildInfo`; the original's OS / Electron parts have no equivalent in core. Task 33 may replace it with `debug_info` if wanted. - Tray Quit uses `WindowCommand::Quit` (spec §6); Restart uses `ShellCommand::Restart`. - Adjacent separators are collapsed (the original leaves two in a row when no update / build rows apply; Electron collapses them). Stacked on: origin/shell-6-core-shell-ports-settings (already merged into shell; the merge was a no-op). Closes #800 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
shell::tray: tray_model (tooltip, unread dot, appearance, the menu in the
original's order and strings, D/DesktopTray.ts:312-315,407-532 and
D/MainI18n.ts:57-117), each TrayAction reduced to the existing actions
or a window / shell command, the model sent only when it changed, and a
hidden window shown again when the tray goes away
(D/DesktopTray.ts:594-600).

Refs #800

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

Independent review: Shell 8 (core tray model and actions)

Scope: git diff 56930ca6..origin/shell-8-core-tray-model-and (567810ff).

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci -> "all steps passed". tests/shell_tray.rs: 10 passed.

Checks

  1. Plan tests: all six named tests exist. menu_rows_per_state covers logged out, logged in, in voice (plain, muted, deafened), a named channel, a DM call, update offered, updater up to date and a hidden window. The others are status_radio_follows_presence, tooltip_per_badge (1,234-style grouping), model_emitted_only_on_change, every_action_maps (iterates TrayAction::ALL) and tray_lost_while_hidden_shows_window. Four extra tests are also present.
  2. Interfaces: shell::tray::tray_model(&App) -> Option<TrayModel> exists. It uses the Task 6 TrayItem, TrayAction and TrayAppearance unchanged. Effect::Shell(ShellCommand::Tray(model)) is sent only on change, and RemoveTray is sent when the model goes away. ShellEvent::TrayAvailability is stored in shell.tray. No registry was reordered: ShellState only gained two fields at the end.
  3. Invariants: fluxer-core has no new imports of iced, wgpu, winit, reqwest or tungstenite, and does no I/O. There are no new fixtures. Nothing indexes server data (the channel name is looked up with get, and an empty name falls back). No secrets or paths appear. The test password is a dummy, as in the existing suites.
  4. Parity, checked against fluxer_desktop/src/main:
    • All 18 strings match MainI18n.ts:57-117.
    • Menu order matches buildTrayMenu (DesktopTray.ts:407-532).
    • The tooltip matches getTrayToolTip / describeUnreadBadge.
    • Show / Hide follows "visible and not minimised" (:408-411).
    • The channel label is isolated with FSI/PDI as isolateBidiText. It falls back to "Disconnect from voice" when the channel has no name (DM), as resolveVoiceChannelLabel.
    • The tray actions map to the same renderer actions as DesktopTrayBridge.ts. Set status has no duration, matching UserSettings.setStatus.
  5. Review Focus #6 (honest capability): NoHost / NoWatcher keep the model and reveal a hidden window. Disabled removes the tray. The typed "no tray" string is for Desktop settings in a later task, so there is nothing to check here. Review Focus #5: without a tray, a hidden window is never left hidden, whether the availability is lost or the icon is turned off.

Findings

  • minor (follow-up suggested): Copy build info content. The core copies "{Channel} Desktop {version|dev} ({commit})" itself through Effect::Clipboard. The original copies all of formatClientBuildInfo: desktop and web build, OS and arch, runtimes, locale. Plan Task 33 says this row "uses the existing debug_info". Task 33 is an apps/fluxer-only task and cannot change this reducer without causing a double write. This should be settled before Task 33 starts. Option 1: Task 33 accepts the core string, optionally extended with an OS line. Option 2: a follow-up makes the core emit a ShellCommand for the runtime to fill. Not blocking: the row exists, works and copies a correct prefix of the original's string.
  • minor: window visibility ownership. shell.window_visible defaults to true and follows UserAction::WindowVisible plus the tray's own Show and Hide. Task 9's close-to-tray Hide and start-hidden decision, and its WindowRequest::Shown/Hidden, must also update this field (or report WindowVisible). Otherwise, after close-to-tray or an autostart start-hidden, the first row reads "Hide Flaxative" and a click hides an already hidden window. Task 9 should own and reuse this field rather than add a second one.
  • minor: reveal is slightly broader than the original. DesktopTray.ts:597 reveals only !isVisible(). Here a minimised window (which counts as window_visible == false) is also sent Show when the tray goes away. This is harmless and arguably better.
  • minor: separators are collapsed. Two separators in a row are merged; the original could emit both, for example on a dev build with no build info. This matches the spec ("Rows 10 and 12 are absent"), and it is invisible on most hosts.
  • note: "In voice" uses VoiceConnection::is_live(), which includes Reconnecting. The original uses connected from the projection. Keeping "Disconnect" available while reconnecting is reasonable.

Verdict: APPROVED. No blocking findings, and the local gate is green. The Copy build info question should be settled before Task 33.

## Independent review: Shell 8 (core tray model and actions) Scope: `git diff 56930ca6..origin/shell-8-core-tray-model-and` (567810ff). **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` -> "all steps passed". `tests/shell_tray.rs`: 10 passed. ### Checks 1. **Plan tests:** all six named tests exist. `menu_rows_per_state` covers logged out, logged in, in voice (plain, muted, deafened), a named channel, a DM call, update offered, updater up to date and a hidden window. The others are `status_radio_follows_presence`, `tooltip_per_badge` (1,234-style grouping), `model_emitted_only_on_change`, `every_action_maps` (iterates `TrayAction::ALL`) and `tray_lost_while_hidden_shows_window`. Four extra tests are also present. 2. **Interfaces:** `shell::tray::tray_model(&App) -> Option<TrayModel>` exists. It uses the Task 6 `TrayItem`, `TrayAction` and `TrayAppearance` unchanged. `Effect::Shell(ShellCommand::Tray(model))` is sent only on change, and `RemoveTray` is sent when the model goes away. `ShellEvent::TrayAvailability` is stored in `shell.tray`. No registry was reordered: `ShellState` only gained two fields at the end. 3. **Invariants:** `fluxer-core` has no new imports of iced, wgpu, winit, reqwest or tungstenite, and does no I/O. There are no new fixtures. Nothing indexes server data (the channel name is looked up with `get`, and an empty name falls back). No secrets or paths appear. The test password is a dummy, as in the existing suites. 4. **Parity, checked against `fluxer_desktop/src/main`:** - All 18 strings match `MainI18n.ts:57-117`. - Menu order matches `buildTrayMenu` (`DesktopTray.ts:407-532`). - The tooltip matches `getTrayToolTip` / `describeUnreadBadge`. - Show / Hide follows "visible and not minimised" (`:408-411`). - The channel label is isolated with FSI/PDI as `isolateBidiText`. It falls back to "Disconnect from voice" when the channel has no name (DM), as `resolveVoiceChannelLabel`. - The tray actions map to the same renderer actions as `DesktopTrayBridge.ts`. Set status has no duration, matching `UserSettings.setStatus`. 5. **Review Focus #6 (honest capability):** `NoHost` / `NoWatcher` keep the model and reveal a hidden window. `Disabled` removes the tray. The typed "no tray" string is for Desktop settings in a later task, so there is nothing to check here. **Review Focus #5:** without a tray, a hidden window is never left hidden, whether the availability is lost or the icon is turned off. ### Findings - **minor (follow-up suggested): Copy build info content.** The core copies `"{Channel} Desktop {version|dev} ({commit})"` itself through `Effect::Clipboard`. The original copies all of `formatClientBuildInfo`: desktop and web build, OS and arch, runtimes, locale. Plan Task 33 says this row "uses the existing `debug_info`". Task 33 is an `apps/fluxer`-only task and cannot change this reducer without causing a double write. This should be settled before Task 33 starts. Option 1: Task 33 accepts the core string, optionally extended with an OS line. Option 2: a follow-up makes the core emit a `ShellCommand` for the runtime to fill. Not blocking: the row exists, works and copies a correct prefix of the original's string. - **minor: window visibility ownership.** `shell.window_visible` defaults to `true` and follows `UserAction::WindowVisible` plus the tray's own Show and Hide. Task 9's close-to-tray `Hide` and start-hidden decision, and its `WindowRequest::Shown/Hidden`, must also update this field (or report `WindowVisible`). Otherwise, after close-to-tray or an autostart start-hidden, the first row reads "Hide Flaxative" and a click hides an already hidden window. Task 9 should own and reuse this field rather than add a second one. - **minor: reveal is slightly broader than the original.** `DesktopTray.ts:597` reveals only `!isVisible()`. Here a minimised window (which counts as `window_visible == false`) is also sent `Show` when the tray goes away. This is harmless and arguably better. - **minor: separators are collapsed.** Two separators in a row are merged; the original could emit both, for example on a dev build with no build info. This matches the spec ("Rows 10 and 12 are absent"), and it is invisible on most hosts. - **note:** "In voice" uses `VoiceConnection::is_live()`, which includes Reconnecting. The original uses `connected` from the projection. Keeping "Disconnect" available while reconnecting is reasonable. **Verdict: APPROVED.** No blocking findings, and the local gate is green. The Copy build info question should be settled before Task 33.
Author
Owner

Joined with Task 9 per the orchestrator's decision: shell::window is the single owner of the window's visibility and of every show / hide. ShellState::window_visible and the tray's own "show when the tray goes away" rule (tray::reduce, tray::sync) are deleted. The tray menu label and click read WindowState::shown() (new accessor: visible and not minimised) and ask for a change through window::request(WindowIntent::{Show, Toggle}) (new); the tray never emits Show/Hide itself. The tray stores its availability in ShellState::tray; window::reduce (now after tray::reduce) shows a hidden window once when the tray is lost (new arm), next to its existing icon-off, grace and Hidden rules; every show cancels the start grace. Tests in tests/shell_tray.rs: exactly one Show for tray lost while hidden, icon turned off while hidden, tray Show clicked; close-to-tray Hide reflected in the menu label; toggle hides and shows. Task 10 landed meanwhile and answers a second instance with one Raise / Activate(token), so no extra Show is added for activation (asserted: exactly one raising command, no Show). Gate FLUXER_SCREENSHOT_TESTS=1 dbus-run-session -- cargo xtask ci green.

Joined with Task 9 per the orchestrator's decision: `shell::window` is the single owner of the window's visibility and of every show / hide. `ShellState::window_visible` and the tray's own "show when the tray goes away" rule (tray::reduce, tray::sync) are deleted. The tray menu label and click read `WindowState::shown()` (new accessor: visible and not minimised) and ask for a change through `window::request(WindowIntent::{Show, Toggle})` (new); the tray never emits Show/Hide itself. The tray stores its availability in `ShellState::tray`; `window::reduce` (now after `tray::reduce`) shows a hidden window once when the tray is lost (new arm), next to its existing icon-off, grace and Hidden rules; every show cancels the start grace. Tests in `tests/shell_tray.rs`: exactly one Show for tray lost while hidden, icon turned off while hidden, tray Show clicked; close-to-tray Hide reflected in the menu label; toggle hides and shows. Task 10 landed meanwhile and answers a second instance with one `Raise` / `Activate(token)`, so no extra Show is added for activation (asserted: exactly one raising command, no Show). Gate `FLUXER_SCREENSHOT_TESTS=1 dbus-run-session -- cargo xtask ci` green.
Per the orchestrator's decision, Task 9's window module is the single owner of
the window's visibility and of every show / hide decision:

- `ShellState::window_visible` and the tray's own "show when the tray goes
  away" rule (tray::reduce and tray::sync) are gone.
- The tray's first row and click read `WindowState::shown()` (visible and not
  minimised) and ask for a change with `window::request(WindowIntent::{Show,
  Toggle})`; the tray never emits a window command itself.
- The tray stores the platform's availability in `ShellState::tray`; the window
  rules show a hidden window once when it is lost (new), when the icon is
  turned off, and on a second instance's `Activate` (new, plus
  `Activate(token)`); every show cancels the start's tray grace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Task 10's shell::instance answers a second instance with one Raise /
Activate(token); the window module's own Activate arm (added in the join with
Task 9) is dropped so the activation is not answered twice. tray::sync runs
after badge::follow so the tooltip shows the badge this event left.

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 08:55:04 +00:00
Author
Owner

Independent review: Shell 8 (core tray model and actions)

Scope. git diff 2cb39185..origin/shell-8-core-tray-model-and is empty: the branch head is 2cb39185, already an ancestor of origin/shell (merged by hand as baf0a9298). So I reviewed the task's own commits instead (567810ffe feat(core): tray model, 88cd55079 cargo fmt) as they stand on the branch: crates/fluxer-core/src/shell/tray.rs, tests/shell_tray.rs, and the app.rs, shell/mod.rs and README hooks. Those files have not changed between the branch and origin/shell.

1. Plan tests. All are present and assert what the plan asks for: menu_rows_per_state (logged out, logged in, in voice, muted, deafened, named channel, DM call, update offered, updater idle, hidden, minimised), status_radio_follows_presence, tooltip_per_badge (None, Dot, Count 3, 12,345, 0), model_emitted_only_on_change, every_action_maps (iterates TrayAction::ALL) and the tray-lost test. There are also extra tests: rows carry their actions, appearance, no model without icon or tray, a dev build's build info, and how window rules interact with the tray.

2. Interfaces. tray_model(&App) -> Option<TrayModel>, TrayModel { tooltip, indicator, appearance, menu }, TrayAppearance::{Colored, Mono}, TrayItem::{Action{label,action,enabled}, Radio{label,action,checked}, Submenu{label,items}, Separator}, and all 12 TrayAction variants exist exactly as the plan names them. ShellEvent::TrayAvailability is stored in ShellState::tray. Effect::Shell(ShellCommand::Tray(model)) is sent only when the model changes, and RemoveTray when the model goes away. Tasks 20, 21 and 22 already build on these names in shell.

3. Invariants. tray.rs is pure. It does no I/O and imports no iced, wgpu, winit, reqwest or tokio-tungstenite. It has no panics on server data: a channel name that is missing or empty falls back to "Disconnect from voice", and the badge-count formatting is plain arithmetic. It adds no fixtures. It contains no secrets, tokens or paths.

4. Parity spot checks against fluxer_desktop/src/main in the fork:

  • Strings match MainI18n.ts:57-117 exactly. This covers show/hide, open settings, the status rows, mute/unmute, deafen/undeafen, "Disconnect from {channel}" with FSI/PDI isolation, disconnect voice, update now, check for updates, copy build info, restart and quit.
  • The tooltip matches getTrayToolTip plus describeUnreadBadge: "Flaxative - Unread messages" for the dot and "Unread messages: {count}" for a count. The indicator is on when the badge is not 0.
  • The menu order and conditions match buildTrayMenu (DesktopTray.ts:407-532). Hide shows only when the window is visible and not minimised. Toggle semantics match toggleMainWindow. Accounts and custom CSS are absent, as spec §6 says (rows 10 and 12). Showing a hidden window when the tray is lost matches revealHiddenWindowIfTrayUnavailable.

5. Review Focus 6 (honest capability reporting). TrayAvailability::{Available, NoHost, NoWatcher, Disabled} is a typed state. NoHost and NoWatcher keep the model so a host that registers later still works. The user-facing "no system tray" string belongs to Task 38, not this task.

6. Gate. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci on 2cb39185: all steps passed (EXIT=0). shell_tray: 14 tests ok.

Findings

  • minor: "Copy build info" copies {Channel} Desktop {version} ({commit}). That is only the first part of the original's formatClientBuildInfo, which also lists web build, OS/arch, locale and so on. The doc comment says this. It is acceptable for a native client, but it is a deliberate deviation and belongs in the parity list (Task 43).
  • minor: the badge count is always grouped the English way (12,345). The original uses toLocaleString(getNativeLocale()). This is fine while the client is English-only.
  • minor: the plan names the test tray_lost_while_hidden_shows_window; on the branch it is tray_lost_while_hidden_shows_window_once. It asserts more than the plan asks, so this is cosmetic.
  • minor: the menu folds two separators in a row into one, which the original does not do. This happens, for example, when no update is offered, the updater is disabled and there is no build info. Menu hosts collapse doubled separators anyway, and the code comments on it.

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

## Independent review: Shell 8 (core tray model and actions) **Scope.** `git diff 2cb39185..origin/shell-8-core-tray-model-and` is empty: the branch head is 2cb39185, already an ancestor of `origin/shell` (merged by hand as baf0a9298). So I reviewed the task's own commits instead (567810ffe `feat(core): tray model`, 88cd55079 `cargo fmt`) as they stand on the branch: `crates/fluxer-core/src/shell/tray.rs`, `tests/shell_tray.rs`, and the `app.rs`, `shell/mod.rs` and README hooks. Those files have not changed between the branch and `origin/shell`. **1. Plan tests.** All are present and assert what the plan asks for: `menu_rows_per_state` (logged out, logged in, in voice, muted, deafened, named channel, DM call, update offered, updater idle, hidden, minimised), `status_radio_follows_presence`, `tooltip_per_badge` (None, Dot, Count 3, 12,345, 0), `model_emitted_only_on_change`, `every_action_maps` (iterates `TrayAction::ALL`) and the tray-lost test. There are also extra tests: rows carry their actions, appearance, no model without icon or tray, a dev build's build info, and how window rules interact with the tray. **2. Interfaces.** `tray_model(&App) -> Option<TrayModel>`, `TrayModel { tooltip, indicator, appearance, menu }`, `TrayAppearance::{Colored, Mono}`, `TrayItem::{Action{label,action,enabled}, Radio{label,action,checked}, Submenu{label,items}, Separator}`, and all 12 `TrayAction` variants exist exactly as the plan names them. `ShellEvent::TrayAvailability` is stored in `ShellState::tray`. `Effect::Shell(ShellCommand::Tray(model))` is sent only when the model changes, and `RemoveTray` when the model goes away. Tasks 20, 21 and 22 already build on these names in `shell`. **3. Invariants.** `tray.rs` is pure. It does no I/O and imports no iced, wgpu, winit, reqwest or tokio-tungstenite. It has no panics on server data: a channel name that is missing or empty falls back to "Disconnect from voice", and the badge-count formatting is plain arithmetic. It adds no fixtures. It contains no secrets, tokens or paths. **4. Parity spot checks** against `fluxer_desktop/src/main` in the fork: - Strings match `MainI18n.ts:57-117` exactly. This covers show/hide, open settings, the status rows, mute/unmute, deafen/undeafen, "Disconnect from {channel}" with FSI/PDI isolation, disconnect voice, update now, check for updates, copy build info, restart and quit. - The tooltip matches `getTrayToolTip` plus `describeUnreadBadge`: "Flaxative - Unread messages" for the dot and "Unread messages: {count}" for a count. The indicator is on when the badge is not 0. - The menu order and conditions match `buildTrayMenu` (`DesktopTray.ts:407-532`). Hide shows only when the window is visible and not minimised. Toggle semantics match `toggleMainWindow`. Accounts and custom CSS are absent, as spec §6 says (rows 10 and 12). Showing a hidden window when the tray is lost matches `revealHiddenWindowIfTrayUnavailable`. **5. Review Focus 6** (honest capability reporting). `TrayAvailability::{Available, NoHost, NoWatcher, Disabled}` is a typed state. `NoHost` and `NoWatcher` keep the model so a host that registers later still works. The user-facing "no system tray" string belongs to Task 38, not this task. **6. Gate.** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` on 2cb39185: all steps passed (EXIT=0). `shell_tray`: 14 tests ok. ### Findings - **minor**: "Copy build info" copies `{Channel} Desktop {version} ({commit})`. That is only the first part of the original's `formatClientBuildInfo`, which also lists web build, OS/arch, locale and so on. The doc comment says this. It is acceptable for a native client, but it is a deliberate deviation and belongs in the parity list (Task 43). - **minor**: the badge count is always grouped the English way (`12,345`). The original uses `toLocaleString(getNativeLocale())`. This is fine while the client is English-only. - **minor**: the plan names the test `tray_lost_while_hidden_shows_window`; on the branch it is `tray_lost_while_hidden_shows_window_once`. It asserts more than the plan asks, so this is cosmetic. - **minor**: the menu folds two separators in a row into one, which the original does not do. This happens, for example, when no update is offered, the updater is disabled and there is no build info. Menu hosts collapse doubled separators anyway, and the code comments on it. **Verdict: APPROVED.** No blocking findings, and the local gate is green.

Pull request closed

Sign in to join this conversation.
No description provided.