Skip to content

feat(native-network-logs): one compact row per request by default - #1413

Draft
blazejkustra wants to merge 6 commits into
mainfrom
feat/native-network-summary
Draft

blazejkustra wants to merge 6 commits into
mainfrom
feat/native-network-summary

Conversation

@blazejkustra

@blazejkustra blazejkustra commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

native-network-logs returned raw events: several per request, plus many data chunks. While an Expo app loaded, its 32 requests came back as 220 events, 131 KB of text for the agent to piece together.

Approach

The events are now folded into one row per request (method, URL, status, type, size, duration). This is the new default; format: "events" keeps the old raw output.

Tests

  • Same app load, same build, read both ways: 32 requests = 9.9 KB as rows vs 131 KB as 220 raw events. On main the same load returned 121 KB (261 events for 23 requests).
  • Default output changed: callers that read events must now pass format: "events".
  • Unit tests: a 54-event stream folds into 2 rows; a redirect keeps url and adds finalUrl; a failed request keeps bytes and durationMs; the tool returns rows by default, raw events with format: "events", the most recent requests under limit, clears only when asked, and sets truncated: true once the log holds its 1000-event limit. Each fails with its fix reverted.
  • Full tool-server suite, tsc, typecheck:tests, eslint, prettier and knip pass.
  • Docs: tools reference row and the network page's note updated (rows hold no headers or request bodies; neither format holds response bodies); docusaurus build passes.
  • Overlaps fix(native-network-logs): capture the launch after restart_required #1402 in execute and the description: whichever merges second keeps fix(native-network-logs): capture the launch after restart_required #1402's capture order and adds its note to the rows result too. format is optional in the params type, so fix(native-network-logs): capture the launch after restart_required #1402's new tests typecheck unchanged.
  • Not tested: a physical iPhone, or the new fields on a device. A request the app cancelled looks the same as one still running (no final event from the native layer, tracked in argent-private#47); the description says so.

Screenshots

No video: the change is in the text the tool returns. Two of the 32 new rows:

{ "requestId": "67824E57-…", "method": "GET", "url": "http://localhost:8086", "status": 200, "mimeType": "multipart/mixed", "bytes": 6726, "durationMs": 552 }
{ "requestId": "DEC1C1C8-…", "method": "GET", "url": "http://127.0.0.1:8086/index.ts.bundle?platform=ios&…", "status": 200, "mimeType": "multipart/mixed", "bytes": 23619397, "durationMs": 158 }

Before, the same requests arrived as requestWillBeSent (about 900 characters each), responseReceived, a run of dataReceived chunks and loadingFinished.

The tool returned the raw Network.* events, mostly dataReceived chunks, so a
screen of traffic came back as a wall of text that could overflow the tool
output limit while still not listing every request. Default to one row per
request (method, url, status, mimeType, bytes, durationMs, error), with limit
counting requests; format: "events" keeps the raw stream.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@blazejkustra
blazejkustra requested a review from latekvo October 12, 2026 22:10

@latekvo latekvo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Diplomat, Opus 5.5]: Ran this branch's tool-server E2E on an iOS 18.5 simulator. The Bloom dev-client hit a local server with redirect, 500, refused, slow and multi-MB endpoints, and I read both formats after each run. Covered claims vs code against the dylib's emitter (NetworkInspector.m / NativeDevtoolsURLProtocol.m), the JS and Chromium twins, non-happy paths, inputs, the 1000-event buffer, the merge with #1402, and mutations across the new branches. Findings are inline.

Two problems outside this diff that came up along the way are filed separately: #1424 (the network docs say Metro traffic is removed, but on the native layer it is not) and software-mansion/argent-private#47 (the dylib sends no terminal event for a cancelled request).

Comment thread packages/tool-server/src/tools/native-devtools/native-network-logs.ts Outdated
Comment thread packages/tool-server/src/tools/native-devtools/native-network-logs.ts Outdated
Comment thread packages/tool-server/src/tools/native-devtools/native-network-logs.ts Outdated
Comment thread packages/tool-server/src/tools/native-devtools/native-network-logs.ts Outdated
Comment thread packages/tool-server/src/tools/native-devtools/native-network-logs.ts Outdated
Comment thread packages/tool-server/test/native-network-summary.test.ts
…request rows

- finalUrl when the response came from another URL; url stays what the app asked for
- failed requests keep bytes and durationMs
- truncated: true once the log hit its 1000-event limit
- format no longer required in the params type
- describe what each format carries (request bodies, never response bodies)
- execute-level tests for format, limit, totalRequests, clear and truncated

@latekvo latekvo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Diplomat, Opus 5.5]: Re-ran the review at 5369d35. I built the head, then ran the three native-network test files (97/97) and typecheck:tests. I checked the descriptions and docs against the dylib's emitter in argent-private (NetworkInspector.m and NativeDevtoolsURLProtocol.m) and against the view-network-logs twin. I also covered non-happy paths and inputs, reachability, the ring buffer and clear lifetime, and a local merge with main and #1402 (typecheck and tests pass). I ran 18 mutants across the new branches; the 4 survivors not raised below cannot be reached from the dylib's events. The earlier redirect, failure, buffer, stale-comment and typecheck findings are addressed. What remains is inline, plus replies on two earlier threads.

Comment thread packages/tool-server/src/tools/native-devtools/native-network-logs.ts Outdated
Comment thread packages/tool-server/src/tools/native-devtools/native-network-logs.ts Outdated
Comment thread packages/tool-server/src/tools/native-devtools/native-network-logs.ts Outdated
# Conflicts:
#	packages/docs/docs/features/network.mdx
#	packages/tool-server/src/tools/native-devtools/native-network-logs.ts
…quest rows

- finalUrl only for a real redirect: compare parsed URLs, skip rows with no url
- truncated: true only once the log evicted events, not when it is merely full
- limit is a non-negative integer, and limit 0 returns no rows
- say that most request bodies are missing and that clear drops the headers
- tests for clear-after-read, fractional timestamps and limit 0

This branch has not been deployed

No deployments
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.

2 participants