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

[Odie][PoC][DRAFT] Standalone Odie client #84069

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

AllTerrainDeveloper
Copy link
Contributor

@AllTerrainDeveloper AllTerrainDeveloper commented Nov 9, 2023

Proposed Changes

This is just a draft where I am trying to create a new package so we can use this client that already connects with our ai-services.

We still need to remove two dependencies (and probably delete the code, I think we don't need it as I did it thinking around Jetpack). That code lives on odie/query/index.ts

import { canAccessWpcomApis } from 'wpcom-proxy-request';
import wpcom from 'calypso/lib/wp';

Lastly, we should inject the User's avatar or display image. Right now its a Calypso dependency using Gravatar component.

Addressing those two things, we have almost decoupled the client from Calypso, and next steps would be to generate a package and add it as a dependency to Calypso or whatever.

All the files in the utils folder are added as a copy from elsewhere in calypso.

DISCLAIMER
Please bear in mind that the current Odie client code is going to be live and actively used next Monday, do not merge if we are not fully sure that the changes we are doing are working.

Testing Instructions

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • https://wpcalypso.wordpress.com/devdocs/docs/testing/index.md for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 9, 2023
Copy link

github-actions bot commented Nov 9, 2023

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • editing-toolkit

To test WordPress.com changes, run install-plugin.sh $pluginSlug prismiwi2015/poc-odie-as-standalone-package on your sandbox.

@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~613 bytes added 📈 [gzipped])

name                   parsed_size           gzip_size
entry-stepper               -357 B  (-0.0%)      -36 B  (-0.0%)
entry-main                  -297 B  (-0.0%)      -27 B  (-0.0%)
entry-subscriptions         -153 B  (-0.0%)      -59 B  (-0.0%)
entry-login                 -153 B  (-0.0%)      -26 B  (-0.0%)
entry-domains-landing       -153 B  (-0.0%)      -59 B  (-0.0%)
entry-browsehappy           -153 B  (-0.1%)      -59 B  (-0.1%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~5335 bytes added 📈 [gzipped])

name                               parsed_size            gzip_size
plugin-bundle-flow                     +1178 B   (+0.6%)    +1067 B   (+1.7%)
trial-wooexpress-flow                  +1075 B   (+1.2%)     +963 B   (+3.3%)
transferring-hosted-site-flow          +1075 B   (+2.2%)     +822 B   (+4.8%)
write-flow                              +946 B   (+0.1%)     +323 B   (+0.1%)
videopress-tv-flow                      +946 B   (+1.6%)     +327 B   (+1.6%)
videopress-flow                         +946 B   (+0.1%)     +333 B   (+0.1%)
themes                                  +946 B   (+0.1%)     +352 B   (+0.1%)
tailored-ecommerce-flow                 +946 B   (+0.1%)     +304 B   (+0.1%)
subscribers                             +946 B   (+0.2%)     +335 B   (+0.2%)
stats                                   +946 B   (+0.1%)     +334 B   (+0.1%)
sensei-flow                             +946 B   (+0.2%)     +316 B   (+0.2%)
promote-post-i2                         +946 B   (+0.3%)     +354 B   (+0.3%)
podcasts-flow                           +946 B   (+0.2%)     +335 B   (+0.2%)
people                                  +946 B   (+0.2%)     +359 B   (+0.2%)
newsletter-post-setup-flow              +946 B   (+0.7%)     +334 B   (+0.7%)
marketplace                             +946 B   (+0.1%)     +297 B   (+0.1%)
link-in-bio-tld-flow                    +946 B   (+0.1%)     +326 B   (+0.1%)
link-in-bio-post-setup-flow             +946 B   (+0.7%)     +334 B   (+0.7%)
import-hosted-site-flow                 +946 B   (+0.0%)     +342 B   (+0.1%)
import-flow                             +946 B   (+0.0%)     +342 B   (+0.0%)
home                                    +946 B   (+0.1%)     +353 B   (+0.1%)
free-post-setup-flow                    +946 B   (+0.7%)     +334 B   (+0.7%)
domain-user-transfer-flow               +946 B   (+0.4%)     +357 B   (+0.7%)
copy-site-flow                          +946 B   (+0.1%)     +331 B   (+0.2%)
build-flow                              +946 B   (+0.1%)     +323 B   (+0.1%)
update-design-flow                      +926 B   (+0.1%)     +332 B   (+0.1%)
woocommerce-installation                +843 B   (+0.3%)     +327 B   (+0.4%)
theme                                   +843 B   (+0.1%)     +322 B   (+0.2%)
site-purchases                          +843 B   (+0.1%)     +327 B   (+0.1%)
site-monitoring                         +843 B   (+0.2%)     +304 B   (+0.2%)
site-blocks                             +843 B   (+0.1%)     +327 B   (+0.2%)
settings-writing                        +843 B   (+0.2%)     +327 B   (+0.2%)
settings-security                       +843 B   (+0.2%)     +327 B   (+0.3%)
settings-reading                        +843 B   (+0.2%)     +327 B   (+0.3%)
settings-podcast                        +843 B   (+0.2%)     +327 B   (+0.2%)
settings-performance                    +843 B   (+0.2%)     +327 B   (+0.2%)
settings-newsletter                     +843 B   (+0.2%)     +327 B   (+0.3%)
settings-jetpack                        +843 B   (+0.2%)     +327 B   (+0.2%)
settings-discussion                     +843 B   (+0.2%)     +327 B   (+0.3%)
settings                                +843 B   (+0.1%)     +327 B   (+0.1%)
security                                +843 B   (+0.1%)     +327 B   (+0.1%)
scan                                    +843 B   (+0.1%)     +327 B   (+0.2%)
reader                                  +843 B   (+0.1%)     +327 B   (+0.1%)
purchases                               +843 B   (+0.0%)     +327 B   (+0.1%)
purchase-product                        +843 B   (+0.4%)     +325 B   (+0.6%)
privacy                                 +843 B   (+0.1%)     +327 B   (+0.2%)
posts-custom                            +843 B   (+0.1%)     +327 B   (+0.2%)
posts                                   +843 B   (+0.1%)     +327 B   (+0.2%)
plugins                                 +843 B   (+0.0%)     +327 B   (+0.1%)
plans                                   +843 B   (+0.1%)     +327 B   (+0.1%)
pages                                   +843 B   (+0.2%)     +327 B   (+0.2%)
notification-settings                   +843 B   (+0.1%)     +327 B   (+0.1%)
migrate                                 +843 B   (+0.3%)     +328 B   (+0.4%)
media                                   +843 B   (+0.1%)     +327 B   (+0.1%)
me                                      +843 B   (+0.1%)     +327 B   (+0.2%)
marketing                               +843 B   (+0.1%)     +327 B   (+0.2%)
mailing-lists                           +843 B  (+10.2%)     +346 B  (+14.5%)
jetpack-social                          +843 B   (+0.2%)     +340 B   (+0.3%)
jetpack-search                          +843 B   (+0.2%)     +308 B   (+0.2%)
jetpack-connect                         +843 B   (+0.1%)     +325 B   (+0.1%)
jetpack-cloud-settings                  +843 B   (+0.2%)     +327 B   (+0.2%)
jetpack-cloud-pricing                   +843 B   (+0.1%)     +327 B   (+0.2%)
jetpack-cloud-plugin-management         +843 B   (+0.1%)     +327 B   (+0.1%)
jetpack-cloud-partner-portal            +843 B   (+0.1%)     +344 B   (+0.1%)
jetpack-cloud-features-comparison       +843 B   (+0.1%)     +327 B   (+0.2%)
jetpack-cloud-agency-signup             +843 B   (+0.8%)     +329 B   (+0.9%)
jetpack-cloud-agency-dashboard          +843 B   (+0.1%)     +344 B   (+0.1%)
jetpack-app                             +843 B   (+0.2%)     +327 B   (+0.2%)
import                                  +843 B   (+0.2%)     +327 B   (+0.3%)
hosting                                 +843 B   (+0.1%)     +327 B   (+0.2%)
help                                    +843 B   (+0.1%)     +327 B   (+0.2%)
google-my-business                      +843 B   (+0.2%)     +327 B   (+0.2%)
export                                  +843 B   (+0.3%)     +327 B   (+0.4%)
email                                   +843 B   (+0.1%)     +327 B   (+0.2%)
earn                                    +843 B   (+0.2%)     +327 B   (+0.2%)
domains                                 +843 B   (+0.0%)     +327 B   (+0.1%)
concierge                               +843 B   (+0.2%)     +298 B   (+0.3%)
comments                                +843 B   (+0.1%)     +327 B   (+0.2%)
checkout                                +843 B   (+0.0%)     +288 B   (+0.1%)
backup                                  +843 B   (+0.1%)     +327 B   (+0.1%)
add-ons                                 +843 B   (+0.3%)     +327 B   (+0.3%)
activity                                +843 B   (+0.1%)     +327 B   (+0.2%)
account-close                           +843 B   (+0.1%)     +327 B   (+0.2%)
account                                 +843 B   (+0.1%)     +327 B   (+0.1%)
accept-invite                           +843 B   (+0.2%)     +366 B   (+0.4%)
with-theme-assembler-flow                -20 B   (-0.0%)      -14 B   (-0.1%)
site-setup-flow                          -20 B   (-0.0%)      -13 B   (-0.1%)
free-flow                                -20 B   (-0.0%)      -14 B   (-0.2%)
ai-assembler-flow                        -20 B   (-0.0%)      -14 B   (-0.1%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~4937 bytes added 📈 [gzipped])

name                                                                         parsed_size           gzip_size
async-load-automattic-help-center                                                +1884 B  (+0.4%)     +707 B  (+0.5%)
async-load-signup-steps-woocommerce-install-transfer                              +946 B  (+3.2%)     +367 B  (+4.0%)
async-load-signup-steps-woocommerce-install-step-store-address                    +946 B  (+1.1%)     +344 B  (+1.2%)
async-load-signup-steps-woocommerce-install-step-business-info                    +946 B  (+1.1%)     +364 B  (+1.3%)
async-load-signup-steps-woocommerce-install-confirm                               +946 B  (+1.8%)     +368 B  (+2.2%)
async-load-signup-steps-website-content                                           +946 B  (+1.0%)     +367 B  (+1.2%)
async-load-signup-steps-user                                                      +946 B  (+0.7%)     +350 B  (+1.0%)
async-load-signup-steps-theme-selection                                           +946 B  (+0.3%)     +359 B  (+0.4%)
async-load-signup-steps-test-step                                                 +946 B  (+5.0%)     +366 B  (+6.1%)
async-load-signup-steps-store-features                                            +946 B  (+2.2%)     +344 B  (+2.7%)
async-load-signup-steps-starting-point                                            +946 B  (+2.7%)     +366 B  (+3.5%)
async-load-signup-steps-social-profiles                                           +946 B  (+3.8%)     +367 B  (+4.7%)
async-load-signup-steps-site-picker                                               +946 B  (+0.6%)     +365 B  (+0.7%)
async-load-signup-steps-site-or-domain                                            +946 B  (+2.4%)     +370 B  (+3.1%)
async-load-signup-steps-site-options                                              +946 B  (+2.4%)     +344 B  (+3.0%)
async-load-signup-steps-site                                                      +946 B  (+2.3%)     +345 B  (+2.8%)
async-load-signup-steps-rewind-were-backing                                       +946 B  (+4.7%)     +367 B  (+5.6%)
async-load-signup-steps-rewind-migrate                                            +946 B  (+2.0%)     +368 B  (+2.5%)
async-load-signup-steps-rewind-form-creds                                         +946 B  (+1.5%)     +345 B  (+1.8%)
async-load-signup-steps-reader-landing                                            +946 B  (+4.1%)     +367 B  (+5.1%)
async-load-signup-steps-plans-theme-preselected                                   +946 B  (+0.2%)     +367 B  (+0.3%)
async-load-signup-steps-plans                                                     +946 B  (+0.2%)     +367 B  (+0.3%)
async-load-signup-steps-page-picker                                               +946 B  (+1.8%)     +370 B  (+2.2%)
async-load-signup-steps-p2-site                                                   +946 B  (+1.9%)     +345 B  (+2.3%)
async-load-signup-steps-p2-join-workspace                                         +946 B  (+3.3%)     +362 B  (+4.0%)
async-load-signup-steps-p2-get-started                                            +946 B  (+4.2%)     +368 B  (+5.1%)
async-load-signup-steps-p2-details                                                +946 B  (+4.2%)     +363 B  (+5.0%)
async-load-signup-steps-p2-confirm-email                                          +946 B  (+3.9%)     +368 B  (+4.7%)
async-load-signup-steps-p2-complete-profile                                       +946 B  (+1.0%)     +346 B  (+1.2%)
async-load-signup-steps-new-or-existing-site                                      +946 B  (+2.5%)     +349 B  (+2.7%)
async-load-signup-steps-intent                                                    +946 B  (+2.5%)     +344 B  (+3.0%)
async-load-signup-steps-emails                                                    +946 B  (+1.6%)     +368 B  (+1.9%)
async-load-signup-steps-domains                                                   +946 B  (+0.2%)     +347 B  (+0.2%)
async-load-signup-steps-difm-site-picker                                          +946 B  (+0.6%)     +366 B  (+0.7%)
async-load-signup-steps-design-picker                                             +946 B  (+1.5%)     +364 B  (+1.8%)
async-load-signup-steps-creds-permission                                          +946 B  (+2.0%)     +369 B  (+2.4%)
async-load-signup-steps-creds-confirm                                             +946 B  (+2.0%)     +370 B  (+2.4%)
async-load-signup-steps-creds-complete                                            +946 B  (+4.7%)     +368 B  (+5.6%)
async-load-signup-steps-courses                                                   +946 B  (+3.3%)     +370 B  (+4.0%)
async-load-signup-steps-clone-start                                               +946 B  (+3.7%)     +369 B  (+4.6%)
async-load-signup-steps-clone-ready                                               +946 B  (+1.9%)     +367 B  (+2.4%)
async-load-signup-steps-clone-point                                               +946 B  (+0.5%)     +351 B  (+0.8%)
async-load-signup-steps-clone-jetpack                                             +946 B  (+4.3%)     +365 B  (+5.3%)
async-load-signup-steps-clone-destination                                         +946 B  (+3.0%)     +343 B  (+3.6%)
async-load-signup-steps-clone-credentials                                         +946 B  (+1.4%)     +345 B  (+1.7%)
async-load-signup-steps-clone-cloning                                             +946 B  (+3.8%)     +366 B  (+4.6%)
async-load-signup-steps-add-ons                                                   +946 B  (+0.8%)     +368 B  (+1.0%)
async-load-store-app-store-stats                                                  +843 B  (+0.2%)     +327 B  (+0.3%)
async-load-design-playground                                                      +843 B  (+0.1%)     +327 B  (+0.1%)
async-load-design-blocks                                                          +843 B  (+0.0%)     +330 B  (+0.1%)
async-load-design                                                                 +843 B  (+0.0%)     +327 B  (+0.1%)
async-load-calypso-post-editor-editor-media-modal                                 +843 B  (+0.1%)     +299 B  (+0.1%)
async-load-calypso-my-sites-current-site-notice                                   +843 B  (+1.6%)     +319 B  (+1.8%)
async-load-calypso-my-sites-checkout-modal                                        +843 B  (+0.1%)     +288 B  (+0.1%)
async-load-calypso-components-web-preview-component                               +843 B  (+0.1%)     +303 B  (+0.2%)
async-load-calypso-blocks-support-article-dialog-dialog                           +843 B  (+0.4%)     +311 B  (+0.5%)
async-load-calypso-blocks-jitm-templates-sidebar-banner                           +843 B  (+2.2%)     +317 B  (+2.4%)
async-load-calypso-blocks-jitm-templates-notice                                   +843 B  (+2.2%)     +316 B  (+2.4%)
async-load-calypso-blocks-jitm-templates-default                                  +843 B  (+2.2%)     +317 B  (+2.4%)
async-load-calypso-blocks-editor-checkout-modal                                   +843 B  (+0.1%)     +288 B  (+0.1%)
async-load-signup-steps-woocommerce-install                                       +103 B  (+3.4%)      +30 B  (+2.8%)
async-load-automattic-global-styles-src-components-global-styles-variations       +103 B  (+0.0%)       +8 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Comment on lines +6 to +14
function omit( obj, fields ) {
const newObj = { ...obj };
for ( const field of fields ) {
if ( newObj.hasOwnProperty( field ) ) {
delete newObj[ field ];
}
}
return newObj;
}
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 is the result of removing lodash library. It was included as a dependency in order to load it's omit function

Comment on lines +66 to +74
const { isMinimized } = useSelect( ( select ) => {
const store = select( HELP_CENTER_STORE ) as HelpCenterSelect;
return {
show: store.isHelpCenterShown(),
isMinimized: store.getIsMinimized(),
initialRoute: store.getInitialRoute(),
};
}, [] );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the Help Center dependency

Comment on lines 10 to 12
import MinimizeIcon from 'calypso/assets/images/odie/minimize-icon.svg';
import WapuuAvatar from 'calypso/assets/images/odie/wapuu-squared-avatar.svg';
import WapuuThinking from 'calypso/assets/images/odie/wapuu-thinking.svg';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These assets should be moved inside the package

Comment on lines 13 to 14
import Gravatar from 'calypso/components/gravatar';
import { getCurrentUser } from 'calypso/state/current-user/selectors';
Copy link
Contributor Author

@AllTerrainDeveloper AllTerrainDeveloper Nov 9, 2023

Choose a reason for hiding this comment

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

We need to inject this as a component to represent the user's profile. It ca be a new prop for Odie,

<OdieProvider
        ...
        ...
        userAvatarComponent={<Gravatar... />}
>
        { children }
<OdieProvider/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO NOT MERGE [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants