Support --copy for streaming responses (SSE, NDJSON, gRPC)#381
Merged
ryanfowler merged 1 commit intomainfrom Feb 1, 2026
Merged
Support --copy for streaming responses (SSE, NDJSON, gRPC)#381ryanfowler merged 1 commit intomainfrom
ryanfowler merged 1 commit intomainfrom
Conversation
Replace the upfront rejection of --copy for streaming content types with a limitedBuffer writer that captures up to 1 MiB as the stream is consumed. If the response exceeds the limit, a warning is printed and the copy is skipped instead of silently truncating data.
There was a problem hiding this comment.
Pull request overview
This PR enables clipboard copying for streaming responses (SSE, NDJSON, gRPC) by replacing the upfront rejection with a buffered capture approach. Previously, --copy would fail immediately for streaming content types; now it captures up to 1 MiB of the response as it streams, warning users only if the limit is exceeded.
Changes:
- Introduced
limitedBufferwriter to capture streaming data up to 1 MiB without blocking or truncating - Removed content-type checks that prevented
--copyfor streaming responses - Added comprehensive unit tests for the
limitedBufferbehavior - Updated documentation to reflect support for streaming responses
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/fetch/clipboard.go | Implements limitedBuffer and integrates it into clipboard copying logic to support streaming responses |
| internal/fetch/clipboard_test.go | Adds unit tests for limitedBuffer covering various overflow and boundary scenarios |
| integration/integration_test.go | Adds integration tests verifying --copy works with SSE and NDJSON responses |
| docs/cli-reference.md | Updates documentation to note streaming support and the 1 MiB limit |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the upfront rejection of --copy for streaming content types with a limitedBuffer writer that captures up to 1 MiB as the stream is consumed. If the response exceeds the limit, a warning is printed and the copy is skipped instead of silently truncating data.