Added opt-in “Format” toggle for HttpMessage Copy/Edit + tests#8039
Open
nadav96 wants to merge 5 commits intomitmproxy:mainfrom
Open
Added opt-in “Format” toggle for HttpMessage Copy/Edit + tests#8039nadav96 wants to merge 5 commits intomitmproxy:mainfrom
nadav96 wants to merge 5 commits intomitmproxy:mainfrom
Conversation
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
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.
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.
Checklist