Skip to content

add: workspace tabs - #6456

Merged
bijin-bruno merged 3 commits into
usebruno:mainfrom
naman-bruno:add/workspace-tabs
Dec 18, 2025
Merged

bijin-bruno merged 3 commits into
usebruno:mainfrom
naman-bruno:add/workspace-tabs

Conversation

@naman-bruno

@naman-bruno naman-bruno commented Dec 18, 2025 •

Copy link
Copy Markdown
Collaborator

Description

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

    • Tab-based workspace navigation powered by a global tab system: open, close, reorder, and focus tabs per workspace; permanent tabs (Overview, Global Environments) persist and initialize when switching workspaces.
    • Smooth horizontal scrolling with overflow chevrons, responsive behavior, and automatic tab initialization on workspace change.
  • Style

    • Redesigned tab UI and layouts (hover/active states, overflow visuals); legacy tab-bar styling removed.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 18, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Centralizes workspace tab UI into a Redux-driven system: adds a new workspaceTabs slice, wires it into the store, replaces WorkspaceHome's local tab UI with a WorkspaceTabs component and WorkspaceTab items, and moves tab styling into new styled-components files.

Changes

Cohort / File(s) Summary
WorkspaceHome Migration
packages/bruno-app/src/components/WorkspaceHome/StyledWrapper.js,
packages/bruno-app/src/components/WorkspaceHome/index.js
Removed local tab CSS and inline tab UI; WorkspaceHome now renders WorkspaceTabs and derives active tab from Redux workspaceTabs.
WorkspaceTabs Container & Styles
packages/bruno-app/src/components/WorkspaceTabs/index.js,
packages/bruno-app/src/components/WorkspaceTabs/StyledWrapper.js
New WorkspaceTabs component (permanent tabs init, ResizeObserver overflow detection, chevrons, horizontal scrolling, workspace filtering) and a new styled Wrapper for the tab list.
WorkspaceTab Item & Styles
packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js,
packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js
New WorkspaceTab component rendering icon, label, and close button (hidden for permanent tabs); dispatches closeWorkspaceTab on close.
Redux: workspaceTabs slice
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js
New Redux Toolkit slice managing tabs[] and activeTabUid with actions: addWorkspaceTab, focusWorkspaceTab, closeWorkspaceTab, closeWorkspaceTabs, closeAllWorkspaceTabs, reorderWorkspaceTabs, initializeWorkspaceTabs, setActiveWorkspaceTab. Enforces permanent-tab invariants and active-tab fallbacks.
Redux Store Integration
packages/bruno-app/src/providers/ReduxStore/index.js
Wire workspaceTabsReducer into root reducer as workspaceTabs.
Workspace activation hook
packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
After switching active workspace, dispatches initializeWorkspaceTabs({ workspaceUid, permanentTabs }) and setActiveWorkspaceTab({ workspaceUid, type: 'overview' }).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WorkspaceHome
    participant Redux
    participant WorkspaceTabs
    participant WorkspaceTab

    User->>WorkspaceHome: open/switch workspace
    WorkspaceHome->>Redux: dispatch initializeWorkspaceTabs(workspaceUid, permanentTabs)
    Redux->>Redux: ensure permanent tabs + set activeTabUid
    Redux-->>WorkspaceTabs: workspaceTabs state updated
    WorkspaceTabs->>WorkspaceTabs: measure overflow (ResizeObserver) & compute layout
    WorkspaceTabs->>WorkspaceTab: render each tab (props: tab, overflow)
    WorkspaceTab-->>User: display tab UI

    User->>WorkspaceTab: click tab
    WorkspaceTab->>Redux: dispatch focusWorkspaceTab(uid)
    Redux-->>WorkspaceTabs: activeTabUid updated -> re-render

    User->>WorkspaceTab: click close (non-permanent)
    WorkspaceTab->>Redux: dispatch closeWorkspaceTab(uid)
    Redux->>Redux: remove tab, compute fallback activeTabUid
    Redux-->>WorkspaceTabs: updated tabs -> re-render
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review Redux slice edge cases: deduplication in addWorkspaceTab, active-tab fallback logic in close* reducers.
  • Verify initializeWorkspaceTabs idempotency and permanent-tab creation.
  • Validate WorkspaceTabs ResizeObserver lifecycle, overflow math, and smooth scrolling.
  • Confirm WorkspaceTab close handling prevents events and respects permanent flag.

Possibly related PRs

Suggested reviewers

  • lohit-bruno
  • bijin-bruno
  • helloanoop

Tabs march from local state to shared,
Redux lines up badges and names prepared.
Resize hears whispers, chevrons point the way,
Close a tab gently — permanents stay.
🎉🧭

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add: workspace tabs' clearly and concisely summarizes the main change: introducing a new workspace tabs feature with Redux integration and related UI components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@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.

Actionable comments posted: 2

🧹 Nitpick comments (7)
packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js (1)

43-43: Verify theme fallback for light/dark mode compatibility.

The fallback rgba(0, 0, 0, 0.1) may not provide adequate contrast in light themes. Ensure props.theme.requestTabs.closeIconHoverBg is always defined, or use a theme-aware fallback.

packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js (1)

12-12: Remove unused isActive prop.

The isActive prop is received but never used in the component. If it's intended for future use, add a comment; otherwise, remove it to avoid confusion.

packages/bruno-app/src/components/WorkspaceTabs/StyledWrapper.js (2)

149-153: Remove duplicate permanent tab styling.

The .permanent-tab .close-icon rule duplicates the styling already defined in WorkspaceTab/StyledWrapper.js (lines 56-58). Remove this to avoid redundancy.

🔎 Apply this diff to remove duplication:
-      &.permanent-tab {
-        .close-icon {
-          display: none;
-        }
-      }
-
       &.short-tab {

112-114: Ensure theme provides all color fallbacks.

Multiple fallback colors (#ffffff, border colors) are hardcoded. Verify that props.theme.bg and props.theme.requestTabs.bottomBorder are always defined to maintain theme consistency across light/dark modes.

Also applies to: 129-130, 143-145

packages/bruno-app/src/components/WorkspaceTabs/index.js (3)

92-92: Extract magic number to named constant.

The value 150 appears to be a fixed offset for UI chrome. Extract it to a named constant at the file top for clarity.

🔎 Example:
+const TAB_LIST_OFFSET = 150; // Account for UI chrome (sidebar toggle, etc.)
+
 const WorkspaceTabs = ({ workspaceUid }) => {
   ...
-  const maxTablistWidth = screenWidth - effectiveSidebarWidth - 150;
+  const maxTablistWidth = screenWidth - effectiveSidebarWidth - TAB_LIST_OFFSET;

96-96: Extract scroll distance to named constant.

The scroll distance 120 is hardcoded in both directions. Extract to a constant for easier tuning.

🔎 Example:
+const SCROLL_DISTANCE = 120;
+
 const WorkspaceTabs = ({ workspaceUid }) => {
   ...
   const leftSlide = () => {
     scrollContainerRef.current?.scrollBy({
-      left: -120,
+      left: -SCROLL_DISTANCE,
       behavior: 'smooth'
     });
   };

   const rightSlide = () => {
     scrollContainerRef.current?.scrollBy({
-      left: 120,
+      left: SCROLL_DISTANCE,
       behavior: 'smooth'
     });
   };

Also applies to: 103-103


137-138: Verify unused WorkspaceTab props.

The hasOverflow and setHasOverflow props are passed but don't appear to be used in the WorkspaceTab component. If they're for future text truncation detection, add a comment; otherwise, remove them.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62b8784 and cf48efd.

📒 Files selected for processing (8)
  • packages/bruno-app/src/components/WorkspaceHome/StyledWrapper.js (0 hunks)
  • packages/bruno-app/src/components/WorkspaceHome/index.js (3 hunks)
  • packages/bruno-app/src/components/WorkspaceTabs/StyledWrapper.js (1 hunks)
  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js (1 hunks)
  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js (1 hunks)
  • packages/bruno-app/src/components/WorkspaceTabs/index.js (1 hunks)
  • packages/bruno-app/src/providers/ReduxStore/index.js (2 hunks)
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/bruno-app/src/components/WorkspaceHome/StyledWrapper.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/components/WorkspaceTabs/StyledWrapper.js
  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js
  • packages/bruno-app/src/components/WorkspaceHome/index.js
  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js
  • packages/bruno-app/src/providers/ReduxStore/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js
  • packages/bruno-app/src/components/WorkspaceTabs/index.js
🧠 Learnings (4)
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Styled Components are used as wrappers to define both self and children components style; Tailwind classes are used specifically for layout based styles

Applied to files:

  • packages/bruno-app/src/components/WorkspaceTabs/StyledWrapper.js
  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Styled Component CSS might also change layout but Tailwind classes shouldn't define colors

Applied to files:

  • packages/bruno-app/src/components/WorkspaceTabs/StyledWrapper.js
  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/components/WorkspaceTabs/StyledWrapper.js
  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js
  • packages/bruno-app/src/components/WorkspaceHome/index.js
  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js
  • packages/bruno-app/src/providers/ReduxStore/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js
  • packages/bruno-app/src/components/WorkspaceTabs/index.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Use styled component's theme prop to manage CSS colors and not CSS variables when in the context of a styled component or any React component using the styled component

Applied to files:

  • packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js
🧬 Code graph analysis (3)
packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js (5)
packages/bruno-app/src/components/WorkspaceHome/index.js (1)
  • dispatch (15-15)
packages/bruno-app/src/components/WorkspaceTabs/index.js (1)
  • dispatch (16-16)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (2)
  • tab (48-48)
  • tab (154-157)
packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js (1)
  • StyledWrapper (3-59)
packages/bruno-app/src/components/WorkspaceHome/StyledWrapper.js (1)
  • StyledWrapper (3-115)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (2)
packages/bruno-cli/src/runner/prepare-request.js (1)
  • find (4-4)
packages/bruno-app/src/components/WorkspaceTabs/index.js (1)
  • tabs (22-22)
packages/bruno-app/src/components/WorkspaceTabs/index.js (4)
packages/bruno-app/src/components/WorkspaceHome/index.js (3)
  • dispatch (15-15)
  • useSelector (16-16)
  • workspaceTabs (17-17)
packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js (2)
  • dispatch (13-13)
  • WorkspaceTab (12-42)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (5)
  • tabs (106-106)
  • workspaceUid (85-85)
  • tabUid (47-47)
  • tab (48-48)
  • tab (154-157)
packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.js (1)
  • StyledWrapper (3-59)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
🔇 Additional comments (5)
packages/bruno-app/src/components/WorkspaceHome/index.js (1)

149-160: LGTM! Good defensive null check.

The guard against missing activeTab is appropriate, even though the Redux initialization should ensure a tab exists. This prevents potential runtime errors during state transitions.

packages/bruno-app/src/providers/ReduxStore/index.js (1)

7-7: LGTM! Clean Redux integration.

The workspaceTabs reducer is properly imported and integrated into the store following the existing pattern.

Also applies to: 31-31

packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (3)

15-42: LGTM! Well-structured tab deduplication logic.

The addWorkspaceTab reducer correctly prevents duplicate tabs by checking both uid and type+workspace combinations before adding a new tab. This ensures a clean tab state.


46-63: LGTM! Proper permanent tab protection.

The closeWorkspaceTab reducer correctly prevents closing permanent tabs and handles active tab reassignment gracefully with the last tab fallback.


126-151: LGTM! Safe initialization pattern.

The initializeWorkspaceTabs reducer properly checks for existing permanent tabs before creating new ones, preventing duplicates when the component remounts or workspaceUid changes.

Comment on lines +119 to +123
<li className="select-none short-tab" onClick={leftSlide}>
<div className="flex items-center">
<IconChevronLeft size={18} strokeWidth={1.5} />
</div>
</li>

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.

🛠️ Refactor suggestion | 🟠 Major

Add keyboard navigation to chevron buttons.

The chevron scroll buttons lack keyboard accessibility. Add tabIndex={0} and onKeyDown handlers for Enter/Space keys.

🔎 Apply this diff for keyboard support:
           {showChevrons ? (
-            <li className="select-none short-tab" onClick={leftSlide}>
+            <li 
+              className="select-none short-tab" 
+              onClick={leftSlide}
+              role="button"
+              tabIndex={0}
+              aria-label="Scroll tabs left"
+              onKeyDown={(e) => {
+                if (e.key === 'Enter' || e.key === ' ') {
+                  e.preventDefault();
+                  leftSlide();
+                }
+              }}
+            >
               <div className="flex items-center">
                 <IconChevronLeft size={18} strokeWidth={1.5} />
               </div>
             </li>
           ) : null}

Apply similar changes to the right chevron (lines 146-150).

Also applies to: 146-150

🤖 Prompt for AI Agents
In packages/bruno-app/src/components/WorkspaceTabs/index.js around lines 119-123
(left chevron) and 146-150 (right chevron), the chevron buttons are not keyboard
accessible; add tabIndex={0} and an onKeyDown handler that calls the same
handler as onClick when the user presses Enter (key === 'Enter') or Space (key
=== ' ' or key === 'Spacebar'), and ensure you prevent default for Space to
avoid page scroll; keep the existing onClick handlers (leftSlide/rightSlide) and
reuse them inside onKeyDown so both mouse and keyboard activate the same
behavior.

Comment on lines +36 to +38
<div className="close-icon" onClick={handleCloseClick}>
<IconX size={14} strokeWidth={1.5} />
</div>

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.

🛠️ Refactor suggestion | 🟠 Major

Add accessibility attributes to close button.

The close icon lacks accessible labeling. Add aria-label and consider role="button" for better screen reader support.

🔎 Apply this diff to improve accessibility:
-      {!tab.permanent && (
-        <div className="close-icon" onClick={handleCloseClick}>
+      {!tab.permanent && (
+        <div 
+          className="close-icon" 
+          onClick={handleCloseClick}
+          role="button"
+          aria-label={`Close ${tab.label} tab`}
+          tabIndex={0}
+          onKeyDown={(e) => {
+            if (e.key === 'Enter' || e.key === ' ') {
+              e.preventDefault();
+              handleCloseClick(e);
+            }
+          }}
+        >
           <IconX size={14} strokeWidth={1.5} />
         </div>
       )}
🤖 Prompt for AI Agents
In packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js around
lines 36 to 38, the close icon lacks accessible labeling and keyboard support;
add accessibility attributes by giving the close container an aria-label (e.g.,
"Close tab"), role="button", and tabindex="0" and wire its onKeyDown to call
handleCloseClick for Enter/Space so keyboard users can activate it; also mark
the IconX as aria-hidden="true" since the container provides the accessible
name.

@bijin-bruno bijin-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Image

Loading back to above state when coming from manage workspace screen and also when switching between workspaces

@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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (1)

15-42: Document the singleton tab behavior.

The reducer activates an existing tab if one with the same type and workspaceUid already exists (lines 25-32), preventing duplicate tabs of the same type per workspace. This singleton pattern isn't immediately obvious and could benefit from a brief comment explaining this intentional design choice.

🔎 View suggested comment
 addWorkspaceTab: (state, action) => {
   const { uid, workspaceUid, type, label, permanent = false } = action.payload;

   const existingTab = find(state.tabs, (tab) => tab.uid === uid);
   if (existingTab) {
     state.activeTabUid = existingTab.uid;
     return;
   }

-  // Check if a tab of the same type already exists for this workspace
+  // Enforce singleton: only one tab of each type per workspace
+  // If a tab of this type already exists, activate it instead of creating a duplicate
   const existingTypeTab = find(
     state.tabs,
     (tab) => tab.workspaceUid === workspaceUid && tab.type === type
   );
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf48efd and f398ef1.

📒 Files selected for processing (2)
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (1 hunks)
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js
🧬 Code graph analysis (1)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (3)
packages/bruno-cli/src/runner/prepare-request.js (1)
  • find (4-4)
packages/bruno-app/src/components/WorkspaceTabs/index.js (2)
  • tabs (22-22)
  • workspaceTabs (53-53)
packages/bruno-app/src/components/WorkspaceHome/index.js (1)
  • workspaceTabs (17-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: Unit Tests
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
🔇 Additional comments (5)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (4)

104-125: LGTM – reorder logic is sound.

The splice-based reordering (lines 121-122) works correctly with Immer's mutation tracking. The permanent tab check (lines 112-115) and boundary validation (lines 117-119) properly guard against invalid operations.


46-63: LGTM – tab closing logic handles edge cases well.

All three close reducers properly:

  • Prevent closing permanent tabs
  • Update activeTabUid when the active tab is closed
  • Handle empty tab arrays gracefully

Also applies to: 64-83, 84-103


126-157: LGTM – initialization logic is well-structured.

The reducer correctly prevents duplicate permanent tabs (lines 130-145) and ensures an active tab is set for the workspace (lines 147-156).


1-9: LGTM – clean Redux Toolkit setup.

Imports, initial state, simple reducers, and exports all follow best practices and coding guidelines.

Also applies to: 43-45, 171-182

packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js (1)

15-15: LGTM – import is correctly placed.

The import follows the existing pattern and is properly located with other slice imports.

bijin-bruno
bijin-bruno previously approved these changes Dec 18, 2025

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (1)

158-179: Race condition resolved; consider improving label generation.

The defensive tab creation (lines 165-176) successfully addresses the race condition flagged in the previous review. The tab is now created if it doesn't exist, preventing silent failures.

However, the label generation on line 171 is simplistic—types like 'global-environments' would display as-is rather than a user-friendly label. Consider a helper function to format labels properly.

💡 Optional: Enhanced label formatting
+const formatTabLabel = (type) => {
+  const labelMap = {
+    'overview': 'Overview',
+    'global-environments': 'Global Environments'
+  };
+  return labelMap[type] || type.split('-').map(word => 
+    word.charAt(0).toUpperCase() + word.slice(1)
+  ).join(' ');
+};
+
 setActiveWorkspaceTab: (state, action) => {
   const { workspaceUid, type } = action.payload;
   let tab = find(
     state.tabs,
     (t) => t.workspaceUid === workspaceUid && t.type === type
   );

   if (!tab) {
     const newTabUid = `${workspaceUid}-${type}`;
     const newTab = {
       uid: newTabUid,
       workspaceUid,
       type,
-      label: type === 'overview' ? 'Overview' : type,
+      label: formatTabLabel(type),
       permanent: false
     };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f398ef1 and 5fb912e.

📒 Files selected for processing (2)
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (1 hunks)
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js
🧬 Code graph analysis (1)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (3)
packages/bruno-cli/src/runner/prepare-request.js (1)
  • find (4-4)
packages/bruno-app/src/components/WorkspaceTabs/index.js (2)
  • tabs (22-22)
  • workspaceTabs (53-53)
packages/bruno-app/src/components/WorkspaceHome/index.js (1)
  • workspaceTabs (17-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
🔇 Additional comments (8)
packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js (8)

1-9: LGTM!

Clean imports and well-structured initial state.


15-42: LGTM!

The duplicate prevention logic correctly enforces the "one tab per type per workspace" constraint. Focusing existing tabs instead of creating duplicates is good UX.


43-45: LGTM!

Simple and correct implementation.


46-63: LGTM!

Proper handling of permanent tabs and sensible active tab fallback logic.


64-83: LGTM!

Batch close operation correctly preserves permanent tabs and handles active tab transitions.


84-103: LGTM!

Flexible implementation that handles both workspace-specific and global tab closure while protecting permanent tabs.


104-125: LGTM!

Proper constraints on permanent tabs and clean reordering logic with edge case handling.


183-194: LGTM!

Proper exports following Redux Toolkit conventions.

Comment on lines +126 to +157
initializeWorkspaceTabs: (state, action) => {
const { workspaceUid, permanentTabs } = action.payload;

// Check if permanent tabs already exist for this workspace
const existingPermanentTabs = state.tabs.filter(
(t) => t.workspaceUid === workspaceUid && t.permanent
);

if (existingPermanentTabs.length === 0) {
// Add permanent tabs
permanentTabs.forEach((tab) => {
state.tabs.push({
uid: `${workspaceUid}-${tab.type}`,
workspaceUid,
type: tab.type,
label: tab.label,
permanent: true
});
});
}

const workspaceActiveTab = state.tabs.find(
(t) => t.uid === state.activeTabUid && t.workspaceUid === workspaceUid
);

if (!workspaceActiveTab) {
const workspaceTabs = state.tabs.filter((t) => t.workspaceUid === workspaceUid);
if (workspaceTabs.length > 0) {
state.activeTabUid = workspaceTabs[0].uid;
}
}
},

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.

🛠️ Refactor suggestion | 🟠 Major

Add defensive check for permanentTabs parameter.

If permanentTabs is undefined or not an array, the forEach on line 136 will throw a runtime error.

🔎 Apply this diff to add a defensive check:
 initializeWorkspaceTabs: (state, action) => {
   const { workspaceUid, permanentTabs } = action.payload;
+
+  if (!permanentTabs || !Array.isArray(permanentTabs)) {
+    return;
+  }

   // Check if permanent tabs already exist for this workspace
   const existingPermanentTabs = state.tabs.filter(
🤖 Prompt for AI Agents
In packages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.js around
lines 126 to 157, the reducer assumes action.payload.permanentTabs is an array
and calls forEach on it, which will throw if it's undefined or not an array;
guard this by checking Array.isArray(permanentTabs) (or coerce to an empty
array) before iterating — only push permanent tabs when permanentTabs is a valid
array, and otherwise skip that branch.

@bijin-bruno
bijin-bruno merged commit a1c4113 into usebruno:main Dec 18, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Jan 12, 2026
4 of 6 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Feb 10, 2026
6 tasks
maxenceleblanc pushed a commit to maxenceleblanc/curly_cats2 that referenced this pull request Jul 20, 2026
* add: workspace tabs

* fixes

* fixes
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.

2 participants