Skip to content

Added opt-in “Format” toggle for HttpMessage Copy/Edit + tests#8039

Open
nadav96 wants to merge 5 commits intomitmproxy:mainfrom
nadav96:copy-attempt
Open

Added opt-in “Format” toggle for HttpMessage Copy/Edit + tests#8039
nadav96 wants to merge 5 commits intomitmproxy:mainfrom
nadav96:copy-attempt

Conversation

@nadav96
Copy link
Copy Markdown

@nadav96 nadav96 commented Jan 5, 2026

Description

This PR adds an opt-in Format/Formatted toggle to the HttpMessage content view controls in mitmweb.

When Format is OFF (default), Copy and Edit use the raw content.data payload (e.g. minified JSON).
When Format is ON, Copy and Edit use the selected content view’s prettified output (Auto/JSON/GraphQL/etc.) fetched from content/.json.
The displayed payload in view mode remains unchanged; the toggle only affects Copy/Edit behavior.
Editor now applies syntax highlighting based on the content view when formatting is enabled, and GraphQL edits are re-encoded on save where applicable.
Includes updated snapshots and added Jest tests to cover the toggle + copy/edit fetch behavior.

image image image

Checklist

  • [v] I have updated tests where applicable.
  • [v] I have added an entry to the CHANGELOG.

Nadav Goldstein added 4 commits January 4, 2026 19:47
…shots

- Add a Format/Formatted toggle so Copy/Edit can use the selected content view’s
  prettified output while keeping the displayed payload unchanged.
- Edit mode now loads either raw content.data (default) or prettified content
  view output (when enabled), including syntax highlighting.
- Update HttpMessage Jest mocks and snapshots for the new button and fetch paths.
- Add setClipboardMocks() helper to mock navigator.clipboard in tests
- Test Format button toggles between "Format" and "Formatted" labels
- Verify Copy uses raw content.data when Format is off
- Verify Copy uses prettified content view JSON when Format is on
- Verify Edit fetches prettified content view when Format is on
- Check correct fetch URLs are called for raw vs formatted content paths
@nadav96 nadav96 changed the title Copy attempt Added opt-in “Format” toggle for HttpMessage Copy/Edit + tests Jan 5, 2026
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.

1 participant