feat(snapshot): implement active workspace tab type tracking (#8487)

* feat(snapshot): implement active workspace tab type tracking and restoration

* feat(snapshot): introduce workspace tab types and update related logic
This commit is contained in:
Sid
2026-07-07 00:09:38 +05:30
committed by GitHub
parent 4ddf65c0c1
commit cbed13a346
6 changed files with 109 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ const yup = require('yup');
const SNAPSHOT_VERSION = '0.0.1';
const ENV_FILE_EXTENSIONS = ['bru', 'yml', 'yaml'];
const WORKSPACE_TAB_TYPES = ['workspaceOverview', 'workspaceEnvironments'];
const isObject = (value) => value && typeof value === 'object' && !Array.isArray(value);
@@ -71,6 +72,7 @@ const workspaceSchema = yup.object({
pathname: yup.string().required(),
environment: yup.string().defined(),
lastActiveCollectionPathname: yup.string().nullable(),
activeWorkspaceTabType: yup.string().oneOf([...WORKSPACE_TAB_TYPES, null]).nullable(),
sorting: yup.mixed().oneOf(['alphabetical', 'reverseAlphabetical', 'default']),
collections: yup.array().of(yup.string()).optional()
});
@@ -193,6 +195,7 @@ class SnapshotManager {
this.store.delete('activeWorkspacePath');
this.store.set('workspaces', (this.store.store?.workspaces ?? []).map((d) => {
d.lastActiveCollectionPathname = undefined;
d.activeWorkspaceTabType = undefined;
return d;
}));
this.store.set('collections', (this.store.store?.collections ?? []).map((d) => {
@@ -461,6 +464,9 @@ class SnapshotManager {
lastActiveCollectionPathname: typeof workspace.lastActiveCollectionPathname === 'string'
? workspace.lastActiveCollectionPathname
: null,
activeWorkspaceTabType: WORKSPACE_TAB_TYPES.includes(workspace.activeWorkspaceTabType)
? workspace.activeWorkspaceTabType
: null,
sorting: typeof workspace.sorting === 'string' ? workspace.sorting : 'default',
collections
};