Skip to content

Conversation

@harikakondur
Copy link
Contributor

@harikakondur harikakondur commented Dec 18, 2025

Purpose

https://contentful.atlassian.net/browse/INTEG-3348

Preview Step UI

  • temporary ui to view entry previews
  • uses useModalManagement() Hook

(ui in progress!!!)

528336719-e1f834a3-fb54-48c5-ab60-e4bdc2713629.mov

Function Refactor:

Split up createEntriesfromDocument into 3 functions to avoid timeout:

  1. analyzeContentTypes -> summarizes content types
  2. createPreview -> processes document and and creates preview entries
  3. createEntries -> calls cma to create entry drafts

Cleanup:

  • moved oauth stuff into a separate folder

@wiz-inc-38d59fb8d7
Copy link

wiz-inc-38d59fb8d7 bot commented Dec 18, 2025

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Medium
Software Supply Chain Finding Software Supply Chain Findings -
Total 1 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

Comment on lines -45 to -60
const cma = initContentfulManagementClient(context);
const contentTypes = await fetchContentTypes(cma, new Set<string>(contentTypeIds));

// Commented out to preserver as much time as possible due to the 30 second limit for App functions
// const contentTypeParserAgentResult = await analyzeContentTypes({ contentTypes, openAiApiKey });

// INTEG-3261: Pass the ai content type response to the observer for analysis
// createContentTypeObservationsFromLLMResponse()

const aiDocumentResponse = await analyzeDocumentWithAgent({
documentId,
oauthToken,
openAiApiKey,
contentTypes,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this part was split into

  • analyzeContentTypes
  • createPreview

Comment on lines -64 to -74
// INTEG-3264: Create the entries in Contentful using the entry service
// The aiDocumentResponse.entries is now ready to be passed to the CMA client
const creationResult = await createEntries(cma, aiDocumentResponse.entries, {
spaceId: context.spaceId,
environmentId: context.environmentId,
contentTypes,
});
console.log('Created Entries Result:', creationResult);

// INTEG-3265: Create the assets in Contentful using the asset service
// await createAssets()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • this part went to createEntries

Comment on lines +78 to +88
return (
<Modal onClose={handleClose} isShown={isOpen} size="fullWidth">
{() => (
<>
<Modal.Header title="Preview Parsed Entries" onClose={handleClose} />
<Modal.Content>
<Flex flexDirection="column" gap="spacingM">
<Card>
<Flex flexDirection="column" gap="spacingS">
<Paragraph>
Based off the document, the following entries are being suggested:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ui work will be in a followup ticket

Comment on lines +62 to 74
const analyzeContentTypesResponse = await analyzeContentTypesAction(
sdk,
contentTypeIds,
oauthToken
);
console.log('analyzeContentTypesResponse', analyzeContentTypesResponse);

const processDocumentResponse = await createPreviewAction(
sdk,
contentTypeIds,
documentId,
oauthToken
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

separate app actions in action 😼

@harikakondur harikakondur marked this pull request as ready for review December 18, 2025 22:16
@harikakondur harikakondur requested a review from a team as a code owner December 18, 2025 22:16
"description": "Function to create content blocks from App Action.",
"path": "functions/createEntriesFromDocument.js",
"entryFile": "functions/createEntriesFromDocument.ts",
"id": "createPreview",
Copy link
Contributor

Choose a reason for hiding this comment

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

not a huge deal but we should make sure functions are created and deleted as expected when changing the id

Copy link
Contributor

@mgoudy91 mgoudy91 left a comment

Choose a reason for hiding this comment

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

I skimmed over the UI code based on your comments, but the rest of this looks good

@ryunsong-contentful ryunsong-contentful merged commit 1b7d992 into google-docs-xmas-fb Dec 18, 2025
12 of 13 checks passed
harikakondur added a commit that referenced this pull request Jan 5, 2026
* fix: google docs package.json scripts so that it deploys correctly in ci (#10350)

* feat: preview step + functions refactor [INTEG-3348] (#10356)

* wip

* simplify agent

* organize oauth functions

* reorganizing function handlers

* reorganizing function handlers (prev `createEntriesfromDocument`) calling each agent in a separate function, + removing plan agent for now

* fix: function manifest

* minor edit to manifest

* replacing single function with 2: one for analyzing ct + one for document processing

* fix: add oauth token to analyze content type function

* fix: adding entries to document processor o/p

* feat: new app action to create entries, preview modal

* cleanup + rename preview function

* cleanup

* chore: delete test docs

* cleanup

* rename handler for consistency

* feat: rename functions and files to be consistent with each other (#10358)

* [INTEG-3359] feat: got google doc picker working (#10357)

* feat: got google doc picker working

* feat: explicitly add api key for google docs oauth connection

* feat(google-docs): review entries modal [INTEG-3363] (#10359)

* feat: reorganize file structure to be more compact (#10361)

* refactor: modal components in google docs to be its own component (#10362)

* refactor: content type analysis app action names to be consistent with other app actions (#10364)

* fix: retries for oauth to be 5 instead of 10 (#10365)

* [INTEG-3372] feat: google docs app works with references (#10366)

* feat: ai document parser can handle references now

* fix: console logs and fixed issues with creating entries and references being mapped

* fix: use correct prod deploy s3 base in google docs (#10368)

* fix: closing the modal from google docs picker no longer errors out (#10370)

* fix: update preview entry card ui [INTEG-3341] (#10367)

* fix: preview entry cards ui

* fix: using displayField for entry title

* pass sdk prop

* chore:fix gapi path

* feat: helper function to fetch entry titles

* chore: using forma style tokens for entry cards

* fix entry title helper functions

* fix: styles

* chore: rename title

* fix: copy

* fix: moving fetchEntryTitle logic to useGeneratePreview hook

* chore: remove logs

* chore: remove redundant title

* fix any type for entry

* replace magic number for title length

* rename and move getEntryTitle util

* handle zero entries better

* cleanup: remove null type for preview response and unused props( summary, total entries)

* cleanup

* rename previewData -> previewEntries

* cleanup

* refactor getEntryTitle to use a new getContentType util

* [INTEG-3381] refactor: preview modal changes (#10372)

* fix: refactor the preview modal logic to have cleaner typings

* feat: update app action typing using generics

* fix: multiple entries (#10371)

* fix: replacing select with multiselect for content type picker modal [INTEG-3378] (#10380)

* fix: replacing select with multiselect for content type picker modal, removing `SelectedContentTypes` type

* cleanup

* feat: file picker upgrade [INTEG-3368] (#10379)

* feat: file picker upgrade

* removing suggested folders logic

* feat: consolidate asset creation (#10377)

* feat: loading state modal [INTEG-3382] (#10391)

* feat: loading modal for google doc app

* loadting state for creating entries

* chore: cleanup

* chore: cleanup up modal hook

* chore: remove extra fragment tags

* fixing ModalOrchestrator

* empty commit to trigger circleci

---------

Co-authored-by: ryunsong-contentful <124832189+ryunsong-contentful@users.noreply.github.com>
Co-authored-by: Adrian Meyer <8539634+primeinteger@users.noreply.github.com>
Co-authored-by: david-shibley-contentful <149433784+david-shibley-contentful@users.noreply.github.com>
Co-authored-by: david shibley <david.shibley@contentful.com>
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