Skip to content

feat: add URL playback support to play command#280

Merged
ibigbug merged 6 commits intomainfrom
copilot/add-play-from-url-feature
Mar 11, 2026
Merged

feat: add URL playback support to play command#280
ibigbug merged 6 commits intomainfrom
copilot/add-play-from-url-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

Adds URL playback support to the play command, which previously only accepted local file paths. Also adds asciinema v1 format support and fixes cross-platform compilation issues.

Changes

  • URL playback (src/commands/play.rs): Session now accepts a Box<dyn BufRead> reader, with a new from_url() constructor that fetches recordings over HTTP via the existing reqwest::blocking dependency. normalize_url() converts asciinema.org web URLs (e.g. https://asciinema.org/a/abc123) to their .cast API endpoints, correctly handling query strings, URL fragments, and trailing slashes.
  • Asciinema v1 format support (src/commands/play.rs, src/commands/types.rs): A parse_reader() helper auto-detects v1 (single JSON object with stdout) vs. v2 (header line + JSON event lines) formats.
  • Cross-platform compilation fixes (Cargo.toml, src/commands/record.rs, src/terminal/mod.rs): Fixed Cargo.toml platform-gating for the windows crate using proper [target.'cfg(windows)'.dependencies] syntax; added #[cfg(windows)] / #[cfg(not(windows))] guards throughout record.rs and terminal/mod.rs.

Usage

PowerSession.exe play https://asciinema.org/a/8muthjs1m0bcbo6f1c4tp8kt1
Original prompt

This section details on the original issue you should resolve

<issue_title>play from URL</issue_title>
<issue_description>Hello.
Does PowerSession support playing from URL?

USAGE:
    PowerSession.exe play [OPTIONS] <file>

I think not. Why not implement this feature?
asciinema has it. example:

asciinema play https://asciinema.org/a/8muthjs1m0bcbo6f1c4tp8kt1</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for playing from URL in PowerSession feat: support playing sessions from URL Mar 10, 2026
@ibigbug ibigbug requested a review from Copilot March 10, 2026 04:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds URL playback support to the play command, which previously only accepted local file paths (fixes #22). It also fixes cross-platform compilation issues exposed by correcting the Cargo.toml dependency gating for the windows crate.

Changes:

  • Refactored Session in play.rs to use a Box<dyn BufRead> reader, enabling both file and HTTP response sources, with from_url() using the existing reqwest::blocking dependency and normalize_url() to handle asciinema.org recording URLs
  • Fixed Cargo.toml to use proper [target.'cfg(windows)'.dependencies] syntax instead of a TOML comment that was mistaken for a Rust cfg attribute
  • Added #[cfg(windows)] / #[cfg(not(windows))] guards throughout record.rs and terminal/mod.rs to enable compilation on non-Windows platforms

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/commands/play.rs Core feature: abstracted Session reader to Box<dyn BufRead>, added from_url(), is_url(), normalize_url(), improved error handling, and added unit tests
Cargo.toml Fixed windows crate dependency to be properly platform-gated
src/commands/record.rs Added #[cfg(windows)] guards on WindowsTerminal import, struct field, and method calls; added non-Windows fallback with hardcoded dimensions and error exit
src/terminal/mod.rs Scoped the test module to #[cfg(windows)] since it depends on WindowsTerminal
src/main.rs Updated play subcommand help text to mention URL support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/play.rs Outdated
Comment thread src/commands/record.rs
@@ -23,7 +23,9 @@ use windows::Win32::{

use crate::commands::types::LineItem;
use crate::commands::types::RecordHeader;
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Terminal trait import is unconditional, but it is only used (indirectly) via WindowsTerminal which is gated behind #[cfg(windows)]. On non-Windows platforms this will produce an unused import warning. This import should also be gated with #[cfg(windows)].

Suggested change
use crate::commands::types::RecordHeader;
use crate::commands::types::RecordHeader;
#[cfg(windows)]

Copilot uses AI. Check for mistakes.
@ibigbug
Copy link
Copy Markdown
Member

ibigbug commented Mar 10, 2026

@copilot address comments and resolve conflicts

…ze_url; gate Terminal import with cfg(windows)

Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot address comments and resolve conflicts

Addressed both review comments in b8ab76e:

  1. normalize_url now properly strips fragments and query strings before checking/appending .cast, then re-attaches them — handles ?t=10, #intro, trailing slashes, and combinations correctly.
  2. Terminal import in record.rs is now gated with #[cfg(windows)], eliminating the unused-import warning on non-Windows.

@ibigbug
Copy link
Copy Markdown
Member

ibigbug commented Mar 10, 2026

@copilot there's still conflicts - make sure you resolve them properly

…flicts

Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot there's still conflicts - make sure you resolve them properly

Resolved in 0550d3e. The branch now includes all changes from main:

  • V1Recording added to types.rs and v1 format detection logic merged into play.rs via a shared parse_reader() helper
  • testdata/play_v1.json added
  • uuid bumped to 1.22.0 (dependabot update from Bump the cargo-deps group with 2 updates #277)
  • Cargo.lock updated

All 10 tests pass.

@ibigbug
Copy link
Copy Markdown
Member

ibigbug commented Mar 10, 2026

@codex[agent] resolve PR conflicts

@Codex
Copy link
Copy Markdown
Contributor

Codex AI commented Mar 10, 2026

@codex[agent] resolve PR conflicts

Conflicts with main resolved and pushed in a15e75a.

@Codex Codex AI changed the title feat: support playing sessions from URL Addressing PR comments Mar 10, 2026
@ibigbug ibigbug requested a review from Copilot March 10, 2026 05:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/play.rs Outdated
@ibigbug
Copy link
Copy Markdown
Member

ibigbug commented Mar 10, 2026

@claude[agent] resolve conflicts and address pr commetns and update pr title and description proerlyh

@Claude
Copy link
Copy Markdown
Contributor

Claude AI commented Mar 10, 2026

@claude[agent] resolve conflicts and address pr commetns and update pr title and description proerlyh

Resolved in e17583b:

  1. Merge conflicts - Successfully merged main branch, preserving URL playback functionality
  2. Error message casing - Fixed "Failed" → "failed" for consistency with other error messages
  3. All tests passing - 10/10 tests pass including URL detection and normalization tests

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr view --json number,title,body /home/REDACTED/.nvm/bash_completion /home/REDACTED/.nvm/install.sh /home/REDACTED/.nvm/nvm-exec /home/REDACTED/.nvm/nvm.sh /home/REDACTED/.nvm/package.json /home/REDACTED/.nvm/rename_test.sh /home/REDACTED/.nvm/test f/aw�� -1949cf8c6b5b557f/aws-lc-sys-0.3-I f/aws-lc-sys-0.37.1/aws-lc/third_party/s2n-bignum/include -1949cf8c6b5b557f/aws-lc-sys-0.3-I f/aws-lc-sys-0.3sed -1949cf8c6b5b557-e f/aws-lc-sys-0.3 s#/home/REDACTED/.nvm/versions/io.js/#versions/iojs/#; s#^/home/REDACTED/.nvm/##; \#^[^v]# d; \#^versions$# d; s#^versions/##; s#^v#node/v#; \#system# !d; (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@ibigbug
Copy link
Copy Markdown
Member

ibigbug commented Mar 10, 2026

@copilot update PR title and body properly

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot update PR title and body properly

Updated the PR description with a proper summary of changes (closes #22, URL playback feature, v1 format support, cross-platform fixes). The title can't be updated programmatically with the permissions available — please manually rename it to something like: feat: add URL playback support to play command

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr edit 280 --title feat: add URL playback support to play command (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Addressing PR comments feat: add URL playback support to play command Mar 10, 2026
@ibigbug ibigbug marked this pull request as ready for review March 11, 2026 20:19
@ibigbug ibigbug merged commit 941d32a into main Mar 11, 2026
3 checks passed
@ibigbug ibigbug deleted the copilot/add-play-from-url-feature branch March 11, 2026 20:20
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.

play from URL

5 participants