internal: rework studio handshake to allow better caching (#31599)

* feat: (studio) Capture telemetry for studio initialization

* fixes

* revert type changes

* add studio lifecycle manager

* fix studio router

* finish lifecycle manager, add test coverage

* fix types

* fix types for real

* fix types actually

* fix lint

* fix routes spec

* fix lint, add try/catch

* remove work to capture telemetry

* didn't mean to remove this part

* fix types

* remove test for other branch

* feedback

* fix test

* encapsulate more logic into studio lifecycle manager

* feedback

* fix tests

* blank

* feedback

* Update packages/app/src/runner/event-manager.ts

Co-authored-by: Matt Schile <mschile@cypress.io>

* fix lint

* fix hiding runner ui

* update test

* re-work lifecycle manager implementation to not use EventEmitter

* fix listener registration logic

* ensure that studio still loads even when cloud bundle doesn't

* feedback

* feedback

* use getter for isProtocolEnabled, report studio manager initialization errors, remove references for isStudioProtocolEnabled

* clean up listeners when initialization errors

* Update packages/server/lib/StudioLifecycleManager.ts

Co-authored-by: Matt Schile <mschile@cypress.io>

* Update packages/server/lib/StudioLifecycleManager.ts

Co-authored-by: Matt Schile <mschile@cypress.io>

* Update packages/server/lib/StudioLifecycleManager.ts

Co-authored-by: Matt Schile <mschile@cypress.io>

* feedback

* fix: rework studio handshake to allow better caching

* merge conflict

* slight refactor

* update types

* Update packages/server/lib/cloud/api/studio/post_studio_session.ts

* Apply suggestions from code review

* fix test

* PR comment

---------

Co-authored-by: astone123 <adams@cypress.io>
Co-authored-by: Matt Schile <mschile@cypress.io>
This commit is contained in:
Ryan Manuel
2025-04-30 13:33:02 -05:00
committed by GitHub
parent 2a6e9fbd44
commit d435ddaac3
11 changed files with 267 additions and 82 deletions

View File

@@ -3,9 +3,12 @@ process.env.CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV ?? 'producti
import path from 'path'
import fs from 'fs-extra'
import { retrieveAndExtractStudioBundle, studioPath } from '@packages/server/lib/cloud/api/studio/get_and_initialize_studio_manager'
import { postStudioSession } from '@packages/server/lib/cloud/api/studio/post_studio_session'
export const downloadStudioTypes = async (): Promise<void> => {
await retrieveAndExtractStudioBundle({ projectId: 'ypt4pf' })
const studioSession = await postStudioSession({ projectId: 'ypt4pf' })
await retrieveAndExtractStudioBundle({ studioUrl: studioSession.studioUrl, projectId: 'ypt4pf' })
await fs.copyFile(
path.join(studioPath, 'app', 'types.ts'),