Repository navigation
feat(snapshot): implement active workspace tab type tracking - #8487
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR adds ChangesWorkspace Active Tab Type Persistence
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR ports workspace-level active tab tracking into OSS by persisting the currently focused workspace tab type in the snapshot and restoring it on app restart / workspace switch.
Changes:
- Persist
activeWorkspaceTabTypein the snapshot schema (electron service) and snapshot lookup hydration (app utils). - Record
activeWorkspaceTabTypeduring snapshot serialization and use it duringswitchWorkspaceto restore the focused workspace tab. - Add unit + Playwright coverage to verify workspace tab restoration behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/snapshots/global-tabs.spec.ts | Adds an end-to-end restart test asserting the active workspace tab is restored. |
| packages/bruno-electron/src/services/snapshot/index.js | Extends snapshot schema/normalization to include activeWorkspaceTabType for workspaces. |
| packages/bruno-app/src/utils/snapshot/index.js | Hydrates activeWorkspaceTabType into snapshot lookup structures. |
| packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js | Restores focused workspace tab based on activeWorkspaceTabType during workspace switching. |
| packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.spec.js | Adds unit tests to verify serialization of activeWorkspaceTabType. |
| packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js | Records/preserves activeWorkspaceTabType in serialized snapshot output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-electron/src/services/snapshot/index.js (1)
193-208: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winClear
activeWorkspaceTabTypeinresetSnapshot()
main:cache-clearemitsinternal:snapshot:reset, so this path is reachable. It resetslastActiveCollectionPathnamebut leavesactiveWorkspaceTabTypebehind, which can survive a cache reset and be restored on the next launch. Clear it with the other workspace fields.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-electron/src/services/snapshot/index.js` around lines 193 - 208, resetSnapshot() is leaving activeWorkspaceTabType behind during snapshot cleanup, so the cached workspace state can persist across a reset. Update the workspace mutation in snapshot/index.js within resetSnapshot() to clear activeWorkspaceTabType alongside lastActiveCollectionPathname, using the same workspace object mapping that already handles workspaces and collections.
🧹 Nitpick comments (2)
packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js (1)
26-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTab-type allowlist duplicated across files without a shared source of truth.
WORKSPACE_TAB_TYPEShere mirrors the keys ofWORKSPACE_TAB_UID_SUFFIX_BY_TYPEinpackages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js(Lines 40-44). Both must be updated together whenever a new workspace tab type is added, or the serialize/restore contract silently drifts (e.g., a type serialized here but missing from the restore-side map would just be silently dropped on restore).Consider extracting a single shared constant (e.g. an object mapping type → uid suffix, with the allowlist derived via
Object.keys(...)) into a common module imported by both files.♻️ Suggested shared constant
// packages/bruno-app/src/utils/workspaceTabs.js export const WORKSPACE_TAB_UID_SUFFIX_BY_TYPE = { workspaceOverview: 'overview', workspaceEnvironments: 'environments' }; export const WORKSPACE_TAB_TYPES = new Set(Object.keys(WORKSPACE_TAB_UID_SUFFIX_BY_TYPE));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js` around lines 26 - 27, The workspace tab allowlist is duplicated between serializeSnapshot and the restore-side workspace action map, so move the tab type source of truth into a shared module and derive the allowlist from it. Update serializeSnapshot’s WORKSPACE_TAB_TYPES and the workspace actions’ WORKSPACE_TAB_UID_SUFFIX_BY_TYPE to import the same shared constant so adding a new workspace tab type only requires one change and serialization/restoration stay in sync.tests/snapshots/global-tabs.spec.ts (1)
59-85: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSolid e2e coverage; a couple of small polish items per the Playwright testing guide.
page.waitForTimeout(2000)at Line 72 repeats the same hardcoded sleep already present in the test above (Lines 33-34). Per the playwright testing guide, hardcoded waits should be avoided unless the underlying signal genuinely can't be awaited (e.g., a debounced snapshot write); if there's no observable "snapshot saved" signal, a short comment explaining why the sleep is necessary would help future maintainers.- Locators from
buildCommonLocatorsare used inline rather than assigned to variables (e.g.locators.tabs.requestTab('Environments')at Line 67), which the path instructions ask to avoid ("Use locator variables for locators").- Only a single assertion is made pre-restart (Line 68) and post-restart (Line 81); consider asserting on complementary state (e.g., that the Overview tab is not the active one, or that no duplicate Environments tab was created) to strengthen the regression signal, per "Use multiple assertions."
None of these block the PR — the restart flow, isolated
userDataPath, and scoped 15s timeout on the restored assertion are all correctly done.As per path instructions, "Try to reduce usage of
page.waitForTimeout();... Use locator variables for locators... Use multiple assertions."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/snapshots/global-tabs.spec.ts` around lines 59 - 85, The workspace-level active tab restart test needs a small Playwright cleanup: replace the hardcoded page.waitForTimeout(2000) with an awaited observable signal or add a brief comment in the test explaining why the delay is required, and update the inline buildCommonLocators usage in the "workspace-level active tab is restored after restart" flow to store locators in variables before calling tabs.requestTab and tabs.activeRequestTab. While touching this test, add one complementary assertion before or after restart in the same test to better cover the regression, using the existing buildCommonLocators and tabs helpers so the intent stays clear.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/bruno-electron/src/services/snapshot/index.js`:
- Around line 193-208: resetSnapshot() is leaving activeWorkspaceTabType behind
during snapshot cleanup, so the cached workspace state can persist across a
reset. Update the workspace mutation in snapshot/index.js within resetSnapshot()
to clear activeWorkspaceTabType alongside lastActiveCollectionPathname, using
the same workspace object mapping that already handles workspaces and
collections.
---
Nitpick comments:
In
`@packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js`:
- Around line 26-27: The workspace tab allowlist is duplicated between
serializeSnapshot and the restore-side workspace action map, so move the tab
type source of truth into a shared module and derive the allowlist from it.
Update serializeSnapshot’s WORKSPACE_TAB_TYPES and the workspace actions’
WORKSPACE_TAB_UID_SUFFIX_BY_TYPE to import the same shared constant so adding a
new workspace tab type only requires one change and serialization/restoration
stay in sync.
In `@tests/snapshots/global-tabs.spec.ts`:
- Around line 59-85: The workspace-level active tab restart test needs a small
Playwright cleanup: replace the hardcoded page.waitForTimeout(2000) with an
awaited observable signal or add a brief comment in the test explaining why the
delay is required, and update the inline buildCommonLocators usage in the
"workspace-level active tab is restored after restart" flow to store locators in
variables before calling tabs.requestTab and tabs.activeRequestTab. While
touching this test, add one complementary assertion before or after restart in
the same test to better cover the regression, using the existing
buildCommonLocators and tabs helpers so the intent stays clear.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 852350c1-266d-4ffb-9936-6eb0c41b1662
📒 Files selected for processing (6)
packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.jspackages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.jspackages/bruno-app/src/utils/snapshot/index.jspackages/bruno-electron/src/services/snapshot/index.jstests/snapshots/global-tabs.spec.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/bruno-app/src/utils/snapshot/index.js (1)
33-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate constant definition across files in the same package.
WORKSPACE_TAB_UID_SUFFIX_BY_TYPE/WORKSPACE_TAB_TYPESare also defined identically inpackages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js(both withinbruno-app). Consider exporting from a single source (e.g. this file) and importing it inserializeSnapshot.jsto avoid drift if the tab-type list changes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/snapshot/index.js` around lines 33 - 39, There is a duplicate definition of the workspace tab constants, so consolidate `WORKSPACE_TAB_UID_SUFFIX_BY_TYPE` and `WORKSPACE_TAB_TYPES` into a single source of truth in `packages/bruno-app/src/utils/snapshot/index.js` and import them into `serializeSnapshot.js` instead of redefining them there. Update the `serializeSnapshot` logic to reference the shared exports so both places stay in sync when tab types change. Keep the existing constant names and wire the middleware code to the shared values rather than maintaining a second copy.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/bruno-app/src/utils/snapshot/index.js`:
- Around line 33-39: There is a duplicate definition of the workspace tab
constants, so consolidate `WORKSPACE_TAB_UID_SUFFIX_BY_TYPE` and
`WORKSPACE_TAB_TYPES` into a single source of truth in
`packages/bruno-app/src/utils/snapshot/index.js` and import them into
`serializeSnapshot.js` instead of redefining them there. Update the
`serializeSnapshot` logic to reference the shared exports so both places stay in
sync when tab types change. Keep the existing constant names and wire the
middleware code to the shared values rather than maintaining a second copy.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 53519535-16f1-4c20-a5ad-f2237052ea4b
📒 Files selected for processing (4)
packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.jspackages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.jspackages/bruno-app/src/utils/snapshot/index.jspackages/bruno-electron/src/services/snapshot/index.js
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/bruno-electron/src/services/snapshot/index.js
- packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
- packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js
…o#8487) * feat(snapshot): implement active workspace tab type tracking and restoration * feat(snapshot): introduce workspace tab types and update related logic
Description
Ported from EE into OSS
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit