Skip to content

Show suggestions and the field icon in empty WhatsApp fields - #853

Open
senadaruc wants to merge 3 commits into
FuJacob:mainfrom
senadaruc:fix/empty-field-no-value
Open

senadaruc wants to merge 3 commits into
FuJacob:mainfrom
senadaruc:fix/empty-field-no-value

Conversation

@senadaruc

@senadaruc senadaruc commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Read an empty field as empty when its host has no value

WhatsApp's Catalyst composer answers AXStringForRange and AXValue with
kAXErrorNoValue while the field is empty, so the zero-length read before
the caret failed the text window, the selection came back missing, and the
field resolved as unsupported: no ghost and no field icon until the first
keystroke. A zero-length range is the empty string, so it is no longer
asked of the host. The window assembly moves into a pure helper with tests.

Show the field icon beside a zero-width caret

An empty field's caret comes from a zero-length AXBoundsForRange, which
hosts answer with a zero-width box (WhatsApp: w:0 h:16.5). The indicator
rejected it with CGRect.isEmpty, true for any zero-width rect, so the icon
stayed hidden in empty fields. It now checks height, as the overlay does.

Place the field icon beside the field's own frame

inputFrameRect is widened to the parent container and a 500pt minimum for
card placement; in WhatsApp that is the whole chat bar, so the icon sat
left of the attachment button. Use the unwidened element frame, as the
translation card already does.

Test plan

  • Rebased onto current main; builds.
  • Full unit suite: 2766 tests. The one failure, AXTextGeometryResolverTests.test_resolveCaretRect_returnsRealGeometry_forNativeTextField, is flaky on this machine: it also fails on branches that do not touch geometry and passes on others.

Summary by CodeRabbit

  • Bug Fixes
    • Activation indicators now align with the focused element when its frame is available, while retaining a fallback to the input field.
    • Zero-width caret positions with a valid height are now recognized, improving indicator placement in text fields.
    • Text around the caret is read in bounded sections. Empty documents are handled without unnecessary reads, and incomplete required reads fall back to the full field value.

RetriggerConfidence Score: 5/5

The PR appears safe to merge based on the reviewed changes.

Summary

The PR lets an empty native text field produce a text window without requesting zero-length AX strings, accepts zero-width caret bounds for the field icon, and anchors that icon to the field’s own frame.

  • Adds focused tests for empty-window assembly and caret usability.
  • No actionable issue was established.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[AX selection and document length] --> B[Windowed text selection]
  B --> C[Focus snapshot and caret geometry]
  C --> D[Indicator]
  D --> E[Field-frame horizontal anchor]
  D --> F[Caret vertical anchor]
Loading

Reviews (1) · Last reviewed commit: "Place the field icon beside the field's ..."

senadaruc and others added 3 commits October 5, 2026 00:15
WhatsApp's Catalyst composer answers AXStringForRange and AXValue with
kAXErrorNoValue while the field is empty, so the zero-length read before
the caret failed the text window, the selection came back missing, and the
field resolved as unsupported: no ghost and no field icon until the first
keystroke. A zero-length range is the empty string, so it is no longer
asked of the host. The window assembly moves into a pure helper with tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018npLpTfiXEGCLF2mg73tFu
An empty field's caret comes from a zero-length AXBoundsForRange, which
hosts answer with a zero-width box (WhatsApp: w:0 h:16.5). The indicator
rejected it with CGRect.isEmpty, true for any zero-width rect, so the icon
stayed hidden in empty fields. It now checks height, as the overlay does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018npLpTfiXEGCLF2mg73tFu
inputFrameRect is widened to the parent container and a 500pt minimum for
card placement; in WhatsApp that is the whole chat bar, so the icon sat
left of the attachment button. Use the unwidened element frame, as the
translation card already does.

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

coderabbitai Bot commented Oct 4, 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: be099e82-5e7b-4ba7-84cb-aa90176b5bdf
📥 Commits

Reviewing files that changed from the base of the PR and between c3d17c1 and 8ce0a70.

📒 Files selected for processing (6)
  • Cotabby.xcodeproj/project.pbxproj
  • Cotabby/App/Core/AppDelegate.swift
  • Cotabby/Services/Focus/Resolution/FocusSnapshotResolver.swift
  • Cotabby/Services/Presentation/ActivationIndicatorController.swift
  • CotabbyTests/Services/Focus/Resolution/NativeTextWindowTests.swift
  • CotabbyTests/Services/Presentation/ActivationIndicatorCaretTests.swift

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

📝 Walkthrough

The changes update native text-window construction and activation indicator frame and caret handling. New tests cover text-range reads and caret rectangle validation.

Changes: Native Text Window

Layer / File(s) Summary
Build and test native text windows
Cotabby/Services/Focus/Resolution/FocusSnapshotResolver.swift, CotabbyTests/Services/Focus/Resolution/NativeTextWindowTests.swift, Cotabby.xcodeproj/project.pbxproj
Native text-window reads now skip host calls for zero-length ranges. Failed preceding or selected-text reads cause window construction to fail, while failed trailing-context reads preserve the available window. Tests cover these cases and the project includes the test file.

Activation Indicator

Layer / File(s) Summary
Select the indicator frame and validate carets
Cotabby/App/Core/AppDelegate.swift, Cotabby/Services/Presentation/ActivationIndicatorController.swift, CotabbyTests/Services/Presentation/ActivationIndicatorCaretTests.swift, Cotabby.xcodeproj/project.pbxproj
The app delegate passes the focused element frame when available. The controller accepts zero-width carets when their height and coordinates are valid, and uses the field rectangle when the caret is unusable. Tests cover accepted and rejected caret rectangles.

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: fujacob

Merge Risk: ⚪ Minimal · up to 8ce0a

No concrete issue remains that should block merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 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 summarizes the main change: showing suggestions and the field icon in empty WhatsApp fields.
Full details: Docstring Coverage

Explanation

Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 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
  • Autopilot · 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.

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.

1 participant