Skip to content

debounced swap interface search with request cancellation #728

Description

@mikewheeleer

Summary

The swap interface search fires a request per keystroke and can render a stale response over a newer one. Add debouncing and cancel/ignore superseded requests.

Why this matters

Per-keystroke, race-prone search wastes work and shows wrong results. Debounce + cancellation is the standard, testable fix.

Requirements

  • Debounce swap interface search input before querying.
  • Cancel or ignore responses from superseded requests (guard against stale results).
  • Show loading, empty-result, and error states distinctly.
  • Keyboard and screen-reader accessible.

Technical guidance

  • Track the latest request token and drop out-of-order responses.
  • Trim/normalize the query before sending.

Edge cases — each must have a test

  • typing quickly -> one query after the pause
  • fast then slow response -> newest result wins
  • no matches -> empty state
  • cleared input -> resets results
  • error -> error state with retry

Acceptance criteria

  • All requirements and every edge case above implemented and covered by tests
  • New unit and integration tests; existing tests still pass and no regressions
  • Structured, typed errors (no leaked internals; stable codes)
  • npm run lint, npm test, and npm run build all pass locally
  • Code follows the repo's existing conventions; no duplication or dead code
  • Short docs/comments explaining the design and any non-obvious decisions
  • PR description explains the approach and includes Closes #<issue>

Out of scope

  • Search history/suggestions
  • Server-side ranking

Rewards

Part of the GrantFox OSS / Official Campaign (FWC26) — this task may be rewarded. PR quality is assessed by AI: depth, correctness under edge cases, meaningful tests, and clean design are what earn the reward. Shallow changes (typos, formatting, trivial docs) do not qualify.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions