fix(app): an update keeps the window as it was, and doesn't take the focus #34

Merged
HumanBean merged 1 commit from HumanBean/Beanstalk:fix/update-focus into main 2026-11-16 00:20:25 +00:00
Owner

Why

When the app updates itself between tests (auto-update, #19), it starts its new copy, and the new copy always showed its window and activated it. So an update could pull Beanstalk to the front over whatever the tester was doing, even when the window was behind other windows, minimized, or closed to the tray.

What changed

The new copy opens the window the way the old one had it, and takes the focus only when the old window had it.

  • Core/RestartWindow.cs: RestartWindow (Focused, Behind, Minimized, Hidden) and RestartWindowState. Of(open, minimized, active) says which one the old window was. BEANSTALK_RESTART_WINDOW carries it to the new copy, which takes it out of its environment at once (Take()), so nothing the app starts sees it. A value it doesn't know, or none, means a normal start.
  • App.RestartAsync passes the window's state to AgentService.StartNew(how).
  • At start, the app opens the window that way:
    • focused: in front, as before.
    • behind: shown with ShowActivated = false, so it doesn't take the focus.
    • minimized: shown minimized, without the focus.
    • hidden: no window, just the tray, as before the update.
  • A normal start, the tray's Open and a second start still bring the window to the front.

Nothing changes on screen except whether the window comes forward, so there are no screenshots.

Testing

  • Agent checks: 1681 passed. New checks cover the four states, reading each value back, unknown or missing values, and Take() clearing the variable.
  • dotnet build agent/App -c Release: no warnings.
  • In a headless sway with a terminal focused, I started the app as an update's restart does. hidden: no window, and the terminal kept the focus. behind and minimized can't be checked there: sway focuses every new tiled window, whatever the app asks, and has no minimize.
  • Not tested: behind and minimized on Windows (where ShowActivated = false shows the window without activating it) or on GNOME/KDE. That needs an update while the window is behind another one, on the next nightly.
## Why When the app updates itself between tests (auto-update, #19), it starts its new copy, and the new copy always showed its window and activated it. So an update could pull Beanstalk to the front over whatever the tester was doing, even when the window was behind other windows, minimized, or closed to the tray. ## What changed The new copy opens the window the way the old one had it, and takes the focus only when the old window had it. - `Core/RestartWindow.cs`: `RestartWindow` (Focused, Behind, Minimized, Hidden) and `RestartWindowState`. `Of(open, minimized, active)` says which one the old window was. `BEANSTALK_RESTART_WINDOW` carries it to the new copy, which takes it out of its environment at once (`Take()`), so nothing the app starts sees it. A value it doesn't know, or none, means a normal start. - `App.RestartAsync` passes the window's state to `AgentService.StartNew(how)`. - At start, the app opens the window that way: - **focused:** in front, as before. - **behind:** shown with `ShowActivated = false`, so it doesn't take the focus. - **minimized:** shown minimized, without the focus. - **hidden:** no window, just the tray, as before the update. - A normal start, the tray's Open and a second start still bring the window to the front. Nothing changes on screen except whether the window comes forward, so there are no screenshots. ## Testing - Agent checks: 1681 passed. New checks cover the four states, reading each value back, unknown or missing values, and `Take()` clearing the variable. - `dotnet build agent/App -c Release`: no warnings. - In a headless sway with a terminal focused, I started the app as an update's restart does. **hidden**: no window, and the terminal kept the focus. **behind** and **minimized** can't be checked there: sway focuses every new tiled window, whatever the app asks, and has no minimize. - **Not tested:** behind and minimized on Windows (where `ShowActivated = false` shows the window without activating it) or on GNOME/KDE. That needs an update while the window is behind another one, on the next nightly.
fix(app): an update keeps the window as it was, and doesn't take the focus
Some checks failed
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 4s
CI / Coordinator tests (pull_request) Has been cancelled
CI / Agent build and checks (pull_request) Has been cancelled
CI / Coordinator image (pull_request) Has been cancelled
97679adddc
After an update the app starts its new copy, and the new one always showed
its window and activated it: an update by itself, between tests, pulled the
window to the front over whatever the person was doing, even when the window
was behind other windows, minimized, or closed to the tray.

The old app now says how its window was (focused, behind, minimized or
hidden) in BEANSTALK_RESTART_WINDOW, and the new one, which takes the
variable out of its environment at once, opens the window the same way:
in front only when it had the focus, else shown without the focus
(ShowActivated = false), minimized, or not at all.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Beanstalk!34
No description provided.