Repository navigation
add: workspace tabs - #6456
add: workspace tabs#6456
Conversation
WalkthroughCentralizes workspace tab UI into a Redux-driven system: adds a new Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 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.
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. Ensureprops.theme.requestTabs.closeIconHoverBgis always defined, or use a theme-aware fallback.packages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.js (1)
12-12: Remove unusedisActiveprop.The
isActiveprop 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-iconrule duplicates the styling already defined inWorkspaceTab/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 thatprops.theme.bgandprops.theme.requestTabs.bottomBorderare 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
150appears 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
120is 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
hasOverflowandsetHasOverflowprops 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
📒 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()notfunc ()
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.jspackages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.jspackages/bruno-app/src/components/WorkspaceHome/index.jspackages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.jspackages/bruno-app/src/providers/ReduxStore/index.jspackages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.jspackages/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.jspackages/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.jspackages/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.jspackages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/StyledWrapper.jspackages/bruno-app/src/components/WorkspaceHome/index.jspackages/bruno-app/src/components/WorkspaceTabs/WorkspaceTab/index.jspackages/bruno-app/src/providers/ReduxStore/index.jspackages/bruno-app/src/providers/ReduxStore/slices/workspaceTabs.jspackages/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
activeTabis 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.
| <li className="select-none short-tab" onClick={leftSlide}> | ||
| <div className="flex items-center"> | ||
| <IconChevronLeft size={18} strokeWidth={1.5} /> | ||
| </div> | ||
| </li> |
There was a problem hiding this comment.
🛠️ 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.
| <div className="close-icon" onClick={handleCloseClick}> | ||
| <IconX size={14} strokeWidth={1.5} /> | ||
| </div> |
There was a problem hiding this comment.
🛠️ 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.
There was a problem hiding this comment.
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
typeandworkspaceUidalready 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
📒 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()notfunc ()
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.jspackages/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.jspackages/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
activeTabUidwhen 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.
There was a problem hiding this comment.
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
📒 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()notfunc ()
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.
| 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; | ||
| } | ||
| } | ||
| }, |
There was a problem hiding this comment.
🛠️ 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.
* add: workspace tabs * fixes * fixes

Description
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
New Features
Style
✏️ Tip: You can customize this high-level summary in your review settings.