Skip to content

Conversation

syn-zhu
Copy link
Collaborator

@syn-zhu syn-zhu commented Aug 29, 2025

Description

Screen.Recording.2025-09-17.at.11.48.12.AM.mov

TODO:

  • Handle case where the initial workspace is the only one to be opened. initial workspace doesn't trigger stage update, so we need another way to trigger the save state middleware.
  • If the initial workspace is only the welcome page, then replace the welcome page with saved tabs?
  • Should we set any specific tab as the active one upon restore?
  • If welcome page was one of the prebiously saved tabs. currently we're duplicating it with the one that opens upon initialization.
  • handle unlikely edgecase where user opens a workspace and triggers save to userdata before the savedTabsPromise even finishes. In this case, it's possible in theory that the savedTabsPromise would end up returning the current tabs because the write would have overwritten previously saved tabs.
    • we should probably avoid saving anything until the initial load is done.

test ases:

  • there is no saved state.
  • one of the tabs we're trying to restore references a connection that no longer exists.
  • one of the tabs we're trying to restore no longer exists (e.g. collection / database was deleted);

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

/**
* UserData instance to use for persisting workspace state
*/
userData: IUserData<typeof WorkspacesStateSchema>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Services shouldn't be used and passed around in views like that. This should be facilicated through the store

);

useEffect(() => {
savedWorkspacesPromiseRef.current.then(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't be happening in render method, this logic belongs in the store

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can move this

initialWorkspaceTabs,
}: { initialWorkspaceTabs?: OpenWorkspaceOptions[] | null },
}: {
userData: IUserData<typeof WorkspacesStateSchema>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Services should be injected through service injection mechanism, not passed as props

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you elaborate on this one? What's service injection mechanism?

// Save to UserData with a fixed ID
await userData.write('current-workspace', stateToSave);

// Optional: Log for debugging in development
Copy link
Collaborator

@gribnoysup gribnoysup Sep 17, 2025

Choose a reason for hiding this comment

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

You should use logger service instead, we don't use console for logging (hence the eslint rule that disables it)

return this.cloudEndpoint(path);
}
userDataEndpoint(path?: string): string {
return `https://cluster-connection.cloud-dev.mongodb.com/userData${normalizePath(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: unhardcode this

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.

2 participants