feat: add network request detail and filtering for request tracking#935
Conversation
- Add `network request <requestId>` command to view full request/response details including response body via CDP Network.getResponseBody - Add --type, --method, --status filter flags to `network requests` - --type: comma-separated resource types (xhr,fetch,document) - --method: filter by HTTP method - --status: supports exact (200), class (2xx), range (400-499) - Extend TrackedRequest with request_id, post_data, status, response_headers, mime_type fields - Update Network.responseReceived handler to also populate tracked_requests (previously only updated HAR entries) - Add tests for parse commands and matches_status_filter - Update README, SKILL.md, docs, and help text Closes vercel-labs#932
|
@ChunHao-dev is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
ctate
left a comment
There was a problem hiding this comment.
Thanks for this, @ChunHao-dev! Filters and network request <requestId> all work correctly end-to-end. Tests and clippy pass clean.
One change needed: network requests output doesn't show request IDs, so there's no way to discover the ID for network request <requestId> without --json. Please add the ID (and status) to the formatted line in cli/src/output.rs ~line 377, e.g.:
[19234.3] POST https://httpbin.org/post (Fetch) 200
|
Done! Added request ID and status to the formatted output in Example: Requests without a response yet omit the status code. |
|
I found some existing behaviors during testing:
These are not from this PR — they already existed before. I thought about adding a tip in the docs to tell users: run network requests before open to capture page load requests. But I want to ask you first — should I add it? And where? Also, I can open a follow-up issue and PR to improve these (e.g. re-send Network.enable on tab switch, add a max size for tracked_requests). Let me know if you'd like that! |
|
@ctate Changes addressed — ready for re-review when you get a chance. |
|
Looks great. Thank you @ChunHao-dev |
Summary
Add
network request <requestId>command and filtering flags (--type,--method,--status) fornetwork requests.fixed #932
Changes
network request <requestId>— view full request/response detail including response body via CDPNetwork.getResponseBody--type xhr,fetch— filter by resource type (comma-separated)--method POST— filter by HTTP method--status 2xx— filter by status code (exact200, class2xx, range400-499)TrackedRequestwithrequest_id,post_data,status,response_headers,mime_typeNetwork.responseReceivednow also updatestracked_requests(previously only HAR entries)Test plan
cargo fmt --check✅cargo clippy -- -D warnings✅cargo test— 490 passed, 0 failed ✅network requestcommandmatches_status_filterunit tests (exact, class, range, None)