Skip to content

fix(address-search): keep autocomplete cache through re-selection#43

Merged
divazbozz merged 1 commit intomainfrom
claude/zen-kilby-964540
Apr 20, 2026
Merged

fix(address-search): keep autocomplete cache through re-selection#43
divazbozz merged 1 commit intomainfrom
claude/zen-kilby-964540

Conversation

@divazbozz
Copy link
Copy Markdown
Contributor

@divazbozz divazbozz commented Apr 19, 2026

Summary

this is a refactor to clean up a old buggy behavior

  • resolveSelection used to clear cache, placesRef, and token at the end of every resolve, so re-selecting the same suggestion returned undefined.
  • Callers (BatteryAddressSearchFlow, EnergyOnlyAddressEntryFlow) worked around this with a lastConfirmDataRef fallback that leaked the hook's caching internals into every caller.
  • Drop the eager reset so the cache lives for the hook's lifetime, and remove the lastConfirmDataRef workaround from both flows.

Test plan

see my test step below

  • Open http://localhost:5173/ (top dark "Street address" input).
  • Type 2500 Longview St, pick "2500 Longview St, Conroe, TX, USA" from the dropdown.
  • The "Confirm your address" modal should appear.
  • Click Close.
  • Click in the input → dropdown reopens with the same suggestion.
  • Click the same suggestion again.
  • Expected with the fix: the "Confirm your address" modal reopens (because resolveSelection still returns the place, the flow hits onRequiresAddressConfirm).
  • Old buggy behavior: nothing would happen on the second click (resolveSelection returned undefined → old code fell through to lastConfirmDataRef fallback; without that fallback the flow would silently do nothing).
Screen.Recording.2026-04-20.at.4.37.45.PM.mov

🤖 Generated with Claude Code


Open in Devin Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include rabbit in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 49450b8c-0659-4811-94cf-02268a74b850

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/zen-kilby-964540

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 and usage tips.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines 111 to 113
return {
selection,
googleAddressComponents,
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot Apr 19, 2026

Choose a reason for hiding this comment

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

🟡 Google Places session token never reset after selection completes a session

The PR removes token.current = null from resolveSelection, which previously reset the session token after fetchFields() completed a Google Places autocomplete session. Google's Places API uses the session token to group autocomplete requests and the final place-details fetch into a single billing session. Once fetchFields() is called, that session is consumed. In the new code, the same consumed token is reused for all subsequent fetchAutocompleteSuggestions calls (useAddressAutocomplete.ts:62), meaning every autocomplete request after the first selection may be billed individually rather than at session pricing.

The DESIGN.md (src/address-search/DESIGN.md:98) explicitly states this hook should "manage the Google Places session token lifecycle," and the surviving comment at useAddressAutocomplete.ts:43-44 describes a per-session intent. The fix should restore token.current = null (to start a new session on the next search) while keeping the cache and placesRef intact to preserve the PR's goal of avoiding the lastConfirmDataRef fallback.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

resolveSelection used to clear cache/placesRef/token on every resolve,
which broke re-selecting the same suggestion (second call returned
undefined). AddressSearchFlow worked around this with lastConfirmDataRef.

Drop the eager reset so the hook's internal caching lives for the
hook's lifetime, and remove the lastConfirmDataRef fallback from
AddressSearchFlow — the hook's internals no longer leak into callers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@divazbozz divazbozz merged commit 09aa9b9 into main Apr 20, 2026
2 checks passed
@divazbozz divazbozz deleted the claude/zen-kilby-964540 branch April 20, 2026 21:42
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