Skip to content

feat: add copy-all button to export full network request details - #268

Merged
Manabu-GT merged 3 commits into
mainfrom
claude/debugoverlay-android-256-u2mfom
Aug 6, 2026
Merged

Manabu-GT merged 3 commits into
mainfrom
claude/debugoverlay-android-256-u2mfom

Conversation

@Manabu-GT

@Manabu-GT Manabu-GT commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

Add a "Copy All" button to the network request detail screen that exports the complete request/response transaction as formatted plain text, suitable for sharing or debugging.

Changes

  • New utility function NetworkRequest.toClipboardText() that formats the full network transaction (overview, headers, body, or error) as plain text

    • Mirrors the Overview/Headers/Body sections shown on the detail screen
    • Omits empty sections (headers/body when absent)
    • Automatically formats JSON bodies with indentation
    • Leaves non-JSON bodies unformatted
    • Shows error details instead of response headers/body when a request fails
  • UI enhancement to NetworkRequestDetailScreen

    • Added "Copy All" button (CopyAll icon) next to existing copy buttons in the top app bar
    • Reuses existing clipboard copy infrastructure
  • String resource added for the new button's content description (debugoverlay_copy_all)

  • Comprehensive test coverage with 4 test cases covering:

    • Full request/response with all sections
    • Minimal request with no headers/body
    • Non-JSON body handling
    • Error state formatting

Implementation Details

The formatting function builds a structured text output with:

  • Request line (method + URL)
  • Status, duration, timestamp, and sizes
  • Optional request/response headers and bodies
  • Optional error section with title, message, and stack trace
  • JSON pretty-printing when applicable

https://claude.ai/code/session_01A5yvCH5EjpW2JdJZ1ggiTY

Summary by CodeRabbit

  • New Features

    • Added options to copy a network request URL or all request and response details.
    • Copied details include metadata, headers, bodies, errors, and formatted JSON when applicable.
    • Large request and response bodies are safely truncated with size information.
  • Bug Fixes

    • Improved content-type detection regardless of header capitalization.
    • Preserved response details when requests contain errors.

Adds a "Copy All" action to the network request detail screen's
TopAppBar, alongside the existing per-section copy buttons. Copies
method, URL, status, timing, both header sets, and both bodies
(JSON pretty-printed when detected) as a single plain-text block via
NetworkRequest.toClipboardText().

Resolves item 2 of #256.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 57e94e4c-37d4-44e8-a8f2-cce2ab9fd828

📥 Commits

Reviewing files that changed from the base of the PR and between 7d80fc3 and ce8cd99.

📒 Files selected for processing (3)
  • debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/ui/NetworkRequestDetailScreen.kt
  • debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/util/NetworkRequestFormatting.kt
  • debugoverlay-core/src/test/kotlin/com/ms/square/debugoverlay/internal/util/NetworkRequestFormattingTest.kt
🚧 Files skipped from review as they are similar to previous changes (2)
  • debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/util/NetworkRequestFormatting.kt
  • debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/ui/NetworkRequestDetailScreen.kt

📝 Walkthrough

Walkthrough

The network detail screen now copies either the request URL or complete request data. Clipboard output includes formatted metadata, headers, bodies, and errors. Shared content-type detection supports case-insensitive headers across detail and HTML rendering.

Changes

Network request clipboard export

Layer / File(s) Summary
Shared formatting utilities
debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/util/Headers.kt, debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/util/TimeFormatters.kt, debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/bugreport/HtmlReportBuilder.kt, debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/ui/NetworkRequestDetailScreen.kt
Adds case-insensitive contentType() lookup and reuses it for network body rendering. The clipboard timestamp formatter is package-internal.
Clipboard text formatting and tests
debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/util/NetworkRequestFormatting.kt, debugoverlay-core/src/test/kotlin/com/ms/square/debugoverlay/internal/util/NetworkRequestFormattingTest.kt
Formats request and response sections, pretty-prints JSON, preserves errors, omits empty sections, and truncates each body at 64 KiB. Tests cover these cases.
Copy actions in the detail screen
debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/ui/NetworkRequestDetailScreen.kt, debugoverlay-core/src/main/res/values/strings.xml
Adds separate URL and complete-request toolbar actions with distinct icons and localized labels.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a Copy All button to export complete network request details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/debugoverlay-android-256-u2mfom

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.

@claude

claude Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Claude finished @Manabu-GT's task in 3m 52s —— View job


Code Review: Copy-all button for network request details

  • Gather context (diff + related source)
  • Review formatting utility
  • Review UI changes
  • Review tests
  • Post review (6 inline comments)

Clean, well-scoped feature. The toClipboardText() naming follows the existing LogEntry.toClipboardText() precedent (TimeFormatters.kt:32), JSON pretty-printing reuses formatJsonIfPossible, and the contentDescription correctly goes through a string resource per docs/CODING.md. No new secret exposure — the OkHttp interceptor redacts sensitive headers and query params at capture time (DebugOverlayNetworkInterceptor.kt:163, :446), so this exports only what's already on screen.

One correctness bug worth fixing before merge, plus a few smaller items.

Findings

# Severity Issue
1 High Response headers/body dropped for all HTTP 4xx/5xx (inline)
2 Medium Case-sensitive content-type lookup (inline)
3 Medium Main-thread formatting on an unbounded clipboard payload (inline)
4 Low Exported timestamp has no date (inline)
5 Low Two adjacent app-bar buttons announced "Copy" / "Copy all" (inline)
6 Low Test gap: no HTTP-error case; self-referential timestamp assertion (inline)

#1 is the one that matters. NetworkRequestFormatting.kt:23-28 treats error != null as "there is no response" — but the interceptor sets error for every response with code >= 400 (DebugOverlayNetworkInterceptor.kt:153) while still capturing headers and body. So copying a 404 or a 500 — the case you'd most want to share — silently omits the response headers and body. Both other renderings of this data show the error and the response sections (NetworkRequestDetailScreen.kt:185+tabs, HtmlReportBuilder.kt:643-659), so the export also contradicts its own "mirrors the detail screen" doc comment. A suggested diff is in the inline comment.

Two related details: for HTTP errors the interceptor stores the response body in NetworkError.stackTrace (:524), so the body does currently leak into the export — but unlabeled, unformatted, and captioned as a stack trace. And HTTP_CLIENT_ERROR_START is duplicated in both the extension and HttpStatusCodes.kt:22.

Smaller notes

  • appendHeadersSection/appendBodySection each hand-roll a "\n\n--- $title ---\n" prefix while the header block uses appendLine. A single StringBuilder.appendSection(title: String, body: String) would remove the asymmetry and make the "no trailing newline" behavior obvious rather than incidental.
  • The per-section copy buttons (NetworkRequestDetailScreen.kt:350, :371) copy the raw body while Copy All pretty-prints it. Defensible — different intents — but worth a deliberate call.
  • The export omits protocol, which the Overview tab doesn't show either, so it's consistent; still, h2 vs http/1.1 is often useful in a shared transcript.

Validation

I could not run ./gradlew :debugoverlay-core:check or spotlessApply — Gradle invocation was denied by the tool permissions in this environment, so tests, detekt, and spotless are unverified by me. Static read of the new code shows nothing over the 120-char line limit and imports in the configured order. Please rely on CI for the check task.
• claude/debugoverlay-android-256-u2mfom

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 034d9ba3dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Manabu-GT Manabu-GT changed the title Add copy-all button to export full network request details feat: add copy-all button to export full network request details Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Qodana for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

claude and others added 2 commits August 6, 2026 02:51
…s review feedback (#268)

- toClipboardText() no longer drops response headers/body when error
  is set: the OkHttp interceptor populates error for any HTTP status
  >= 400 while still capturing the response, so a 404/500 - the case
  most worth sharing - was silently exporting no response data.
- Content-Type header lookups are now case-insensitive (shared
  Map<String, String>.contentType() helper, also adopted by
  HtmlReportBuilder and the three pre-existing exact-match lookups in
  NetworkRequestDetailScreen), since HTTP/1.1 typically capitalizes
  the header while HTTP/2 lowercases it.
- Cap each body at 64KB when building clipboard text, to bound a
  single ClipData and avoid TransactionTooLargeException on large
  bodies.
- Build the clipboard text off the main thread (new suspend-producer
  overload of copyToClipboard) instead of synchronously in the
  onClick handler.
- Exported timestamp now includes the date (formatClipboardTimestamp,
  shared with LogEntry's clipboard export) instead of a bare
  wall-clock time.
- Renamed the URL-only top-bar button's content description to
  "Copy URL" so it reads distinctly next to "Copy all".
- Extracted the top bar's actions into NetworkRequestDetailActions,
  fixing the detekt LongMethod failure on NetworkRequestDetailScreen
  (62 lines, threshold 60) that broke CI.
- Added test coverage for the HTTP-error-with-response-data case,
  capitalized Content-Type detection, and body truncation.
@Manabu-GT
Manabu-GT merged commit 1474895 into main Aug 6, 2026
1 check passed
Manabu-GT added a commit that referenced this pull request Aug 7, 2026
* docs: update README for v2.6.3

- Bump dependency coordinate examples in README from 2.6.2 to 2.6.3.
- Add CHANGELOG entry for v2.6.3 covering the network request "Copy all"
  export (#268, item 2 of #256) and the Gradle 9.6.1 update (#267).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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