feat(google-docs): handle OAuth expiry mid-workflow with reauth modal []#10934
Draft
Mitch Goudy (mgoudy91) wants to merge 1 commit intomasterfrom
Draft
feat(google-docs): handle OAuth expiry mid-workflow with reauth modal []#10934Mitch Goudy (mgoudy91) wants to merge 1 commit intomasterfrom
Mitch Goudy (mgoudy91) wants to merge 1 commit intomasterfrom
Conversation
…h modal When the agents-api workflow suspends with `needs-google-reauth`, show a reconnect modal that preserves workflow progress. On successful reconnect the fresh token is passed directly to resumeWorkflowRun so the workflow continues from where it left off rather than requiring a full restart. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
NeedsReauthSuspendPayloadtype (suspendStepId: 'needs-google-reauth') to the workflow type unionModalOrchestratornow shows a reconnect modal instead of an error modal — preserving all workflow progressresumeWorkflowRunso the workflow continues from where it left off rather than requiring a full restartoauthTokentoResumePayloadtypeModalOrchestratorpropsProblem
OAuth tokens expire after ~1 hour. The previous UX was: workflow fails → generic error modal → user must reconnect → user must restart the entire workflow from scratch. All progress (document selection, content type selection, tab/image selection) was lost.
Solution
The agents-api step now suspends with
needs-google-reauthinstead of failing (see pairing PR). On the frontend:ModalOrchestrator.handleWorkflowResultdetectssuspendStepId === 'needs-google-reauth'and callsshowReauthPrompt, which sets a newFlowStep.REAUTHstate and saves therunIdinpendingReauthRunIdREAUTHflow step renders the existingOAuthConnectorinside the modal with an explanatory messagehandleReauthTokenChangeis wired as theonOauthTokenChangecallback — when the reconnect completes it immediately callsresumeWorkflow(pendingReauthRunId, { oauthToken: newToken })and resumes pollingshowWorkflowErroras a last resortPairing PR
This PR pairs with contentful/agents-api#447 which adds the suspend-on-401 logic to the workflow step.
Files changed
src/types/workflow.tsNeedsReauthSuspendPayload, addoauthTokentoResumePayload, updateWorkflowRunResultunionsrc/hooks/useWorkflowAgent.tsNeedsReauthSuspendPayloadingetSuspendPayloadreturn typesrc/locations/Page/components/mainpage/ModalOrchestrator.tsxFlowStep.REAUTH,pendingReauthRunIdstate,showReauthPrompt,handleReauthTokenChange, reauth modal render, new required propssrc/locations/Page/Page.tsxonOAuthConnectedChangeandonOauthTokenChangetoModalOrchestratortest/.../ModalOrchestrator.spec.tsxdefaultPropsTest plan
needs-google-reauthsuspend (mock it inuseWorkflowAgentor deploy pairing agents-api PR) and confirm the reconnect modal appears mid-workflowOAuthConnectorso the connected state stays in syncnpm run testinapps/google-docs🤖 Generated with Claude Code