Skip to content

Add periodic buffer persistence to protect against unexpected termination#19805

Open
sgeraldes wants to merge 2 commits intomicrosoft:mainfrom
sgeraldes:periodic-buffer-persistence
Open

Add periodic buffer persistence to protect against unexpected termination#19805
sgeraldes wants to merge 2 commits intomicrosoft:mainfrom
sgeraldes:periodic-buffer-persistence

Conversation

@sgeraldes
Copy link

Summary

This PR adds periodic buffer persistence to protect against unexpected termination (BSOD, power failure, Task Manager kill).

Fixes #19804

The Problem

Previously, terminal buffer content was only persisted on graceful exit:

  • At end of message loop (normal quit)
  • On WM_ENDSESSION (graceful OS shutdown)

The 5-minute persistence timer only saved layout (tabs, panes, positions), not buffer content. This meant:

What Gets Saved When Survives Unexpected Termination
Tab layout Every 5 minutes ✅ Yes
Buffer content Only on graceful exit No

Users running long-lived sessions (Claude Code, SSH, development environments) would lose hours of terminal history on crash, even though tabs appeared to be "restored."

The Solution

  • Extract buffer persistence into a new _persistBuffers() function
  • Call _persistBuffers() on the existing 5-minute persistence timer
  • Refactor _finalizeSessionPersistence() to use the shared function

Now buffer content is saved every 5 minutes alongside layout.

Validation Steps Performed

  • Code review for correctness
  • Verified refactored _finalizeSessionPersistence() maintains cleanup behavior
  • Confirmed _persistBuffers() respects FirstWindowPreference::PersistedLayoutAndContent setting

PR Checklist


🤖 Generated with Claude Code

…tion

Fixes microsoft#19804

Previously, terminal buffer content was only persisted on graceful exit
(normal quit or WM_ENDSESSION). This meant that unexpected terminations
like BSOD, power failure, or Task Manager kills would cause complete
buffer loss, even though tab layout was preserved by the 5-minute timer.

This change:
- Extracts buffer persistence into a new `_persistBuffers()` function
- Calls `_persistBuffers()` on the existing 5-minute persistence timer
- Refactors `_finalizeSessionPersistence()` to use the shared function

Now buffer content is saved every 5 minutes alongside layout, protecting
users running long-lived sessions (Claude Code, SSH, development
environments) from losing hours of terminal history on crash.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@sgeraldes
Copy link
Author

@microsoft-github-policy-service agree

The irony of Microsoft's own spell checker not recognizing "BSOD"
(Blue Screen of Death) - a term coined specifically for Windows crashes
- is not lost on anyone. 😅

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sgeraldes
Copy link
Author

Had to add a second commit to appease the spell checker gods. 📝

The irony here is chef's kiss — Microsoft's own CI spell checker flagging "BSOD" as an unknown word. You know, Blue Screen of Death... the thing Windows has been (in)famous for since Windows 3.1?

I get it, we're trying to move past that reputation, but denying its existence in the dictionary feels like revisionist history. 😄

The term is now safely enshrined in expect.txt where it belongs — right between Bspace and BTNFACE, as Ballmer intended.

@DHowett
Copy link
Member

DHowett commented Jan 28, 2026

The irony here is chef's kiss — Microsoft's own CI spell checker flagging "BSOD" as an unknown word. You know, Blue Screen of Death... the thing Windows has been (in)famous for since Windows 3.1?

I get it, we're trying to move past that reputation, but denying its existence in the dictionary feels like revisionist history. 😄

I appreciate your contribution, but don't be weird about it. It's not in the dictionary because it is not used in this codebase. The spell checker is maintained by a non-Microsoft person, hosted in a non-Microsoft repository, as non-Microsoft property, and the dictionaries only get updated as needed when somebody wants to use an unusual term of art.

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.

Feature Request: Periodic Buffer Persistence for Crash Recovery

3 participants