Skip to content

feat: save and replay decoded sessions#32

Merged
sunng87 merged 2 commits into
sunng87:mainfrom
iPeluwa:feat/session-save-replay
Jul 22, 2026
Merged

feat: save and replay decoded sessions#32
sunng87 merged 2 commits into
sunng87:mainfrom
iPeluwa:feat/session-save-replay

Conversation

@iPeluwa

@iPeluwa iPeluwa commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • I added a schema-versioned JSONL format that preserves decoded message timestamps, client addresses, direction, type, text, flat rendering, and rich RowDescription/DataRow details.
  • I added --save FILE to continuously record the complete output stream before display filtering or TUI history eviction, while stdout or the TUI continues normally.
  • I added --replay FILE as a file source that replaces pcap/mitm and feeds saved records through the existing stdout, display-filter, and rich TUI rendering pipeline.
  • I added a TUI command bar on / and : with :save/:w and :open/:o commands.
  • I documented schema version 1, replay behavior, compatibility rules, security considerations, CLI options, and TUI commands.

Design decisions

The saved format is structured JSONL rather than a plain transcript. Every record carries schema_version: 1 and an RFC 3339 timestamp. Message records retain the filter fields and optional rich-rendering payload, so replayed traffic behaves like live decoded traffic instead of becoming display-only text.

--save writes each completed JSONL line directly to disk before display filtering and independently of the bounded TUI history. Unknown schema versions, malformed records, invalid timestamps, and attempts to overwrite the replay input are refused with explicit errors.

CLI replay is instant and streams large files without retaining the full session. TUI open validates the complete file atomically and retains the newest 50,000 records. Opening from a live TUI switches the view to replay mode, closes any active recorder, and discards subsequent live display records so the two timelines cannot mix.

User impact

tapgres --save session.jsonl
tapgres --replay session.jsonl
tapgres --replay session.jsonl --tui --tui-rich
tapgres --replay session.jsonl -Y 'message.type == "Query"'

In the TUI, / or : opens the command bar:

:save session.jsonl
:open session.jsonl

Validation

  • cargo fmt --all --check
  • cargo test --all-targets (64 tests passed: 54 library, 5 protocol replay, 5 session CLI)
  • cargo clippy --all-targets -- -D warnings
  • cargo build --release
  • generated manpage verification
  • package-content verification for the schema documentation and compatibility fixture
  • interactive rich-mode TUI replay and :open smoke test
  • git diff --check

Closes #16.

@iPeluwa
iPeluwa marked this pull request as ready for review July 17, 2026 18:59
@sunng87

sunng87 commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Can we confirm there is a new mode when we use tapgres --replay session.jsonl? tapgres should not be listening to pcap or tcp port for this mode, it's readonly.

@sunng87

sunng87 commented Jul 22, 2026

Copy link
Copy Markdown
Owner

let me merge this first and verify by myself.

@sunng87
sunng87 merged commit 1051896 into sunng87:main Jul 22, 2026
2 checks passed
sunng87 added a commit that referenced this pull request Jul 22, 2026
The SAVED SESSIONS section and OPTIONS entries for --save/--replay landed
in #32, but the EXAMPLES section only covered pcap/mitm/TUI-filter usage.
Add three examples mirroring the README so the manpage stands alone:

  tapgres --save session.jsonl
  tapgres --replay session.jsonl --tui
  tapgres --replay session.jsonl -Y 'message.type == "Query"'
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.

Save and open captured message files (CLI + TUI)

2 participants