Skip to content

fix(hints): keep macOS hint-search callbacks in order - #1869

Merged
y3owk1n merged 2 commits into
mainfrom
fix/darwin-hint-search-callback-order
Oct 25, 2026
Merged

y3owk1n merged 2 commits into
mainfrom
fix/darwin-hint-search-callback-order

Conversation

@y3owk1n

@y3owk1n y3owk1n commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Description

This PR keeps macOS hint-search callbacks in the order they were typed. Each keystroke, Return and Escape in the hint-search field started its own goroutine to reach the mode handler, and nothing ordered those goroutines, so pressing Return right after an edit could confirm the query from before the edit, and Escape could likewise overtake it. The macOS field now hands its callbacks to the same ordered queue the Windows field uses, so they run in the order they arrived.

The callbacks still never run on the main thread, which the mode handler's locking contract requires.

Related Issues

None.

Target Platform

  • Platform-agnostic (shared logic, no OS-specific code)
  • macOS
  • Linux
  • Windows

Type of Change

  • feat: New feature
  • fix: Bug fix
  • refactor: Code restructuring (no behavior change)
  • perf: Performance improvement
  • docs: Documentation only
  • test: Adding or updating tests
  • chore: Build, CI, dependencies, tooling

Cross-Platform Checklist

  • OS-specific files use correct build tags (e.g., //go:build darwin). No build tag changed
  • No darwin imports from untagged (shared) code, per The One Rule
  • Stub implementations added for other platforms (returning CodeNotSupported). N/A: no new functionality
  • N/A: This PR does not touch platform-specific code

General Checklist

  • Code formatted (just fmt)
  • just ci passes. It runs the same checks as CI, on your host only
    (format check, lint, vet, build, a CGO-off type-check of the Linux and
    Windows builds, tests including a unit -race pass, vulnerability scan),
    and CI runs them on macOS, Linux and Windows
  • Tests added/updated for new or changed functionality
  • Documentation updated (if applicable)
  • PR title is a conventional commit
    subject written for users. This PR squash-merges, so the title is what
    Release Please ships in the changelog, not the commits on the branch

Additional Context

  • The new test fires two queries and a confirm through the bridge and requires the confirm to run last. It failed 33 of 50 runs under -race before the fix and passes 50 of 50 after.
  • Starting a session now stops any queue left from the previous one, and a field that fails to open stops its own queue, matching Windows.
  • The locking contract in the mode handler guide and a line reference in ADR 0009 are updated to match. The deadlock review of the change found nothing.

Each exported bridge of the macOS hint-search field started its own
goroutine for the Go callback, so nothing ordered them. A Return typed
right after an edit could reach the handler before that edit, and the
search confirmed the previous query.

The bridges now post to the same callback queue the Windows field uses.
The queue runs the callbacks in order on one goroutine, so the main
thread still never reaches the handler lock. Start replaces and stops any
previous queue, Stop drops the queue before closing the field, and a
field that fails to open stops its queue, since the handler never stops
a session that did not start.
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; both previous findings are addressed.

Summary

macOS hint-search callbacks now share an ordered queue instead of starting separate goroutines.

  • Hint searches apply text edits before Return or Escape.

The changes since the previous review only revise the regression test. No new actionable issues were found.

Diagram

sequenceDiagram
  participant Field as macOS text field
  participant Bridge as Go bridges
  participant Queue as Callback queue
  participant Handler as Mode handler
  Field->>Bridge: Query change
  Bridge->>Queue: Post query
  Field->>Bridge: Return or Escape
  Bridge->>Queue: Post control action
  Queue->>Handler: Run query callback on queue goroutine
  Queue->>Handler: Run control callback afterward
Loading

Reviews (2) · Last reviewed commit: "test(hints): pin hint-search callback or..." · Reviewed by Greptile

Comment thread internal/adapter/textinput/textinput_darwin_test.go Outdated
Comment thread internal/adapter/textinput/textinput_darwin_test.go Outdated
The bridge test stopped as soon as one query and the confirm had run, so
under the old per-callback goroutines it could pass with the second query
running after the confirm. It also covered only the Return bridge.

The test is now a table over the Return and Escape bridges. The first
query blocks until the second query and the control are posted, so the
second query is queued on its own, and the test waits for all three
callbacks and asserts the exact order.
@y3owk1n
y3owk1n merged commit 7e48720 into main Oct 25, 2026
27 checks passed
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