Conversation
Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds support for playing asciinema v1 recordings by detecting the v1 single-JSON-object format and translating its relative delays into the existing playback event pipeline.
Changes:
- Introduces a
V1Recordingtype to deserialize v1 recordings (single JSON blob with relativestdoutdelays). - Updates playback to detect v2 first, then fall back to v1 by buffering the already-read content and converting to absolute timestamps.
- Adds a v1 fixture and tests to cover v1 playback (including speed and idle-time-limit variants).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| testdata/play_v1.json | Adds a v1-format recording fixture for tests. |
| src/commands/types.rs | Adds V1Recording for v1 deserialization. |
| src/commands/play.rs | Adds v1/v2 detection and a unified line source to run both through the same playback pipeline; adds tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for line in line_iter { | ||
| file_content.push('\n'); | ||
| file_content.push_str(&line.unwrap()); | ||
| } |
There was a problem hiding this comment.
The v1/v2 fallback path still has multiple unwrap() calls that can panic (file open error, empty file, I/O error while reading remaining lines), which contradicts the PR goal of exiting cleanly on unsupported/corrupt input. Handle these errors explicitly (e.g., print a clear error to stderr and exit(1), or refactor Session::new to return a Result<Session, _> and let the caller handle reporting).
|
@copilot ci failed. Fix it? Also check pr comments. |
- Fix testdata/play_v1.json: invalid JSON due to literal newlines in strings - Replace unwrap/panic with eprintln+exit(1) throughout play.rs - Improve error messages to use stderr with filename and error details Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
Fixed in 947907c. The CI failure was caused by Also addressed all the PR review comments in the same commit:
|
V1Recordingstruct totypes.rsfor deserializing v1 formatSessionLineSourceenum inplay.rsto support both v2 (file-based) and v1 (vec-based) iteratorsSession::newto detect v1 format and handle it properlytestdata/play_v1.jsonhad literal newlines inside JSON strings (invalid JSON)unwrap()/panic!witheprintln!+exit(1)for clean error reportingeprintln!(stderr) with filename and underlying error detailsOk(version≠1)andErr(parse_failure)arms for precise diagnosticsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.