Skip to content

fix: set focus tab#6196

Open
Pragadesh-45 wants to merge 1 commit intousebruno:mainfrom
Pragadesh-45:fix/focus-tab
Open

fix: set focus tab#6196
Pragadesh-45 wants to merge 1 commit intousebruno:mainfrom
Pragadesh-45:fix/focus-tab

Conversation

@Pragadesh-45
Copy link
Copy Markdown
Contributor

@Pragadesh-45 Pragadesh-45 commented Nov 25, 2025

fixes: #6148

Description

This PR implements the logic for setting the focused tab

Contribution Checklist:

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

Summary by CodeRabbit

  • Bug Fixes
    • Collection Settings tab selection now reliably defaults to the overview tab when the previously selected tab becomes unavailable or invalid.
    • Request pane automatic tab switching has been improved to prevent unnecessary transitions to the Body tab when a focused request tab is already active.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 6, 2025

Walkthrough

Fixed a bug where request pane sub-tabs reverted to 'Body' after switching between requests. CollectionSettings now defaults to 'overview' when undefined; HttpRequestPane adds conditional guards to prevent auto-switching the Body tab when a focused tab already exists with a requestPaneTab, and tracks activeTabUid in dependencies.

Changes

Cohort / File(s) Summary
Tab Initialization
packages/bruno-app/src/components/CollectionSettings/index.js
Changed default tab resolution to fall back to 'overview' when collection.settingsSelectedTab is undefined or falsy.
Tab Switch Logic & Dependencies
packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js
Added conditional guard to auto-switch Body tab only when no focused tab exists or focused tab lacks requestPaneTab. Updated effect dependency array from empty to [activeTabUid] to track focused tab changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Logic changes require careful verification of tab state management and conditional guards
  • Two distinct areas affected with different concerns (default fallback vs. conditional switching)
  • Verify that activeTabUid dependency correctly triggers re-evaluations and doesn't cause unintended auto-switches

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🎯 Tabs no longer wander home,
They stay where you decree,
No more reverting as you roam—
Your scripts flow wild and free!
A guard clause brings the fix so true,
Dependencies tracked through and through. ✨

Pre-merge checks and finishing touches

✅ 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 'fix: set focus tab' directly describes the main fix implemented—adding focus tab logic to preserve sub-tab selection when switching between tabs.
Linked Issues check ✅ Passed The changes correctly address issue #6148 by implementing focus tab logic that preserves the selected sub-tab when switching between tabs, preventing the unwanted revert to 'Body'.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the focus tab issue: CollectionSettings default tab resolution and HttpRequestPane tab auto-switch guard logic are both necessary for preserving sub-tab state.
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

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/bruno-app/src/components/CollectionSettings/index.js (1)

21-21: Defaulting settings tab to 'overview' is correct; consider ?? for clearer intent

Using || here works because tab IDs are non-empty strings, but if settingsSelectedTab ever became '' this would silently fall back to 'overview'. Using nullish coalescing makes the fallback strictly about null/undefined:

-  const tab = collection.settingsSelectedTab || 'overview';
+  const tab = collection.settingsSelectedTab ?? 'overview';
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a8d787 and 9ffed77.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/CollectionSettings/index.js (1 hunks)
  • packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js (1 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/components/CollectionSettings/index.js
  • packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js (3)
packages/bruno-app/src/components/RequestTabPanel/index.js (2)
  • focusedTab (50-50)
  • activeTabUid (49-49)
packages/bruno-app/src/components/ResponsePane/index.js (3)
  • focusedTab (141-141)
  • selectTab (46-53)
  • activeTabUid (32-32)
packages/bruno-app/src/components/RequestPane/GraphQLRequestPane/index.js (3)
  • focusedTab (118-118)
  • selectTab (54-61)
  • activeTabUid (27-27)
⏰ 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 - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: CLI Tests
🔇 Additional comments (1)
packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js (1)

78-81: Auto-switch-to-Body effect is unreachable due to early guard condition using identical predicate

The early return at lines 78-81 checks !focusedTab || !focusedTab.uid || !focusedTab.requestPaneTab before the useEffect runs. Since the effect at lines 113-120 uses the same !focusedTab || !focusedTab.requestPaneTab condition, any render that reaches the effect already has this condition false, making the selectTab('body') fallback dead code.

To restore the intended behavior of auto-selecting Body only when requestPaneTab is missing (while preserving error handling for missing focused tabs), remove !focusedTab.requestPaneTab from the early return:

-  if (!focusedTab || !focusedTab.uid || !focusedTab.requestPaneTab) {
+  if (!focusedTab || !focusedTab.uid) {
     return <div className="pb-4 px-4">An error occurred!</div>;
   }

   useEffect(() => {
-    if (!focusedTab || !focusedTab.requestPaneTab) {
-      if (activeParamsLength === 0 && body.mode !== 'none') {
-        selectTab('body');
-      }
-    }
-  }, [activeTabUid]);
+    if (!focusedTab.requestPaneTab && activeParamsLength === 0 && body.mode !== 'none') {
+      selectTab('body');
+    }
+  }, [activeTabUid]);

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.

Sub tab always reverts to 'Body' after switching tabs

1 participant