Skip to content

fix: refactor default tab selection logic for correct tab persistance#6473

Merged
bijin-bruno merged 1 commit intousebruno:mainfrom
abhishek-bruno:fix/request-tabs-persistence
Dec 22, 2025
Merged

fix: refactor default tab selection logic for correct tab persistance#6473
bijin-bruno merged 1 commit intousebruno:mainfrom
abhishek-bruno:fix/request-tabs-persistence

Conversation

@abhishek-bruno
Copy link
Member

@abhishek-bruno abhishek-bruno commented Dec 21, 2025

Description

JIRA

The HttpRequestPane component had a useEffect that auto-selected the 'body' tab on mount for requests with a body and no params. The initialAutoSelectDone ref was component-instance specific, so when switching requests caused the component to remount, the ref reset and the auto-select ran again, overwriting the user's selection.

Fix: Moved the default tab logic to getDefaultRequestPaneTab() in utils/collections/index.js. This function is called only once when a tab is first created (via addTab). After that, the selected tab is stored in Redux and persists across component remounts.

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

  • Bug Fixes
    • Improved request pane tab selection logic to display the most relevant tab by default based on request content, rather than relying on automatic behavior on load.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 21, 2025

Walkthrough

Automatic tab selection was removed from the HttpRequestPane component and replaced with utility-based default tab logic. The getDefaultRequestPaneTab function now returns 'body' as the default tab when no enabled params exist and body mode is set, otherwise defaults to 'params'.

Changes

Cohort / File(s) Summary
Component logic removal
packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js
Removed useEffect hook for automatic tab selection on mount, removed initialAutoSelectDone guard (useRef), and removed React useEffect import. Tab selection now relies on user interaction only.
Utility logic addition
packages/bruno-app/src/utils/collections/index.js
Added conditional logic to getDefaultRequestPaneTab for http-request: returns 'body' tab when no enabled params exist and body mode is configured (not 'none'), otherwise defaults to 'params'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Logic refactored from component to utility—straightforward movement pattern
  • Conditional logic in utility is clear and testable
  • Limited surface area (2 files)

Possibly related PRs

  • improve: tabs design #6363 — Directly related; this PR removes the auto-select useEffect that was introduced in that earlier change.

Suggested labels

size/M

Suggested reviewers

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

Poem

Tabs no longer choose themselves,
Logic moves to utility shelves,
User's hand now leads the way,
Cleaner code to start the day. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: refactoring default tab selection logic by moving it from useEffect to getDefaultRequestPaneTab utility to fix tab persistence issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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.

@bijin-bruno bijin-bruno merged commit 3552801 into usebruno:main Dec 22, 2025
8 checks passed
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