Skip to content

Prompt highlight keeps tinting a row after an agent TUI has repainted it — blue band on the input box / spinner line #230

Closed

Description

@cgri

What happens

With prompt highlighting on, the highlight band sometimes ends up on a row that
is not a prompt. In a Claude Code pane I get the default blue (#6ea8ff) band
on:

  • the agent's input box, and
  • the status/spinner row, e.g. a one-row band over * Germinating… (1m 15s · ↓ 4.1k tokens)

The band travels upward as output pushes the screen along, but it no longer
lines up with the text it started on. Resizing the window repaints and the band
is gone entirely — not moved onto the right row, just gone, and it does not come
back for the prompts that already scrolled by.

Expected: the tint stays on the prompt's rows, or disappears once that row's
content is no longer the prompt. Not: an unrelated row tinted as if it were one.

Workaround

Settings → Prompts → Highlight prompt lines off. The prompt log, the outline,
the jump marks and the scrollbar ticks all keep working; only the row tint goes
away. Turning Track prompts off disables the whole feature.

Steps to reproduce

  1. Settings → Prompts: Track prompts and Highlight prompt lines on (defaults).
  2. Open a terminal pane and run an agent TUI that repaints its lower region —
    Claude Code here.
  3. Send a few prompts and let it produce enough output that each prompt scrolls
    up out of the repainted region.
  4. Watch the bands. Intermittent; a long-running turn with a live spinner is
    where I see it most.
  5. Resize the window → every band disappears.

wmux version

2.10.4

Windows version

Windows 11 23H2 (build 22631)

Anything else

Guessing at the mechanism from src/renderer/utils/prompt-marks.ts, so take
this as a lead rather than a diagnosis:

applyHighlight() anchors the decoration to an IMarker, i.e. to a buffer
line, and height rows down from it. For a shell that is the same thing as
anchoring to content — the prompt row in scrollback is never rewritten. An agent
TUI is different: it redraws its input box and status row over the same lines
over and over, and the submit-time mark sits right in that repainted zone.
refineMark() moves the mark onto the echoed prompt text once, and after that
nothing re-checks whether the row still carries the prompt. So the decoration
goes on tinting a row whose content has been replaced — which is exactly what
a band over the spinner row looks like.

The resize behaviour fits the same picture: reflow disposes the markers, the
decorations go with them, and refreshHighlights() only runs on a preference
change — so a repaint clears the bands for good rather than re-placing them.

Two directions that might help, whichever fits the design better:

  • Re-validate in decoration.onRender: the needle from buildNeedle() is
    already derivable from the stored prompt text, so a row that no longer
    contains it could drop its highlight (or re-run refineMark).
  • For agent-sourced prompts, hold the highlight back until the row has left the
    region the TUI still rewrites (roughly: more than terminal.rows above the
    cursor), and keep only the rail/ruler mark until then.

Also worth considering re-applying highlights after a resize, not only after a
preference change.

Activity

  1. amirlehmam commented on Sep 12, 2026

    @amirlehmam
    Owner

    Fixed in 2.10.5 — thanks, your lead was right about the mechanism and it saved me the diagnosis.

    What it was

    Your reading of applyHighlight() is exactly it. A marker binds a decoration to a buffer line, and for a shell "line" and "content" are the same sentence — a command row in scrollback is never rewritten again. An agent TUI breaks that equivalence, and the submit-time cursor (the only line wmux has when the UserPromptSubmit hook arrives) sits right in the region it repaints.

    refineMark() is what was supposed to get out of that, and it usually does. But it can miss — a prompt shorter than MIN_NEEDLE (6 chars, so yes / go on are uncheckable by construction), or one the TUI reflowed or styled beyond recognition. On a miss the mark just stays on the submit-time cursor, and nothing re-checked it after that. That is your band over ✳ Germinating….

    I reproduced it against a real xterm 6 + WebGL driving the actual module, rather than only in a fake. Pre-fix, the cell background on the spinner row reads back as #28384e — which is #6ea8ff at the tint's 26% over the terminal background, i.e. literally the default blue you screenshotted:

    PASS  refineMark finds the echoed prompt row  (got 1, want 1)
    PASS  band on the prompt row                  (got true, want true)
    FAIL  no band on the spinner row              (got #28384e, want null)
    FAIL  band released after the repaint         (got #28384e, want null)
    

    The fix

    I took your first direction. The tint is now a claim about content and is treated as one, twice:

    A failed check drops the tint and the rail but keeps the overview-ruler tick — a tick claims "the prompt is around here", which is still true, so the fix doesn't quietly degrade into the workaround you found.

    Your second direction is in there too, as the fallback for the case content can't decide: an uncheckable prompt falls back to what its source can promise. A shell's row was named by OSC 133 and keeps its band; an agent's row is a guess, so no band. That is what covers yes.

    Two details, in case you read the diff:

    • the match is stored as an offset from the marker, not a boolean, so the per-render re-check is one row instead of up to MAX_HIGHLIGHT_ROWS;
    • termination is structural rather than a retry count — the degraded re-apply registers no onRender, so it physically cannot re-arm itself.

    Needle matching also collapses whitespace on both sides now. It already did on the needle, so git status typed was being compared as git status against a row that still read git status — a prompt sitting verbatim on screen could miss.

    On the resize half

    Here I have to correct your guess, because the answer is more interesting than "reflow disposes the markers". It doesn't. I checked in the same harness: narrowing 80→40 moved marker.line 20→40 and it still pointed at the same text, through a narrow and a widen, on both renderers. xterm 6 reflows markers with their content.

    What actually goes stale is the decoration: its width is terminal.cols as it was at registration time, so widening a pane leaves every band stopping short of the new right edge. And a resize is the moment a full-screen TUI redraws everything it owns, which is when a band's row is most likely to stop carrying its prompt.

    So refreshHighlights now runs on resize as well as on a preference change, trailing-debounced (a window drag emits a resize per frame, and up to 200 decorations per surface rebuilt on each of them is its own bug). That rebuild also re-establishes the offset above, which reflow can move.

    I couldn't reproduce "every band disappears and doesn't come back" in isolation, so I'd rather not claim I've explained that exact observation. What I'd expect now is that the bands you were seeing on TUI-owned rows are gone because they're never painted there, and the ones on real prompt rows come back correctly sized after a resize. If you still see a full clear-out on 2.10.5, please reopen with roughly what the pane was doing — that would be a second mechanism and I'd want it.


    2.10.5 is up: https://github.com/amirlehmam/wmux/releases/tag/v2.10.5 (portable zip needs a right-click → Unblock after download). You can turn Highlight prompt lines back on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions