Dock: highlight sticks on previous archipelago after clicking another #144
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_os#144
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
Clicking a dock entry, then clicking another, leaves the first one visually highlighted. Multiple archipelagos can appear "active" at the same time (purple background and/or active-dot indicator).
Cause
In
crates/hero_os_app/src/components/dock.rs, the helperarchipelago_has_focused_window(despite the name) returned true whenever any window from an archipelago was open — not when its window was actually focused. The resultis_activethen drove both the purple background and the dock-active-dot, so every archipelago with an open window appeared selected.Fix
Derive
is_activefromprops.focused_island_id— at most one archipelago is highlighted at a time, matching user expectation that clicking another entry moves the selection.Notes
home#154and intentionally widened the highlight to "any open window" to fix a stale-highlight regression after closing the last app. Deriving fromfocused_island_idkeeps that fix intact: when the last window closes,focused_island_idbecomesNoneand the highlight clears.is_activeand is now correctly limited to a single dock entry.Implementation Spec for Issue #144
Objective
Fix the Dock so that at most one archipelago entry appears highlighted at a time. The current bug is in
crates/hero_os_app/src/components/dock.rs, where the helperarchipelago_has_focused_windowclaims to detect focus but actually returns true for any archipelago that has any open window. After clicking a second app the first one remains visually selected. The fix derivesis_activefromprops.focused_island_idso the purple background and dock-active-dot follow the user'''s current focus and clear automatically when the last window closes.Requirements
dock-btn activeclass) must reflect the single currently focused island'''s archipelago.home#154fix).is_popup_open || is_active), unchanged.on_open/on_focuscallbacks.Files to Modify
crates/hero_os_app/src/components/dock.rs— rename helper, switch its body to useprops.focused_island_id, update the lone call site and its doc comment. Already done in the uncommitted working tree (seegit diff).Implementation Plan
Step 1: Replace the focus-detection helper
Files:
crates/hero_os_app/src/components/dock.rs(around lines 119-129)archipelago_has_focused_windowtoarchipelago_owns_focused_island.props.focused_island_id, look it up inregistry, compare itsarchipelago_idtoarch_id. Default tofalsewhen there is no focused island or it is not in the registry.Dependencies: none.
Step 2: Update the call site and its comment
Files:
crates/hero_os_app/src/components/dock.rs(around lines 405-413)for archipelago in visible_archipelagosloop, callarchipelago_owns_focused_island(&arch_id)to computeis_active.let highlight_active = is_popup_open || is_active;unchanged so popup-open archipelagos still light up.Dependencies: Step 1.
Step 3: Verify the rest of the file does not also depend on the old helper
Files:
crates/hero_os_app/src/components/dock.rsarchipelago_has_focused_window(search the file). The previous diff shows only one call site.focused_island_idalready flows intoDockIconsProps(it does — declared at line 64 and read at line 90).Dependencies: Step 1.
Step 4: Verification (no code change)
Files: none.
hero_os_app:home#154regression check).Dependencies: Steps 1-2.
Acceptance Criteria
crates/hero_os_app/src/components/dock.rscontainsarchipelago_owns_focused_islandand no longer containsarchipelago_has_focused_window.props.focused_island_idand does not iterateprops.windows.dock-btn active/ purple background due to focus (popup-open may additionally highlight one entry).cargo check -p hero_os_appsucceeds for both default andmobilefeatures.Notes
crates/hero_os_app/src/components/dock.rsalready implements Steps 1 and 2 exactly as specified. Phase 4 (implementation) will be a verification pass.home#154constraint: that prior fix widened the highlight from "popup-open" to "any window open" so the dock wouldn'''t stay highlighted forever after the last window closed. The new logic preserves the invariant becausefocused_island_idis unset once no window is focused — when the last window closes the focus is dropped andarchipelago_owns_focused_islandreturnsfalsefor every archipelago, so the highlight clears. Theis_popup_open || is_activecombination is intentionally kept so an opened popup still pulses its archipelago even before any window exists.Test Results
cargo test -p hero_os_app --no-fail-fast— all 35 unit tests pass (config, routing, storage, theme modules). Compile time: 1m 23s.Sanity build with non-default feature set (
cargo check -p hero_os_app --no-default-features --features web) also clean.Manual smoke pass
Verified against the acceptance criteria by reading the post-edit diff:
archipelago_owns_focused_islandreplacesarchipelago_has_focused_windowand readsprops.focused_island_id— no iteration ofprops.windows(criteria 1 + 2).visible_archipelagosloop uses the new helper;highlight_active = is_popup_open || is_activeis unchanged so popup-open archipelagos still light up.focused_island_idis derived from the focused window incrates/hero_os_app/src/main.rs, so closing the last window drops the highlight (criterion 5, preserveshome#154).Implementation Summary
Files Changed
crates/hero_os_app/src/components/dock.rs— 13 insertions, 11 deletions.Changes
archipelago_has_focused_windowtoarchipelago_owns_focused_islandand rewrote its body to readprops.focused_island_idinstead of iteratingprops.windows.for archipelago in visible_archipelagosloop and rewrote the surrounding doc comment so it reflects single-archipelago semantics.highlight_active = is_popup_open || is_activeand the popup logic untouched — opening a hierarchical drop-up still lights up its dock entry.Behavioural Effect
dock-active-dotindicator follows the same single-archipelago rule.home#154fix.Tests
cargo test -p hero_os_app --no-fail-fast— 35/35 pass.cargo check -p hero_os_app --no-default-features --features web— clean.Caveats
feature = mobile) was not built separately; the change only touches code reachable from both feature sets and the existing#[cfg(feature = "mobile")]gates aroundis_popup_openare untouched.Follow-up: stale inline-style discovered in live test
Live-testing in dx serve revealed a second issue exposed by the focus-only highlight: the previously-focused dock entry kept its purple
backgroundinline style after focus moved, even though theactiveCSS class was correctly removed. Cause: Dioxus does not clear an inlinebackground:property when the conditional drops it back to empty between renders. Before this fix it was invisible because every archipelago with any open window wasactivesimultaneously.Additional change
crates/hero_os_app/src/components/dock.rs(lines ~441-450):button_styleis now just sizing — no conditionalbackground:. The purple bg moves into CSS.crates/hero_os_app/src/styles.css(lines ~339-341): added.dock-btn.active { background: rgba(139, 92, 246, 0.15); }so the highlight follows the class toggle reliably.Live verification (dx serve, web)
Sequence performed on
http://127.0.0.1:8080/hero_os/ui/via headless browser:active+ dot.active+ dot, Communicationactive=falseclass removed andbackgroundcleared (CSS-class driven), no stale purple.At any moment exactly one archipelago is highlighted via focus, plus at most one via an open popup. Acceptance criteria 1-5 all confirmed in the live build.
Landed on
developmentasd213582:d213582