feat: add @wterm/serialize for session persistence#36
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
Adds a new package that serializes wterm terminal state (grid, scrollback, cursor, modes) into a portable snapshot and restores it into a fresh terminal, matching the capability xterm.js users get from @xterm/addon-serialize. Closes vercel-labs#35.
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Comment on lines
+51
to
+53
| const parts = [snapshot.payload]; | ||
|
|
||
| if (snapshot.modes.altScreen) parts.push("\x1b[?1049h"); |
There was a problem hiding this comment.
Suggested change
| const parts = [snapshot.payload]; | |
| if (snapshot.modes.altScreen) parts.push("\x1b[?1049h"); | |
| const parts: string[] = []; | |
| if (snapshot.modes.altScreen) parts.push("\x1b[?1049h"); | |
| parts.push(snapshot.payload); |
When restoring an alt screen snapshot, the payload content is written to the main screen first, then \x1b[?1049h switches to a clean empty alt screen, causing all serialized alt screen content to be lost/hidden.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #35.
Adds a new package
@wterm/serializethat snapshots wterm state (grid cells, scrollback, cursor, modes, palette) into a portable string and restores it into a fresh terminal. Matches the capability xterm.js users get from@xterm/addon-serialize.Usage
Approach
term.write()reproduces the exact cell state, which reuses the renderer you already have rather than introducing a parallel restore path@wterm/coreor@wterm/domTesting
17 new tests in
packages/@wterm/serialize/src/__tests__/:Full repo CI is green:
pnpm test151 passing,pnpm format:check,pnpm typecheck,pnpm buildall clean.Demo
Left terminal holds a live session.
serialize()returns a snapshot string. A fresh WTerm mounts after reload andrestore()rebuilds the exact state into the right terminal.Notes
AGENTS.md🤖 Generated with Claude Code