Skip to content

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

Merged
bijin-bruno merged 4 commits into
usebruno:mainfrom
sid-bruno:feat/oss-active-workspace-tab
Jul 6, 2026
Merged

bijin-bruno merged 4 commits into
usebruno:mainfrom
sid-bruno:feat/oss-active-workspace-tab

Conversation

@sid-bruno

@sid-bruno sid-bruno commented Jul 6, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Ported from EE into OSS

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

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

  • New Features
    • Workspace-level active tabs are now saved and restored after restart, including supported scratch-collection tab types.
  • Bug Fixes
    • Workspace tab restoration now correctly restores the previously active workspace tab type when available, and avoids falling back to the overview tab unnecessarily.
  • Tests
    • Added Jest coverage for saving/restoring the active workspace tab type in snapshots.
    • Added an end-to-end test confirming the workspace “Environments” tab is restored as active after restart.

bijin-bruno
bijin-bruno previously approved these changes Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f1326bf2-561d-4793-81f4-eab7b10c7acc

📥 Commits

Reviewing files that changed from the base of the PR and between edfffac and 60da9a5.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/services/snapshot/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-electron/src/services/snapshot/index.js

Walkthrough

This PR adds activeWorkspaceTabType to workspace snapshots, validates and hydrates that field across snapshot utilities and Electron storage, and uses it during workspace switching to restore the matching workspace tab. Tests cover serialization and restart restoration.

Changes

Workspace Active Tab Type Persistence

Layer / File(s) Summary
Serialize active workspace tab type
packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js, packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.spec.js
Computes activeWorkspaceTabType for the active workspace, preserves it for inactive workspaces, writes it into serialized snapshots, and verifies the behavior in unit tests.
Normalize and validate activeWorkspaceTabType
packages/bruno-app/src/utils/snapshot/index.js, packages/bruno-electron/src/services/snapshot/index.js
Defines allowed workspace tab types, carries activeWorkspaceTabType through normalization and hydration, validates it in the Electron schema, and clears it on snapshot reset.
Restore workspace tab on switch
packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js, tests/snapshots/global-tabs.spec.ts
Uses the snapshot tab type to create the matching scratch tab during switchWorkspace, adjusts overview fallback behavior, and adds an app restart test for tab restoration.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • usebruno/bruno#7087: Shares the same workspace scratch tab and switchWorkspace area, including special handling for workspace-specific tab types.
  • usebruno/bruno#7794: Touches the snapshot normalization/hydration path that this change extends with activeWorkspaceTabType.
  • usebruno/bruno#8451: Modifies switchWorkspace in the same file and overlaps with the workspace-switch flow updated here.

Suggested reviewers: helloanoop, bijin-bruno, lohit-bruno, naman-bruno

Poem

A workspace tab went off to sleep,
Then woke up after restart to leap.
With type in tow, it found its place,
And came back home with steady grace.
Environments smiled, restored in time.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: tracking active workspace tab type in snapshots.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 activeWorkspaceTabType in the snapshot schema (electron service) and snapshot lookup hydration (app utils).
  • Record activeWorkspaceTabType during snapshot serialization and use it during switchWorkspace to 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.

Comment thread tests/snapshots/global-tabs.spec.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Clear activeWorkspaceTabType in resetSnapshot()
main:cache-clear emits internal:snapshot:reset, so this path is reachable. It resets lastActiveCollectionPathname but leaves activeWorkspaceTabType behind, 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 win

Tab-type allowlist duplicated across files without a shared source of truth.

WORKSPACE_TAB_TYPES here mirrors the keys of WORKSPACE_TAB_UID_SUFFIX_BY_TYPE in packages/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 win

Solid e2e coverage; a couple of small polish items per the Playwright testing guide.

  1. 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.
  2. Locators from buildCommonLocators are 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").
  3. 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

📥 Commits

Reviewing files that changed from the base of the PR and between b1f08b5 and 462a647.

📒 Files selected for processing (6)
  • packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js
  • packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.spec.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
  • packages/bruno-app/src/utils/snapshot/index.js
  • packages/bruno-electron/src/services/snapshot/index.js
  • tests/snapshots/global-tabs.spec.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/bruno-app/src/utils/snapshot/index.js (1)

33-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate constant definition across files in the same package.

WORKSPACE_TAB_UID_SUFFIX_BY_TYPE/WORKSPACE_TAB_TYPES are also defined identically in packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js (both within bruno-app). Consider exporting from a single source (e.g. this file) and importing it in serializeSnapshot.js to 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

📥 Commits

Reviewing files that changed from the base of the PR and between 462a647 and edfffac.

📒 Files selected for processing (4)
  • packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/serializeSnapshot.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
  • packages/bruno-app/src/utils/snapshot/index.js
  • packages/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

@bijin-bruno
bijin-bruno merged commit cbed13a into usebruno:main Jul 6, 2026
12 of 16 checks passed
ravindra-bruno pushed a commit to ravindra-bruno/bruno that referenced this pull request Jul 9, 2026
…o#8487)

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

* feat(snapshot): introduce workspace tab types and update related logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants