fix(address-search): keep autocomplete cache through re-selection#43
fix(address-search): keep autocomplete cache through re-selection#43
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| return { | ||
| selection, | ||
| googleAddressComponents, |
There was a problem hiding this comment.
🟡 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.
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>
2ae47a6 to
5e99bf9
Compare
Summary
this is a refactor to clean up a old buggy behavior
resolveSelectionused to clearcache,placesRef, andtokenat the end of every resolve, so re-selecting the same suggestion returnedundefined.BatteryAddressSearchFlow,EnergyOnlyAddressEntryFlow) worked around this with alastConfirmDataReffallback that leaked the hook's caching internals into every caller.lastConfirmDataRefworkaround from both flows.Test plan
Screen.Recording.2026-04-20.at.4.37.45.PM.mov
🤖 Generated with Claude Code