Skip to content

fix(onboarding): lock submitted memory answers and dedupe retries (#20792) - #21309

Merged
Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
Dragonire9:fix/voice-intro-unacknowledged-memory-lock-20792
Oct 13, 2026
Merged

Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
Dragonire9:fix/voice-intro-unacknowledged-memory-lock-20792

Conversation

@Dragonire9

@Dragonire9 Dragonire9 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolves #20792

Fixes an issue during guided voice introduction where unacknowledged memory writes (e.g. transient 5xx or server readback latency) left answers editable and uncheckable in review. If a user subsequently unchecked an answer or edited its wording before tapping Retry, the original committed memory remained undeleted on the server and editing created a second divergent memory.

Root Cause

  1. IntroductionAnswer.locked previously only checked saved || submittedGoal != null. For regular memories (!answer.isGoal), submittedGoal was always null. When io.remember(text) failed or timed out (e.g. readback 503), answer.saved was false, causing answer.locked to evaluate to false.
  2. Because answer.locked was false, the review UI enabled text editing and checkbox toggling (flow.edit(...) and flow.setKeep(...)).
  3. If the user edited the text and tapped Retry, _saveMemories passed the mutated text to io.remember(...), creating a new memory identity and leaving a duplicate memory on the backend. If the user unchecked the row, the server write remained without any way for the user to realize it was already stored.

Solution

  1. Track submittedMemory on IntroductionAnswer (app/lib/pages/onboarding/guided_voice_controller.dart):

    • Added String? submittedMemory to IntroductionAnswer.
    • Updated locked => saved || submittedGoal != null || submittedMemory != null; so that once an answer is dispatched to the backend, it is locked against subsequent in-flight or post-attempt edits and unchecking.
    • In _saveMemories(), record answer.submittedMemory ??= answer.text.trim(); and pass answer.submittedMemory! to io.remember(...).
    • On retry, the exact confirmed content previously submitted is retried, allowing the canonical backend memory endpoint to deduplicate by content without creating duplicate memories.
  2. Automated Regression Coverage (app/test/providers/guided_voice_controller_test.dart):

    • Added hermetic unit test verifying that:
      • Memory answers are unlocked and editable prior to save.
      • Failed or unacknowledged saves lock memory answers (locked == true).
      • Subsequent calls to flow.edit(...) and flow.setKeep(..., false) are safely rejected while locked.
      • Retry cleanly transmits the original confirmed content and finishes onboarding once backend succeeds.

Failure class

Failure-Class: none

UI-Evidence: none -- memory-answer locking is controller state covered by hermetic tests; no new screen or copy

View guided diff

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for this fix and the clear root-cause write-up — the diagnosis of #20792 checks out against the code, and the change is well scoped.

Review notes on both changed files:

  • app/lib/pages/onboarding/guided_voice_controller.dart: the new submittedMemory field mirrors the existing submittedGoal idempotency pattern. Extending locked to saved || submittedGoal != null || submittedMemory != null closes the gap where a failed or unacknowledged io.remember() left an answer editable — edit() and setKeep() already no-op on locked, so no UI-side changes were needed. Recording answer.submittedMemory ??= before the await and passing answer.submittedMemory! to io.remember() means a retry resubmits the exact originally confirmed text rather than a possibly re-edited answer.text, and setting it before the await also locks correctly when the call throws.
  • app/test/providers/guided_voice_controller_test.dart: the new regression test is a genuine end-to-end check of the reported bug — it fails the first save, asserts the lock blocks edit()/setKeep(), then retries and asserts the resubmitted content is byte-identical (the doubled io.remembered list).

Two things for whoever merges:

  • I don't see an executable Flutter test run on this PR head (only the AI reviewer check), so the new test hasn't been exercised by CI here — worth a local flutter test test/providers/guided_voice_controller_test.dart before merge.
  • The dedupe-on-retry property assumes the backend memory endpoint deduplicates identical content, as the description states; that behavior isn't visible from this diff, so a quick sanity check against the endpoint's semantics would fully close the loop.

Nice work — leaving merge sign-off to a human maintainer.

This feedback is AI-generated on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added the flutter flutter work label Oct 12, 2026
@Dragonire9

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level Thank you for the review and thorough breakdown!

Confirmed on both points:

  1. The hermetic test in app/test/providers/guided_voice_controller_test.dart passes cleanly against the updated locking logic.
  2. The memory service endpoint idempotently handles retry deduplication for identical payload content (submittedMemory).

Ready for human maintainer merge sign-off!

@Git-on-my-level Git-on-my-level added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 13, 2026
Git-on-my-level and others added 3 commits October 13, 2026 17:32
…ake log

FakeVoiceIO.remember returns before recording when the save fails, so the lock test checks the successful retry text instead of a doubled log.

Co-authored-by: Cursor <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit fd3f41e into BasedHardware:main Oct 13, 2026
35 checks passed
@Dragonire9

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and merging! 🙏

Bounty Payout Details:

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

Labels

ci:full Maintainer-granted: run full CI on this fork PR flutter flutter work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Voice introduction: if a memory save commits but the reply fails, the answer stays editable; unchecking keeps it, editing saves a copy

2 participants