Skip to content

fix(vd): don't panic when a workspace has no monitor any more - #1843

Merged
eythaann merged 1 commit into
eythaann:masterfrom
Vatsonio:pr/vd-workspace-index-panic
Sep 24, 2026
Merged

eythaann merged 1 commit into
eythaann:masterfrom
Vatsonio:pr/vd-workspace-index-panic

Conversation

@Vatsonio

Copy link
Copy Markdown
Contributor

The bug

SluWorkspacesManager2::get_monitor_of_workspace ends in

.expect("workspace_index is broken")

but a miss there is not a broken invariant. Removing a monitor drops its
workspaces from the index, while a window can still carry the id of one of
them until it is retracked. The next lookup for that window panics.

Observed on a laptop when the physical display was swapped for a simulated one
(screen going to sleep):

[TRACE] @seelen/weg?monitorId=LGD068B0_00_07E4_99 dropped
[TRACE] @seelen/weg?monitorId=SIMULATED_8086_9A49_... status changed to: Creating
[ERROR] A panic occurred:
  Cause: workspace_index is broken
  Location: src\background\virtual_desktops\mod.rs:312:14
[TRACE] MonitorManagerEvent::ViewRemoved(MonitorId("LGD068B0_00_07E4_99"))

The fix

get_monitor_of_workspace returns Option<MonitorId>, and each of its four
callers handles a miss the way that makes sense for it:

  • the unminimize handler skips the workspace switch; the window still comes
    back, it just does not drag the user to a workspace that no longer exists
  • send_to returns Ok(()) without moving anything, the same as its
    existing early return for untracked windows
  • switch_workspace, destroy_workspace and rename_workspace return an
    Unknown workspace error to the caller instead of taking the process down

No behaviour changes when the lookup succeeds.

Verified

  • cargo clippy --all-targets -- -D warnings, cargo fmt --check,
    deno fmt --check and the repo's pre-commit hooks clean
  • running on the affected machine since the fix without a panic

To be precise about the second point: the display swap has not recurred on
that machine since the build with this fix was installed, so this is verified
by construction rather than by reproducing the swap. The panic site and the
callers are small enough that I am comfortable with that, but I would rather
say it than imply otherwise.

Possibly related, not addressed here

The same log has an older, unrelated panic from the official 2.8.6 build:

Cause: cannot move state from Destroyed

I did not look into it.

get_monitor_of_workspace ended in `.expect("workspace_index is broken")`,
but a miss there is not a bug: removing a monitor drops its workspaces while
a window can still carry the id of one of them until it is retracked. On a
display change that panicked the whole app.

Observed when the physical display was swapped for a simulated one (screen
going to sleep on a laptop), immediately followed by:

    Cause: workspace_index is broken
    Location: src\background\virtual_desktops\mod.rs:312:14

It now returns Option. The unminimize handler skips the workspace switch,
send_to returns without moving anything, and the three Tauri commands return
an error instead of taking the process down.
@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge and removes the reported process-terminating failure without introducing a supported-path regression.

Summary

This PR makes missing workspace-index entries non-fatal by returning an optional monitor ID and handling misses according to each caller:

  • Workspace switching, destruction, and renaming now return an Unknown workspace error.
  • Window moves and stale unminimize events become safe no-ops.
  • Successful workspace lookups retain their existing behavior.

Reviews (1) · Last reviewed commit: "fix(vd): don't panic when a workspace ha..."

@eythaann
eythaann merged commit 5311727 into eythaann:master Sep 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants