Add scrollback buffer for reattach context - #31
Open
bmills23 wants to merge 2 commits into
Open
Conversation
When a client attaches to a dtach session, the master now replays buffered pty output so the user has immediate context of recent activity. This is critical for tools like terminallm that need to see what happened while detached. - Circular buffer in master.c captures all pty output - Replay sent to client on MSG_ATTACH before marking attached - New -b <size> option (supports K/M suffixes, default 256K, 0 to disable) - Removed screen clear on attach to preserve replayed content - Updated man page with -b documentation
On MSG_ATTACH, the replay is now bracketed with: ESC]dtach-rev;replay-start BEL ... scrollback data ... ESC]dtach-rev;replay-end BEL This lets clients like TerminaLLM distinguish replayed content from live PTY output and command echo. Unknown OSC sequences are silently ignored by standard terminals, so non-aware clients are unaffected.
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.
Hey, I've been using dtach for a while and the one thing that always bugged me is losing all context when reattaching. This adds a simple circular buffer in the master that captures pty output and replays it when a new client attaches.
-b <size>(supports K/M suffixes, or 0 to disable)-b 0Happy to adjust anything if needed.