Skip to content

Conversation

@syn-zhu
Copy link
Collaborator

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

Description

https://jira.mongodb.org/browse/COMPASS-9499

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

Implement saving and restoring of session tabs.

Filed https://jira.mongodb.org/browse/COMPASS-9913 to track a couple of potential followups that I'm omitting from this PR

TODO: add test cases:

  • 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);
  • user declines restore tabs

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)

@syn-zhu
Copy link
Collaborator Author

syn-zhu commented Sep 30, 2025

haven't fixed the logging comment yet but tried to address the other comments, @gribnoysup can you lmk if this looks better?

@syn-zhu syn-zhu requested a review from gribnoysup October 1, 2025 05:26
Comment on lines 231 to 235
loadSavedWorkspaces: async () => {
throwIfNotTestEnv();
return Promise.reject();
},
restoreSavedWorkspaces: () => throwIfNotTestEnv,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a public interface of workspaces that you are adding this to, loading / restoring workspaces shouldn't be exposed through it: we shouldn't allow other parts of the app to trigger this process

@syn-zhu syn-zhu requested a review from gribnoysup October 11, 2025 18:29
Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Looks good, just one question + one optional suggestion :shipit:

return;
}

void connections.connect(connectionInfo);
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do we deal with failures to connect?

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

Now that the feature is behind a feature flag, nothing immediately blocking this PR from my side (there are some legit failures in the CI, so please take a look). But a couple of things definitely need follow-ups. Can you please open tickets for those?

One thing that we discussed, but is still not addressed is the "invisible" tab titles while connections are loading:

Kapture.2025-10-22.at.10.27.21.mp4

As discussed before, this is due ConnectionInfoProvider rendering nothing while connection is in progress. Instead I think we should allow some sort of fallback rendering there and do this for titles inside the workspace to make it clear that we actually restored the tabs, they are just not ready.

The e2e tests are also missing and for a feature like that we definitely want some.

@syn-zhu syn-zhu requested a review from gribnoysup October 24, 2025 20:40
@syn-zhu syn-zhu marked this pull request as ready for review October 28, 2025 18:50
@syn-zhu syn-zhu requested a review from a team as a code owner October 28, 2025 18:50
Copilot AI review requested due to automatic review settings October 28, 2025 18:50
@syn-zhu
Copy link
Collaborator Author

syn-zhu commented Oct 28, 2025

@gribnoysup Okay, I think I finally resolved everything. Check one last time?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements saving and restoring of session tabs in Compass, allowing users to reopen their previous workspace state when restarting the application. The feature is controlled by a new enableRestoreWorkspaces feature flag and includes a confirmation dialog before restoring tabs.

Key changes:

  • Added Zod schemas for workspace type validation and serialization
  • Implemented middleware to debounce and persist workspace state changes
  • Created storage service providers for both desktop and web platforms
  • Added thunk action to load and restore saved workspaces with connection validation

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/compass/src/app/components/entrypoint.tsx Added WorkspacesStorageServiceProviderDesktop to the provider chain
packages/compass-workspaces/src/types.ts Converted workspace type definitions to Zod schemas for validation and persistence
packages/compass-workspaces/src/stores/workspaces.ts Added RestoreWorkspaces action and loadSavedWorkspaces thunk for loading persisted state
packages/compass-workspaces/src/stores/workspaces-middleware.ts Created middleware to debounce and save workspace state changes
packages/compass-workspaces/src/services/workspaces-storage.tsx Defined storage service context and noop implementation for tests
packages/compass-workspaces/src/services/workspaces-storage-web.tsx Implemented Atlas-based storage provider for web platform
packages/compass-workspaces/src/services/workspaces-storage-desktop.tsx Implemented file-based storage provider for desktop platform
packages/compass-workspaces/src/index.ts Integrated storage service and middleware into plugin activation
packages/compass-web/src/entrypoint.tsx Added WorkspacesStorageServiceProviderWeb to the web provider chain
packages/compass-user-data/src/index.ts Exported IUserData as a class rather than just a type
packages/compass-preferences-model/src/feature-flags.ts Added enableRestoreWorkspaces feature flag
packages/atlas-service/src/atlas-service.ts Added savedWorkspaces to the list of supported resource types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

name: 'enableRestoreWorkspaces',
stage: 'development',
atlasCloudFeatureFlagName:
'DATA_EXPLORER_COMPASS_WEB_ENABLE_RESTORE_WORKSPACES',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

Very neat! The check failure in CI is legit: you need to add user-data dependency to the workspaces package, but otherwise LGTM for this part of work

@nbbeeken
Copy link
Collaborator

Is "no release notes" accurate? seems like compass user's would care and should know about this change

@syn-zhu
Copy link
Collaborator Author

syn-zhu commented Oct 30, 2025

Is "no release notes" accurate? seems like compass user's would care and should know about this change

it's feature flagged, I'm sure we'll add release notes when it's GA

@syn-zhu syn-zhu merged commit e964ca8 into main Oct 30, 2025
84 of 85 checks passed
@syn-zhu syn-zhu deleted the smnzhu/save-tab branch October 30, 2025 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat no release notes Fix or feature not for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants