Skip to content

Add output history replay - #32

Open
bigfactory wants to merge 1 commit into
crigler:masterfrom
bigfactory:output-history-replay
Open

Add output history replay#32
bigfactory wants to merge 1 commit into
crigler:masterfrom
bigfactory:output-history-replay

Conversation

@bigfactory

Copy link
Copy Markdown

Summary

  • Add an in-memory ring buffer for recent program output in the master process.
  • Replay retained output history when a new client attaches.
  • Add -H <bytes> to configure history size, with -H 0 disabling replay.
  • Document the new option in the man page and help output.

Test Plan

  • make -C /Users/bytedance/Github/dtach
  • Verified default history replay by starting an unattached session that prints output, then attaching and checking the output is replayed.
  • Verified -H 0 disables history replay.
  • Verified small history buffers keep only the newest bytes.
  • Verified invalid -H values are rejected.

Retain bounded process output history for reattach while filtering terminal query sequences that would otherwise feed responses back into the shell.
@rdebath

rdebath commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

There is another class of controls you will want to filter, the persistent state controls. Probably the common ones are the 'alternate screen' selection and the mouse control. The thing is you don't want to remove them, you want to hold the last state seen before the beginning of the buffer.

Unfortunately, it would also be nice to reset those when detaching; which would mean a lot more proactive understanding.
Like lists of ECMA-48 sequences with the first of each set being the reset.

Also CSI c CSI >c CSI ? 15n \033[?1049$p and loads more from XTerm, old XTerm, real VTs and others.

@bigfactory
bigfactory force-pushed the output-history-replay branch from 53b263e to 9f834a9 Compare June 22, 2026 07:50
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.

2 participants