fix(#1079): retry plan generation on transient failures, fix empty-plan UX#1080
Open
lokhor wants to merge 4 commits into
Open
fix(#1079): retry plan generation on transient failures, fix empty-plan UX#1080lokhor wants to merge 4 commits into
lokhor wants to merge 4 commits into
Conversation
…roller When Android TTS drops an onDone/onError callback (audio routing interference, engine glitch), completePlaybackIfDrained waits forever with non-empty utteranceIds and never emits SpeakingStopped, leaving the UI stuck on 'Speaking response...'. Add a 30-second safety-net timeout that fires after the final chunk is queued. If TTS callbacks haven't drained all utterances by then, the timeout force-cleans the playback state and emits SpeakingStopped. Cancels automatically on natural completion or explicit stop().
…an UX messages - Add MAX_PLAN_GENERATION_ATTEMPTS=2 retry loop in generatePlanForReview() - Retry on PLAN_NO_OUTPUT and PLAN_JSON_INVALID; no retry on variety repair - markGenerationFailure() only after all attempts exhausted - planGenerationFailedMessage() helper with stale-draft detection - All empty-plan UX surfaces now show actionable recovery copy - Structured logging with sessionId per attempt - 8 new tests + 1 updated test covering retry, recovery, and stale-draft scenarios
Debug APK readyCommit: Updated on each push. Removed when PR is merged or closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1079
Problem: After collecting all 5 required slots, users saw "I still need to rebuild your meal plan draft" instead of the generated plan. State collapse:
markGenerationFailure()moved session to PLAN_REVIEW with empty days, clearingpendingGenerationKind, so follow-up turns showed confusing recovery copy.Changes:
Retry loop in
generatePlanForReview()— 2 total attempts on blank output or JSON parse failure. No retry onPLAN_VARIETY_REPAIR_FAILED(already has internal retries).markGenerationFailure()only called after all attempts exhausted. Cancellation check before each attempt and beforesavePlanDraft().Empty-plan UX recovery — All surfaces (
planReviewPrompt(),helpPrompt(),planReviewSuggestions(), activity subtitle,currentPlanReply()) now show actionable recovery copy instead of the confusing "rebuild" message. "Show current plan" removed from suggestions when days are empty.Stale-draft preservation —
planGenerationFailedMessage()checkssnapshot.days.isNotEmpty(): when old days exist from a preference-edit flow, message says "Your previous draft is still shown — say 'generate recipes' to try again."Structured logging — Each retry attempt logs session ID, attempt number, and error code.
Tests — 8 new tests + 1 updated test covering blank retry success, invalid JSON retry success, terminal exhaustion (both blank and invalid JSON), variety repair no-retry, empty-plan activity/suggestions recovery state, and stale-draft visibility after preference-edit failure.