Skip to content

"Open windows from a previous session" opens wrong tabs after crash #18838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sparrowt opened this issue Apr 25, 2025 · 3 comments · Fixed by #18898
Closed

"Open windows from a previous session" opens wrong tabs after crash #18838

sparrowt opened this issue Apr 25, 2025 · 3 comments · Fixed by #18898
Assignees
Labels
Area-Windowing Window frame, quake mode, tearout Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Priority-3 A description (P3) Product-Terminal The new Windows Terminal.

Comments

@sparrowt
Copy link

sparrowt commented Apr 25, 2025

Windows Terminal version

1.22.10731.0

Windows build number

10.0.26100.0

Other Software

No response

Steps to reproduce

  1. Run Windows Terminal for several days, over which period many tabs have been opened, closed, renamed etc.
  2. Somehow Windows Terminal crashes (this in itself is obviously caused by a different bug, but inevitably this will sometimes happen)
  3. Re-launch Windows Terminal and find that it has restored the wrong tabs (the ones that were open last time it had a clean shutdown)

Expected Behavior

Windows Terminal should restore the tabs that were open at least vaguely recently before the crash (e.g. by persisting this state either on a regular interval, or each time a new tab is opened/renamed.

Actual Behavior

Instead it restores whatever tabs were open last time I explicitly closed it (i.e. the same set that it restored last time) which may well be multiple days ago and completely different from the tabs that I had been using before the crash.

Unfortunately this makes the restore feature pretty useless in the case of a crash 😢

@sparrowt sparrowt added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Apr 25, 2025
@sparrowt sparrowt changed the title Wrong tabs opened after a crash via "Open windows from a previous session"to "Open windows from a previous session" opens wrong tabs after crash Apr 25, 2025
@DHowett
Copy link
Member

DHowett commented Apr 30, 2025

Hmmmmmmm. Well, that's not good. Thanks!

@DHowett DHowett added Priority-3 A description (P3) Area-Windowing Window frame, quake mode, tearout labels Apr 30, 2025
@DHowett DHowett removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Apr 30, 2025
@DHowett
Copy link
Member

DHowett commented Apr 30, 2025

Notes from discussion: maybe we should persist the window layout (cheap) every couple minutes or whatever, but not the buffers yet (too expensive to do serially).

Right now, we only clear the old session off disk when we save a new one. You can well imagine what that means. 🙂

@DHowett DHowett added this to the Terminal v1.24 milestone Apr 30, 2025
@DHowett DHowett added the Product-Terminal The new Windows Terminal. label Apr 30, 2025
@sparrowt
Copy link
Author

sparrowt commented May 1, 2025

maybe we should persist the window layout (cheap) every couple minutes or whatever, but not the buffers yet

Thanks yes that would be great - the crucial thing is remembering which set of things I was keeping an eye on and the terminal type + tab title (+ cwd) is much better than nothing. I'm not fussed about the buffers (in fact would be nice to be able to disable that, pretty sure I've seen another ticket for that).

carlos-zamora added a commit that referenced this issue May 14, 2025
If `persistedWindowLayout` is enabled, we now persist the window layout
every few minutes (excluding the text buffer).

This was done by adding a `SafeDispatcherTimer` to the `WindowEmperor`
that calls `PersistState()` every 5 minutes. For `BuildStartupKind`, I
split up `Persist` into `PersistAll` and `PersistLayout`. This way, we
go through all the same code flow that `Persist` had except for
specifically serializing the buffer.

## Validation Steps Performed
✅ (with the timer set to 3 seconds) create a window layout and ensure
the layout is restored after forcefully stopping Terminal (aka
simulating a "crash")

Closes #18838
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Windowing Window frame, quake mode, tearout Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Priority-3 A description (P3) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants