Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7104: affordance to pass data from host page to AA Co-Pilot forms #7109

Merged
merged 10 commits into from
Dec 13, 2023

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Dec 13, 2023

What does this PR do?

  • Closes Support passing data to AA Copilot via postMessage #7104
  • Adds window message handlers to the sidebar and frame to listen for AA Co-Pilot data requests
  • Adds "Map Automation Anywhere Co-Pilot Data" brick to set the host data to pass to the AA Co-Pilot
  • Adds an affordance for setting the name attribute on the IFrame brick

Remaining Work

  • Figure out how to message the extension frames with the data: @fregante do we have an affordance to messaging the extension frames on a page?
  • Figure out how to handle scenario where the host data is set before the frame is shown. I think when the sidebar/frame is added to the page, it needs to ask the top-level frame on the page if there's any host data set. @fregante what's the correct/best way for an extension frame on a page to message the top-level content script?

Reviewer Tips

  • frameProtocol.ts contains the message handler for the window message from the AA Co-Pilot frame

Discussion

  • With the IFrame brick, the frame might be embedded either directly into the sidebar, or with a layer of indirection with our frame.html to workaround the CSP
  • The reason why we're pre-setting the data is that there appears to be a 30-40ms time frame in which the host page must respond to the data request message. So the information needs to be available in the parent frame to respond immediately

Demo

Team Coordination

Checklist

  • Add tests: I will add a test mod and regression test entry. The code is 90% message passing, so E2E is the only effective way to test
  • New files added to src/tsconfig.strictNullChecks.json (if possible)
  • Designate a primary reviewer: @grahamlangford

@twschiller twschiller requested a review from fregante December 13, 2023 04:18
@twschiller twschiller self-assigned this Dec 13, 2023
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 55 lines in your changes are missing coverage. Please review.

Comparison is base (21b82ba) 71.21% compared to head (449c008) 71.12%.

Files Patch % Lines
src/contrib/automationanywhere/aaFrameProtocol.ts 0.00% 27 Missing ⚠️
...contrib/automationanywhere/SetCopilotDataEffect.ts 45.00% 11 Missing ⚠️
src/background/partnerHandlers.ts 0.00% 6 Missing ⚠️
src/tinyPages/frame.ts 0.00% 5 Missing ⚠️
src/bricks/renderers/iframe.ts 0.00% 4 Missing ⚠️
src/development/headers.ts 0.00% 1 Missing ⚠️
src/sidebar/sidebar.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7109      +/-   ##
==========================================
- Coverage   71.21%   71.12%   -0.09%     
==========================================
  Files        1210     1213       +3     
  Lines       37469    37533      +64     
  Branches     7061     7068       +7     
==========================================
+ Hits        26682    26696      +14     
- Misses      10787    10837      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@twschiller twschiller added this to the 1.8.5 milestone Dec 13, 2023
@fregante
Copy link
Contributor

fregante commented Dec 13, 2023

  • do we have an affordance to messaging the extension frames on a page?

Yes, via page target:

const target = { tabId: "this", page: "/sidebar.html" } as const;
const sidebarInThisTab = {
renderPanels: getMethod("SIDEBAR_RENDER_PANELS", target),

  • what's the correct way for an extension frame on a page to message the top-level content script?

I think it's {tabId: "this", frameId: 0}

No, getTopLevelFrame():

const topFrame = await getTopLevelFrame();
// Ensure persistent sidebar extension points have been installed to have reserve their panels for the sidebar
await ensureExtensionPointsInstalled(topFrame);

"this" only works towards chrome-extension:// pages for now:

@twschiller twschiller changed the title #7104: [WIP] affordance to pass data to AA Co-Pilot forms #7104: affordance to pass data to AA Co-Pilot forms Dec 13, 2023
@twschiller twschiller marked this pull request as ready for review December 13, 2023 13:50
@twschiller twschiller added enhancement New feature or request enterprise customer Required for a customer projct labels Dec 13, 2023
@twschiller twschiller requested a review from mthek10 December 13, 2023 13:57
@twschiller twschiller changed the title #7104: affordance to pass data to AA Co-Pilot forms #7104: affordance to pass data from host page to AA Co-Pilot forms Dec 13, 2023
Copy link

When the PR is merged, the first loom link found on this PR will be posted to #sprint-demo on Slack. Do not edit this comment manually.

@grahamlangford grahamlangford merged commit dab1fec into main Dec 13, 2023
14 checks passed
@grahamlangford grahamlangford deleted the feature/7104-copilot-data branch December 13, 2023 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer Required for a customer projct enhancement New feature or request enterprise
Development

Successfully merging this pull request may close these issues.

Support passing data to AA Copilot via postMessage
3 participants