Skip to content

Leave search boxes to the app - #866

Open
senadaruc wants to merge 1 commit into
FuJacob:mainfrom
senadaruc:fix/search-field-block
Open

senadaruc wants to merge 1 commit into
FuJacob:mainfrom
senadaruc:fix/search-field-block

Conversation

@senadaruc

@senadaruc senadaruc commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Leave search boxes to the app

A search box takes a query of a word or two, not prose to continue. In
Microsoft Teams' search box (an AXComboBox, placeholder "Search (⌘ E)" /
"Look for people, messages, files, and more.", DOM id ms-searchux-input)
the model turned "san" into "dbox: https://sandbox.openai.com/", a URL in no
part of its context, while the prompt framed the query as a chat message with
the open conversation's history.

SearchFieldDetector recognizes single-line search fields by the
AXSearchField role or subrole, a search label (title, description,
placeholder; whole words), or a DOM id with a word starting "search". It
reuses the cached label reading the credential check already makes, now named
fieldLabelReading, so the check adds no extra Accessibility reads. A
browser's address bar is browser chrome (no DOM attributes) and stays
supported.

Validation

  • Based on current main (8cdbea2); builds against main's own inference workspace.
  • Full unit suite: 2793 tests, 14 skipped. AXTextGeometryResolverTests.test_resolveCaretRect_returnsRealGeometry_forNativeTextField fails, as it does on main on this machine. ScreenTextExtractorTests.test_extractText_blankNormalImageReturnsNoRecognizedText failed once with a Vision CRImageReaderError and passed on rerun; this change does not touch OCR.
  • SearchFieldDetectorTests and FocusSnapshotResolverLiveTests cover the Teams placeholder, search roles/subroles, DOM ids, ordinary fields such as "Research notes", multi-line fields, and the browser address bar.
  • Not yet checked by hand in Microsoft Teams on this branch.

Risk / rollout notes

Fields that look like search boxes no longer get suggestions. The match is on
whole words in the label, so "Research notes" is not treated as a search field.

Summary by CodeRabbit

  • New Features

    • Search fields are now recognized using their field type, labels, or identifiers, including common search and filter terms.
    • Browser controls such as address bars are excluded from search-field detection.
  • Bug Fixes

    • Ordinary text fields are not classified as search fields solely because of their field type, helping keep their existing behavior unchanged.

RetriggerConfidence Score: 4/5

Correct the Firefox search-field exception before merging.

Fix All in CodexFindings

  1. P1 Firefox search boxes remain eligible ▶

Summary

This PR leaves single-line search boxes to the host app.

  • Cotabby leaves app search boxes to handle their own queries.

Keeping browser address bars supported is explicitly intended by senadaruc.

Reviews (1) · Last reviewed commit: "Leave search boxes to the app" · Reviewed by Greptile

A search box takes a query of a word or two, not prose to continue. In
Microsoft Teams' search box (an AXComboBox, placeholder "Search (⌘ E)" /
"Look for people, messages, files, and more.", DOM id ms-searchux-input)
the model turned "san" into "dbox: https://sandbox.openai.com/", a URL in
no part of its context, while the prompt framed the query as a chat
message with the open conversation's history.

SearchFieldDetector recognizes single-line search fields by the
AXSearchField role or subrole, a search label (title, description,
placeholder; whole words), or a DOM id with a word starting "search". It
reuses the cached label reading the credential check already makes, now
named fieldLabelReading. A browser's address bar is browser chrome (no
DOM attributes) and stays supported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XWP9XF2imh1ayEA62r6khb
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be589752-cad9-4a52-8c6d-b5b97cf0b83d
📥 Commits

Reviewing files that changed from the base of the PR and between 8cdbea2 and 90fd178.

📒 Files selected for processing (6)
  • Cotabby.xcodeproj/project.pbxproj
  • Cotabby/Services/Focus/Resolution/FocusSnapshotResolver.swift
  • Cotabby/Support/Accessibility/CredentialFieldDetector.swift
  • Cotabby/Support/Accessibility/SearchFieldDetector.swift
  • CotabbyTests/Services/Focus/Resolution/FocusSnapshotResolverLiveTests.swift
  • CotabbyTests/Support/Accessibility/SearchFieldDetectorTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The focus resolver now identifies search fields from roles, labels, and web DOM identifiers. It shares cached field-label readings with credential detection and blocks fields classified as search fields. New tests cover detection rules and resolver behavior.

Changes: Search field detection

Layer / File(s) Summary
Search-field classification rules
Cotabby/Support/Accessibility/SearchFieldDetector.swift, Cotabby/Support/Accessibility/CredentialFieldDetector.swift, Cotabby.xcodeproj/project.pbxproj
SearchFieldDetector classifies eligible fields by role or subrole, whole-word label keywords, and DOM identifiers. CredentialFieldDetector.containsWord is available for shared label matching. The project registers the detector in the application targets.
Focus resolver integration
Cotabby/Services/Focus/Resolution/FocusSnapshotResolver.swift
The resolver shares a one-second field-label cache between credential and search detection. Matching search fields receive SearchFieldDetector.blockedReason. Browser chrome without DOM attributes is treated as browser chrome for search detection.
Detection and resolver tests
CotabbyTests/Support/Accessibility/SearchFieldDetectorTests.swift, CotabbyTests/Services/Focus/Resolution/FocusSnapshotResolverLiveTests.swift, Cotabby.xcodeproj/project.pbxproj
Tests cover search roles, labels, identifiers, browser-chrome exclusions, and live resolver blocking. The project registers the detector tests.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant FocusSnapshotResolver
  participant AccessibilityElement
  participant SearchFieldDetector
  FocusSnapshotResolver->>AccessibilityElement: Read field labels and web DOM identifier
  AccessibilityElement-->>FocusSnapshotResolver: Return field-label reading
  FocusSnapshotResolver->>SearchFieldDetector: Classify role, subrole, labels, identifier, and browser-chrome status
  SearchFieldDetector-->>FocusSnapshotResolver: Return search-field match
Loading

Suggested reviewers: fujacob

Merge Risk: ⚪ Minimal · up to 90fd1

No concrete issue is identified that should block merging. Testing the Microsoft Teams search field remains a useful validation step.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing the application from generating suggestions for detected search fields.
Full details: Docstring Coverage

Explanation

Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 5 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment on lines +423 to +425
let isBrowserChrome = BrowserAppDetector.isBrowser(bundleIdentifier: bundleIdentifier)
&& !candidate.vendsDOMAttributes
if SearchFieldDetector.mightBeSearchField(role: candidate.role, isBrowserChrome: isBrowserChrome) {

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.

P1 Firefox search boxes remain eligible

Firefox page fields lack the DOM attributes checked here, so isBrowserChrome becomes true even for page search boxes. The detector then exits before checking an explicit AXSearchField role or subrole. Cotabby can still offer prose completions in those boxes, and accepting one changes the query.

Distinguish page fields from the address bar before applying this exception, and add a Firefox-shaped test.

Fix in Codex Fix in Claude Code

@7hdmm9pp2w-code 7hdmm9pp2w-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The approach looks good and reuses the sign-in field label cache nicely. Two concerns:

  1. Address bars of browsers not on BrowserAppDetector's list (Vivaldi, Opera, Dia — company.thebrowser.dia doesn't match the Arc prefix — Comet, Atlas) aren't exempt as browser chrome. Chromium labels the omnibox "Address and search bar", so it would match "search". Could you verify one of them?
  2. The doc says a Firefox page's search box is recognized by role only. But mightBeSearchField returns false for all browser chrome, and every Firefox field counts as chrome (no DOM attributes), so nothing is recognized in Firefox.
    Small one: "find" matches labels like "How did you find us?". Limiting the weaker keywords to placeholder or description text would be safer.

Context: I built main with #885, #882, #879, #883, #866 and #867 merged on top (no conflicts) and ran the full test suite the way tests.yml does. All tests touched by these PRs pass. The only two failures also fail on plain main (locale-dependent, see #891). These reviews are based on reading the code; I have not tested the UI by hand.

This branch has not been deployed

No deployments
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.

2 participants