8000 Autobackup not considering all open windows? · Issue #118 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content

Autobackup not considering all open windows? #118

Closed

Description

@arnonuem

Unfortunately I can`t prove it but i suspect the autobackup does not save the state of all open windows.

With autobackup enabled/loaded i lost all my open browser instances / links.

I use those to persist things but every session just showed the wmux webpage. Would be awesome if autobackup could also backup these. I had an old saved session and with that i was able to at least recover some of my pages.

Activity

  1. amirlehmam commented on Jul 28, 2026

    @amirlehmam
    Owner

    Fixed in 43e049a, shipping in v0.37.0. You were right, and it was worse than "does not save all windows" — it actively destroyed the state of every window but one, every 30 seconds.

    The bug

    Auto-save is a broadcast. Main sends session:request to every window, and each renderer answers with its own state, wrapped as a one-entry array because that's the file's shape:

    window.wmux.session.pushAutoSave({ version: 1, windows: [ /* just me */ ] });

    That payload went straight into saveSession(data) — which writes the whole file. So with two windows open, both answered, and whichever answered last overwrote the other one's entry. Every 30 seconds, and again on quit. There was never a merge step; the format had room for N windows and the write path only ever held one.

    The same windows[0] assumption sat on the read side. SESSION_LOAD_AUTO handed the first window's state to whoever asked, so a second window came up as a clone of the first's tabs rather than its own, and a multi-window session could never restore more than one window's worth of state anyway.

    On the browser pages specifically

    Those are stored per surface (surface.url, persisted into the split tree since #40), so they were never the weak link — they went down with the rest of the window's entry when it got clobbered. Which also explains the shape of what you saw: not "browser tabs are special and don't persist", but "one window's whole tree survived and the other's didn't", and the surviving one showed the default page because it was a different window.

    That you had to recover from an old named session fits exactly: named saves are explicit single-window snapshots and never went through the broadcast, so they were the only thing the race couldn't touch.

    The fix

    SessionWindowRegistry gives each window a slot. A save upserts one slot and serialises all of them; restore hands each window back its own; launch reopens every saved window (capped at 8, so a corrupt file can't spawn windows without bound).

    Two cases deliberately do not prune a window's slot, and both matter:

    • During shutdown. Every window is being destroyed, so "forget windows that no longer exist" would erase the file we're in the middle of writing.
    • When closing the last window. That's how most people quit wmux, and it has to persist everything for next launch — not read as "the user closed their only window, forget it".

    Closing window 2 of 3 does forget it, immediately and on disk, so a window you deliberately closed doesn't come back as a ghost.

    Tests cover the merge, the ordering (creation order, not who-answered-first), priming a restored window that never reports, and both no-prune cases.

    One behaviour change worth flagging

    A new window (Ctrl+Shift+N or wmux new-window) now opens empty instead of duplicating your first window's workspaces. That was the read-side half of this bug, but if you'd gotten used to it as a "duplicate this window" gesture, it's gone.

    Unfortunately I can't prove it but i suspect…

    For what it's worth, the suspicion was enough. Thanks for filing it anyway rather than writing it off.

  2. arnonuem commented on Jul 28, 2026

    @arnonuem
    Author

    "launch reopens every saved window (capped at 8, so a corrupt file can't spawn windows without bound)."

    What does this mean? I usually have about 20 sessions open :/
    I expect them to be opened all of them when I launch wmux.

  3. added a commit that references this issue on Jul 28, 2026
    43e049a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0