console: fix search in the flow view - #8355
Open
malkafen wants to merge 3 commits into
Open
Conversation
The body was rendered as a single widget, so a match greyed out the whole body, dropped its syntax highlighting, and n/N had nothing to jump to.
malkafen
force-pushed
the
fix/flowview-search
branch
from
August 2, 2026 09:21
4c5fbcc to
cfeb148
Compare
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
Searching inside a flow (
/, thenn/N) is broken in mitmproxy 12: on a match the whole message body turns grey, loses its syntax highlighting, andn/Ndo not move anywhere.FlowDetails._get_content_viewrenders the entire body as a single widget (text_objects = [urwid.Text(chunks)]); before the contentview rework (#7623, #7670) there was one widget per line. SinceSearchableworks on list walker items, this breaks search in three ways:Highlightrebuilds the item asAttrMap(urwid.Text(t.text), "focusfield")— plain text without markup, so syntax highlighting is discarded, andfocusfieldis("black", "light gray"), repainting the whole body grey.find_nextiterates over items, not over occurrences within an item, so with a single body itemn/Nnever advance.last_searchlives on theSearchableinstance, butconn_text()creates a new one on every flow view rebuild, so the search term is silently forgotten.Changes:
flowview.py: addchunks_to_lines()to split highlighting chunks at newlines, so bodies are rendered one widget per line again. Applied to HTTP bodies, TCP/UDP streams and WebSocket messages.searchable.py:Highlightkeeps the original markup and emphasizes only the matched substrings.searchable.py: move the last search term into a sharedSearchStateson/Nsurvive view rebuilds.test/mitmproxy/tools/console/test_flowview_search.pycovers all three symptoms; the tests fail on current main and pass with this change.Checklist