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

Expose cloud event logging endpoint to GUI and render GUI editor as react component. #9951

Merged
merged 22 commits into from
May 27, 2024

Conversation

Frizi
Copy link
Contributor

@Frizi Frizi commented May 14, 2024

Pull Request Description

fixes #9730

Added a logEvent method to remote backend implementation in dashboard. Added an always-present remote backend instance that can be used for logging even when running a local project (intentional behavior).

Important Notes

Because the backend implementation requires access to always fresh session token, the logger needs to be periodically updated on GUI side, so it can continue to function. To accomplish that, I simplified the app loading logic to treat GUI as an ordinary react component, so its props can be updated with normal react rendering flow. That refactor also removed the dynamic GUI asset loading code that was only needed for Rust GUI.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.

Copy link
Collaborator

@somebody1234 somebody1234 left a comment

Choose a reason for hiding this comment

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

logic changes look good, some minor nits
(not included: other style nits that will be caught by CI)

await window.enso?.runApp(config, accessToken)
},
},
appRunner: null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably (?) fine for now?
but we will probably want to refactor the Vite setup so that the cloud build also bundles GUI2, very soon.

i guess it's out of scope for this PR? but i imagine we eventually want the cloud dashboard to import the module for GUI2, and remove appRunner as a configuration option

Copy link
Contributor Author

@Frizi Frizi May 22, 2024

Choose a reason for hiding this comment

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

Technically the GUI Vite setup does bundle dashboard and editor. We could just use that instead.

I agree that direct import will be preferred over the current appRunner indirection. We can refactor that once the apps are unified.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah. about the GUI Vite setup - i guess the idea then, is to make sure we have the option to disable the Local backend at build time (for the cloud build). iirc, the Vite configs are already pretty similar so ideally there shouldn't be too many issues with that

@somebody1234
Copy link
Collaborator

also i remember the dashboard's custom button class conflicting with the GUI's definitions. so it should probably be renamed both in tailwind.config.ts, and any TSX classNames containing button

@farmaazon
Copy link
Contributor

@Frizi what is the status here? What is needed to undraft this PR?

@Frizi Frizi added the CI: No changelog needed Do not require a changelog entry for this PR. label May 23, 2024
@Frizi Frizi marked this pull request as ready for review May 23, 2024 13:27
Copy link
Contributor

@farmaazon farmaazon left a comment

Choose a reason for hiding this comment

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

Checked files owned by me (so skipped dashboard changes).

I assume all stores have not been changed, except making them contexts.

registerAutoBlurHandler()
const logger = provideEventLogger(toRef(props, 'logEvent'), toRef(props, 'projectId'))
watch(
[toRef(props, 'projectId')],
Copy link
Contributor

Choose a reason for hiding this comment

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

Cannot we just watch props.projectId? Why we wrap it in an array?

Copy link
Collaborator

Choose a reason for hiding this comment

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

i assume props.projectId comes from React so you wouldn't get reactivity. although, i also assume toRef(props, 'projectId') without the wrapping array would be valid, since it is a ref (i.e. it is a valid watch source)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The array is indeed unnecessary, but toRef is needed to pass a ref the watcher, not the current value.

const projectStore = useProjectStore()
const suggestionDb = useSuggestionDbStore()

// Initialize suggestion db immediately, so it will be ready when user needs it.
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIR providing the suggestionDbStore should now initialize it, not the code below, so this comment is to be removed (before, we called useSuggestionDbStore inside onMounted)


const syncModule = computed(() => proj.module && markRaw(new MutableModule(proj.module.doc.ydoc)))
export type GraphStore = ReturnType<typeof useGraphStore>
export const { injectFn: useGraphStore, provideFn: provideGraphStore } = createContextStore(
Copy link
Contributor

Choose a reason for hiding this comment

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

Everywhere else, we use inject prefix, not use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the inject ones are a bit non-standard, and I'm considering renaming those. For now, I kept the names as they used to be for stores previously implemented through pinia. We might consider renaming things, but I'd do it outside of this PR.

Comment on lines +70 to +71
this.#setupUpdateHandler(lsRpc)
this.#loadGroups(lsRpc, projectStore.firstExecution)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change it? Isn't TS compile-time checking sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case the use of private caused weird issues with typechecking after the types went through proxyRefs. I just decided to use native private fields to get around that, as those have no such issues.

@Frizi Frizi added the CI: Ready to merge This PR is eligible for automatic merge label May 24, 2024
@Frizi Frizi added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label May 27, 2024
@mergify mergify bot merged commit 8edf493 into develop May 27, 2024
37 checks passed
@mergify mergify bot deleted the wip/frizi/log-opensearch-events branch May 27, 2024 17:32
alias: {
...resolve?.alias,
// Use `ffiPolyglot` module as `ffi` interface during the build.
'shared/ast/ffi': fileURLToPath(new URL('./shared/ast/ffiPolyglot.ts', import.meta.url)),
Copy link
Contributor

Choose a reason for hiding this comment

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

@Frizi it does not work. If you run

$ npm --workspace=enso-gui2 run build-ydoc-server-polyglot

it will use the original ffi.ts module

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll revert it

4e6 added a commit that referenced this pull request May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add basic Opensearch telemetry to Electron App
5 participants