Skip to content

Clear AI block find highlights when the find bar closes#11458

Open
maxmilian wants to merge 1 commit into
warpdotdev:masterfrom
maxmilian:maxmilian/fix-11212-ai-block-find-highlight
Open

Clear AI block find highlights when the find bar closes#11458
maxmilian wants to merge 1 commit into
warpdotdev:masterfrom
maxmilian:maxmilian/fix-11212-ai-block-find-highlight

Conversation

@maxmilian
Copy link
Copy Markdown
Contributor

@maxmilian maxmilian commented May 21, 2026

Summary

Closing the find bar left stale find highlights on AI blocks until the pane was refocused. close_find_bar now clears find matches so AI block child views repaint immediately. Fixes #11212.

Root cause

TerminalView::close_find_bar (app/src/terminal/view.rs) only set is_find_bar_open to false and called ctx.notify() on the terminal view itself. AI block find highlights are gated on is_find_bar_open() at render time (app/src/ai/blocklist/block/view_impl.rs), but AI blocks are separate child views — nothing notified them to repaint when the find bar closed, so their last-rendered highlights persisted until another repaint (e.g. pane refocus). Terminal grid blocks were unaffected because the terminal view repaints itself on close.

Fix

close_find_bar now also calls find_model.clear_matches(). That clears each registered rich-content child view's cached find state and notifies it to repaint — mirroring how open_find_bar runs find on open. Both the sync (clear_matches) and async (clear_results) find paths already iterate registered rich-content views, so the fix covers both.

Tests

Added close_find_bar_clears_ai_block_find_highlights in app/src/terminal/view_tests.rs: builds an AI block with a searchable query, highlights a match, closes the find bar, and asserts the AI block's find match count drops to 0. The test fails before this change (highlights persist, left: 1, right: 0) and passes after. cargo fmt --check, cargo clippy --tests -D warnings, and the test all pass locally.

The test drives the AI block's run_find directly because the blocklist find pipeline only visits rich-content views once they have been laid out, which does not happen in a headless test; this is noted in a comment in the test.

Visual evidence

Before (stable v0.2026.05.20.09.21.stable_03) — highlights persist after closing find bar until pane refocus:

11212_A.mov

After (this PR) — highlights clear immediately on close:

11212_B.mov

Scope

  • Only close_find_bar is touched; opening find and live find updates are unchanged.
  • The new #[cfg(test)] accessors (FindState::match_count, AIBlock::find_match_count) exist solely so the regression test can observe AI block find state.

CHANGELOG-BUG-FIX: Fixed find highlights lingering on AI blocks after closing the find bar.

@cla-bot cla-bot Bot added the cla-signed label May 21, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 21, 2026
@maxmilian maxmilian force-pushed the maxmilian/fix-11212-ai-block-find-highlight branch from a19cddd to 578c91a Compare May 22, 2026 01:06
@maxmilian maxmilian marked this pull request as ready for review May 23, 2026 15:01
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 23, 2026

@maxmilian

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 23, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR clears cached find matches when closing the find bar so AI block highlights repaint immediately, and adds a regression test plus test-only accessors. The approach matches the intended behavior for the synchronous find path and includes visual evidence.

Concerns

  • Closing the find bar now clears the async find controller through clear_results, which also drops the saved active FindOptions. With AsyncFind enabled, reopening find no longer restores/reruns the previous query/options, unlike the sync path.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/terminal/view.rs Outdated
// grid highlights are gated at paint time on `is_find_bar_open()`,
// but AI blocks are separate child views that won't repaint on
// their own when the find bar closes.
find_model.clear_matches(ctx);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] clear_matches drops the active async find options via AsyncFindController::clear_results, so with AsyncFind enabled closing and reopening the find bar no longer restores/reruns the previous query. The sync cleared() path preserves options; make the async clear path preserve current_find_options/config or clear only rich-content highlights here.

`TerminalView::close_find_bar` only set `is_find_bar_open` to false and
notified the terminal view itself. AI blocks are separate child views
whose find highlights are gated on `is_find_bar_open()` at render time,
but nothing notified them to repaint when the find bar closed, so stale
highlights persisted until the pane was refocused. Terminal grid blocks
were unaffected because the terminal view repaints itself on close.

Add a new `TerminalFindModel::clear_rich_content_matches` that only
notifies registered rich-content child views to drop their cached find
state and repaint, without touching the active find run's options/config.
`close_find_bar` calls it instead of the broader `clear_matches`, which
on the async-find path routes through `AsyncFindController::clear_results`
and drops `current_find_options` — losing the query that `open_find_bar`
reads back via `active_find_options` to restore the previous search.

Regression coverage:
- `close_find_bar_clears_ai_block_find_highlights` (existing, sync path)
- `close_find_bar_preserves_options_on_async_find_path` (new, async path)

Fixes warpdotdev#11212
@maxmilian maxmilian force-pushed the maxmilian/fix-11212-ai-block-find-highlight branch from 578c91a to b32cf40 Compare May 23, 2026 16:05
@maxmilian
Copy link
Copy Markdown
Contributor Author

Addressed Oz's async-path concern (commit b32cf40f).

The previous revision called find_model.clear_matches() from close_find_bar. On the async-find path that helper routes through AsyncFindController::clear_results, which also resets current_find_options — losing the query that open_find_bar reads back via active_find_options to restore the previous search.

Fix: added TerminalFindModel::clear_rich_content_matches — a minimal helper that only notifies registered rich-content child views to drop their cached find state and repaint, without touching the active find run's options/config. close_find_bar now calls this instead of clear_matches. The sync (block-list) path is unaffected because it already preserved options via run.cleared().

Regression coverage:

  • close_find_bar_clears_ai_block_find_highlights (existing, sync path — still green)
  • close_find_bar_preserves_options_on_async_find_path (new) — enables FeatureFlag::AsyncFind, runs find with query "needle", closes find bar, asserts active_find_options() still returns Some("needle"). Verified the test catches the regression by reverting the fix in place: test fails with left: None, right: Some("needle").

cargo fmt --check, cargo clippy -p warp --lib --tests --no-deps -- -D warnings, and cargo nextest run -p warp 'find::' all green (29/29 find tests + both regression tests). Single squashed commit, force-pushed.

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 23, 2026

@maxmilian

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @seemeroland.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot dismissed their stale review May 23, 2026 16:09

Oz no longer requests changes for this pull request after the latest automated review.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR clears cached AI block find state when the terminal find bar closes, preserving async-find options so reopening find restores the previous query. It also adds focused regression coverage for the AI block highlight clearing behavior and the async-find query preservation path.

Concerns

No blocking correctness, security, or spec-alignment concerns found. Visual evidence is included in the PR description for this user-facing behavior change.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot requested a review from seemeroland May 23, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find highlights on AI blocks persist after closing find bar

1 participant