Skip to content

console: fix search in the flow view - #8355

Open
malkafen wants to merge 3 commits into
mitmproxy:mainfrom
malkafen:fix/flowview-search
Open

console: fix search in the flow view#8355
malkafen wants to merge 3 commits into
mitmproxy:mainfrom
malkafen:fix/flowview-search

Conversation

@malkafen

@malkafen malkafen commented Aug 2, 2026

Copy link
Copy Markdown

Description

Searching inside a flow (/, then n/N) is broken in mitmproxy 12: on a match the whole message body turns grey, loses its syntax highlighting, and n/N do not move anywhere.

FlowDetails._get_content_view renders the entire body as a single widget (text_objects = [urwid.Text(chunks)]); before the contentview rework (#7623, #7670) there was one widget per line. Since Searchable works on list walker items, this breaks search in three ways:

  1. Highlight rebuilds the item as AttrMap(urwid.Text(t.text), "focusfield") — plain text without markup, so syntax highlighting is discarded, and focusfield is ("black", "light gray"), repainting the whole body grey.
  2. find_next iterates over items, not over occurrences within an item, so with a single body item n/N never advance.
  3. last_search lives on the Searchable instance, but conn_text() creates a new one on every flow view rebuild, so the search term is silently forgotten.

Changes:

  • flowview.py: add chunks_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: Highlight keeps the original markup and emphasizes only the matched substrings.
  • searchable.py: move the last search term into a shared SearchState so n/N survive view rebuilds.

test/mitmproxy/tools/console/test_flowview_search.py covers all three symptoms; the tests fail on current main and pass with this change.

Checklist

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

malkafen and others added 3 commits August 2, 2026 15:04
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
malkafen force-pushed the fix/flowview-search branch from 4c5fbcc to cfeb148 Compare August 2, 2026 09:21
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