Skip to content

feat(google-docs): connect and replace initial mock hil steps [INTEG-3599]#10735

Merged
Harika Kondur (harikakondur) merged 10 commits intomasterfrom
initial-hil-steps
Mar 26, 2026
Merged

feat(google-docs): connect and replace initial mock hil steps [INTEG-3599]#10735
Harika Kondur (harikakondur) merged 10 commits intomasterfrom
initial-hil-steps

Conversation

@harikakondur
Copy link
Copy Markdown
Contributor

@harikakondur Harika Kondur (harikakondur) commented Mar 25, 2026

PR Description

Connects the Google Docs frontend to the workflow-based human-in-the-loop flow.

After content type selection, the frontend starts the google-docs-workflow-agent, polls the thread run until it completes or pauses for review, and uses the suspend payload to show the tabs and images steps. Resume decisions are sent back through the resume API using the thread id. This replaces the previous mock-first flow.

Files Changed

File Change
useWorkflowAgent.ts Added workflow start, polling, and resume logic. Keeps using the thread id while polling and sends the resume payload using the current API contract.
ModalOrchestrator.tsx Updated the modal flow to start the workflow after content type selection, store the active thread id, build the resume payload from review state, and move through the tabs/images steps based on backend suspend data.
SelectTabsModal.tsx Removed the mock tab fallback so the modal only shows tabs returned by the backend.
types.ts Added shared types for suspend payloads, resume payloads, workflow results, and document-scope review state.
ModalOrchestrator.spec.tsx Updated tests to cover the workflow start, suspend, and resume flow.

@harikakondur Harika Kondur (harikakondur) marked this pull request as ready for review March 25, 2026 15:22
@harikakondur Harika Kondur (harikakondur) requested a review from a team as a code owner March 25, 2026 15:22
Copilot AI review requested due to automatic review settings March 25, 2026 15:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Connects the Google Docs app’s modal flow to the workflow-based human-in-the-loop (HIL) backend by starting a workflow after content type selection, polling for completion/suspension, and resuming with user review decisions.

Changes:

  • Add useWorkflowAgent workflow start/poll/resume support and wire it into ModalOrchestrator.
  • Replace mock-first tab/image review flow with backend-driven suspend payload + resume payload.
  • Update UI/tests/types to support the new document-scope review state and workflow results.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
apps/google-docs/src/hooks/useWorkflowAgent.ts Implements workflow run creation, polling, and resume calls against Agents API (local + CMA).
apps/google-docs/src/locations/Page/components/mainpage/ModalOrchestrator.tsx Orchestrates the new workflow-driven modal flow; builds review state and resume payload.
apps/google-docs/src/locations/Page/components/modals/step_2/ContentTypePickerModal.tsx Switches onContinue to pass string[] of content type IDs (no CSV).
apps/google-docs/src/locations/Page/components/modals/step_3/SelectTabsModal.tsx Removes mock tabs fallback so tabs are backend-provided only.
apps/google-docs/src/utils/types.ts Adds shared types for suspend payload, resume payload, workflow results, and review state.
apps/google-docs/test/locations/Page/components/mainpage/ModalOrchestrator.spec.tsx Updates tests to cover workflow start → suspend → review steps → resume.
apps/google-docs/src/locations/Page/Page.tsx Removes the “Optimization tip” note content and related styling/imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

setAvailableTabs(MOCK_TABS);
setHasAttemptedSubmit(false);
}, [setAvailableTabs]);
}, [availableTabs, setAvailableTabs]);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The useEffect here only resets hasAttemptedSubmit, but its dependency list includes availableTabs and setAvailableTabs (which isn't otherwise used). This will reset validation state whenever the tabs array identity changes, and setAvailableTabs can likely be removed entirely from this component API now that tabs come from the backend. Consider making this effect run only on mount (or when the modal opens) and dropping the unused setAvailableTabs prop/dependency.

Suggested change
}, [availableTabs, setAvailableTabs]);
}, []);

Copilot uses AI. Check for mistakes.
Comment on lines +202 to +206
headers: {
'Content-Type': 'application/json',
'x-contentful-enable-alpha-feature': 'agents-api',
'X-Contentful-App-Definition-Id': '653vTnuQw3j5onU1tUoH6t',
},
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

X-Contentful-App-Definition-Id is hard-coded here. This is brittle (will break if the app definition changes or in different environments) and makes local API behavior dependent on a committed ID. Prefer deriving it from sdk.ids.app (as done elsewhere in the codebase) and only sending the header when an app id is available.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@JuliRossi JuliRossi left a comment

Choose a reason for hiding this comment

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

⭐ Overall, really nice work! How you should read my comments:
💡 ideas for the future (definitely not for now)
⛏️ nitpicks (nice to haves, not need to implement)
💭 suggestions (strongly suggest, not need to implement)
⚔️ dealbreakers /must (what makes me not approve this PR, need to implement/further discussions)

headers: {
'Content-Type': 'application/json',
'x-contentful-enable-alpha-feature': 'agents-api',
'X-Contentful-App-Definition-Id': '653vTnuQw3j5onU1tUoH6t',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⛏️ Should be an env var?

@harikakondur Harika Kondur (harikakondur) force-pushed the initial-hil-steps branch 3 times, most recently from ffd7fb7 to e164198 Compare March 26, 2026 14:45
@harikakondur Harika Kondur (harikakondur) force-pushed the initial-hil-steps branch 2 times, most recently from c5c032c to 8bc409b Compare March 26, 2026 15:52
}

interface WorkflowResult {
interface WorkflowHook {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not the most ideal type name

@harikakondur Harika Kondur (harikakondur) merged commit da5c317 into master Mar 26, 2026
14 checks passed
@harikakondur Harika Kondur (harikakondur) deleted the initial-hil-steps branch March 26, 2026 17:50
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.

4 participants