Skip to content

Add scrollback buffer for reattach context - #31

Open
bmills23 wants to merge 2 commits into
crigler:masterfrom
bmills23:scrollback-buffer
Open

Add scrollback buffer for reattach context#31
bmills23 wants to merge 2 commits into
crigler:masterfrom
bmills23:scrollback-buffer

Conversation

@bmills23

Copy link
Copy Markdown

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.

  • Defaults to 256K, configurable with -b <size> (supports K/M suffixes, or 0 to disable)
  • No impact on existing behavior if you pass -b 0
  • Updated the man page

Happy to adjust anything if needed.

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.
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.

1 participant