Skip to content

fix: scrollbar restoration - #7926

Merged
bijin-bruno merged 2 commits into
usebruno:mainfrom
shubh-bruno:fix/scroll-restoration
May 6, 2026
Merged

bijin-bruno merged 2 commits into
usebruno:mainfrom
shubh-bruno:fix/scroll-restoration

Conversation

@shubh-bruno

@shubh-bruno shubh-bruno commented May 6, 2026 •

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

  • Improvements
    • Scroll positions now persist across environment tabs, request parameters, and workspace environments, automatically restoring your location when switching between sections.

@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

This PR adds scroll position persistence across three table components—EnvironmentVariablesTable, QueryParams tables, and EnvironmentList—by integrating usePersistedState and useTrackScroll hooks to preserve and restore scroll positions per environment tab or workspace context.

Changes

Scroll Persistence Across Table Components

Layer / File(s) Summary
Hook Integration
packages/bruno-app/src/components/EnvironmentVariablesTable/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js
Import usePersistedState and useTrackScroll hooks to enable scroll state persistence.
State & Ref Management
packages/bruno-app/src/components/EnvironmentVariablesTable/index.js, packages/bruno-app/src/components/RequestPane/QueryParams/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js
Initialize persisted scroll state, refs, and track scroll changes via useTrackScroll for each component context (keyed by tab UID and workspace).
Table Component Wiring
packages/bruno-app/src/components/EnvironmentVariablesTable/index.js, packages/bruno-app/src/components/RequestPane/QueryParams/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js
Bind initialScroll/scrollerRef and initialTopMostItemIndex props to TableVirtuoso and EditableTable components to restore scroll position on render.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • usebruno/bruno#6843: Modifies EnvironmentVariablesTable with column-resizing behavior alongside this PR's scroll persistence.
  • usebruno/bruno#7797: Implements UI state persistence using the same usePersistedState/useTrackScroll subsystem and scope.
  • usebruno/bruno#6790: Addresses react-virtuoso integration and scroll state handling in the environment variables table.

Suggested reviewers

  • helloanoop
  • sid-bruno
  • bijin-bruno
  • lohit-bruno

📜 Three tables now remember where they were,
Scrolling back home with a persisted purr,
Tab by tab, workspace to space,
Your scroll position—always in the right place! ✨

🚥 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 accurately reflects the main change: implementing scroll position persistence across multiple table components and environment lists.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/bruno-app/src/components/RequestPane/QueryParams/index.js (2)

31-32: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Persistence key doesn't follow the persisted::<tabUid>:: scoping convention — stale data will accumulate.

The other two files in this PR use the explicit persisted::${activeTabUid}::... prefix format, and EnvironmentList even documents why: "so clearPersistedScope works." The QueryParams key request-params-scroll-${item.uid} skips that prefix, so the entry is never evicted when the containing tab is closed.

🛠️ Proposed fix
+ const activeTabUid = useSelector((state) => state.tabs.activeTabUid);
  const [scroll, setScroll] = usePersistedState({
-   key: `request-params-scroll-${item.uid}`,
+   key: `persisted::${activeTabUid}::request-params-scroll-${item.uid}`,
    default: 0
  });

Also applies to: 167-167, 200-200

🤖 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/components/RequestPane/QueryParams/index.js` around
lines 31 - 32, The persisted scroll key in QueryParams uses
"request-params-scroll-${item.uid}" which skips the required scoping prefix so
entries aren't evicted; update the usePersistedState call in QueryParams (where
usePersistedState is invoked with key) to prepend the scope like
`persisted::${activeTabUid}::request-params-scroll-${item.uid}` (and make the
same change for the other occurrences flagged around lines 167 and 200), so
clearPersistedScope can evict them; ensure you reference the activeTabUid/local
tab identifier used elsewhere in this component when building the key.

31-32: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use separate persistence keys for query-params and path-params tables.

Both EditableTable instances find the same scrollable parent (.flex-boundary in HeightBoundContainer) via findScrollParent(). Scrolling either table updates this shared container's position, which useTrackScroll persists to a single key. When users switch between tables, the scroll position from one table overwrites the other's.

Use request-params-scroll-query-${item.uid} and request-params-scroll-path-${item.uid} instead.

🤖 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/components/RequestPane/QueryParams/index.js` around
lines 31 - 32, The scroll position for both query and path params is persisted
to the same key; update the usePersistedState key used with useTrackScroll so
each table has its own key (e.g., use distinct keys like
`request-params-scroll-query-${item.uid}` and
`request-params-scroll-path-${item.uid}`) so that the two EditableTable
instances (see usePersistedState, useTrackScroll, wrapperRef and item.uid) do
not overwrite each other's saved scroll position; ensure the component that
renders the query table uses the query key and the one that renders the path
table uses the path key when calling usePersistedState and passing initialValue
to useTrackScroll.
🤖 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.

Inline comments:
In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js`:
- Line 65: Remove or update the stale inline comment "// We need to add
<EditableTable/> component for env table" in the EnvironmentVariablesTable
component: replace it with a short, accurate note that the env table uses
TableVirtuoso and that the scroll wiring is handled below (or simply delete the
comment). This touches the comment near the top of
packages/bruno-app/src/components/EnvironmentVariablesTable/index.js and
references the use of TableVirtuoso rather than EditableTable.

In
`@packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js`:
- Around line 59-62: The persisted scroll key uses activeTabUid which becomes
"null" for workspace home and never gets cleared by clearPersistedScope(tabUid),
leaving orphaned localStorage entries; update the EnvironmentList to avoid
persisting when activeTabUid is null by conditionally using usePersistedState
only when activeTabUid != null (e.g., fall back to a regular useState for
envListScroll/setEnvListScroll), or alternatively call clearPersistedScope(null)
from the workspace home unmount/cleanup to remove the "persisted::null::..."
entries; modify the code around usePersistedState, envListScroll,
setEnvListScroll and add an effect to call clearPersistedScope(null) if you
prefer explicit cleanup.

---

Outside diff comments:
In `@packages/bruno-app/src/components/RequestPane/QueryParams/index.js`:
- Around line 31-32: The persisted scroll key in QueryParams uses
"request-params-scroll-${item.uid}" which skips the required scoping prefix so
entries aren't evicted; update the usePersistedState call in QueryParams (where
usePersistedState is invoked with key) to prepend the scope like
`persisted::${activeTabUid}::request-params-scroll-${item.uid}` (and make the
same change for the other occurrences flagged around lines 167 and 200), so
clearPersistedScope can evict them; ensure you reference the activeTabUid/local
tab identifier used elsewhere in this component when building the key.
- Around line 31-32: The scroll position for both query and path params is
persisted to the same key; update the usePersistedState key used with
useTrackScroll so each table has its own key (e.g., use distinct keys like
`request-params-scroll-query-${item.uid}` and
`request-params-scroll-path-${item.uid}`) so that the two EditableTable
instances (see usePersistedState, useTrackScroll, wrapperRef and item.uid) do
not overwrite each other's saved scroll position; ensure the component that
renders the query table uses the query key and the one that renders the path
table uses the path key when calling usePersistedState and passing initialValue
to useTrackScroll.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd7cfb62-1130-4e9d-b88e-c1855d18423f

📥 Commits

Reviewing files that changed from the base of the PR and between 973ca18 and 1a38f9f.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/EnvironmentVariablesTable/index.js
  • packages/bruno-app/src/components/RequestPane/QueryParams/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js

@bijin-bruno
bijin-bruno merged commit ece742c into usebruno:main May 6, 2026
10 checks passed
sharan-bruno pushed a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
* fix: restore scrollbar

* chore: remove comments

---------

Co-authored-by: shubh-bruno <[email protected]>
sid-bruno added a commit to sid-bruno/bruno that referenced this pull request Aug 21, 2026
* feat: implement proxy-aware API fetching using axios instance (usebruno#7767)

* fix(cli): skip headers with empty name when building request (usebruno#7869)

* Revert "feat: ws multi message (usebruno#7719)" (usebruno#7921)

This reverts commit a305b41.

* fix: remove dragbar z-index that was bleeding through modals (usebruno#7924)

* feat: ui state snapshots (usebruno#7794)

* feat(snapshot): add session snapshot persistence and restoration

- Add snapshot middleware to persist UI state (tabs, workspaces, environments)
- Add SnapshotManager service in electron for atomic snapshot storage
- Add accessor-based tab serialization using pathname for reliable restoration
- Add loading states for tabs while collections are mounting
- Add hydrateTabs to restore tabs from snapshots on app load
- Add devTools state persistence (console open/height/tab)

* fix(snapshot): preserve unloaded collections and fix async serialization

Make serializeSnapshot async to fetch existing snapshot before saving,
ensuring collections not currently loaded in Redux are preserved. Fix
activeTab serialization to pass collection object instead of just UID.

* refactor(snapshot): rewrite storage to map-based schema with granular IPC

Replace array-based snapshot storage with key-value maps keyed by pathname
for O(1) lookups. Separate tabs into their own top-level map, decoupled
from collections.

- Rewrite SnapshotManager with map-based schema and granular read/write
  methods (getWorkspace, getTabs, setCollection, removeWorkspace, etc.)
- Add 12 granular IPC handlers (renderer:snapshot:*) replacing 4 coarse ones
- Update middleware serialization to produce maps; remove activeCollectionUidCache
  in favor of lastActiveCollectionPathname on workspace objects
- Fix mountCollection passing collectionUid instead of collection to restoreTabs
- Preserve non-active workspace state from existing snapshot on save

* wip

* refactor: allow migration of old snapshot

* refactor: trim down redundancy

* fix: for workspace state

* feat: fix for finalised schema

* fix: schema cleanup

* chore: simplify

* chore: wait on hydration to finish

* chore: snapshot changes to schema

* chore: fix typo

* fix: switch schema for saving and restoring extras

* chore: correctness changes

* chore: add active in the schema check

* chore: fix lint

* chore: comments

* chore: make writes async

* fix: sorting and cross workspace shared collection fixes

* chore: add version

* fix: wait on hydration

* chore: fix backward compat for ui-snapshots

* chore: dead code removal

* Fix optional chaining in snapshot lookup

---------

Co-authored-by: Chirag Chandrashekhar <[email protected]>

* fix: scrollbar restoration (usebruno#7926)

* fix: restore scrollbar

* chore: remove comments

---------

Co-authored-by: shubh-bruno <[email protected]>

* fix: message in ConnectGitRemote and RemoveGitRemote (usebruno#7929)

* fix: allow empty header names in CLI and gRPC request preparation (usebruno#7925)

* refactor: remove idx from HeaderList, extend ReadOnlyPropertyList, add positional method translations (usebruno#7917)

* refactor: remove 'idx' method from headerList and update related tests

- Eliminated the 'idx' method from both req.headerList and res.headerList to streamline header management.
- Updated associated tests and documentation to reflect the removal, ensuring clarity in the API usage and maintaining consistency across the header management system.

* refactor: block unimplemented HeaderList methods with error messages

- Added error handling for unimplemented methods in HeaderList, including idx, add, upsert, remove, each, prepend, insert, and insertAfter.
- Each method now throws a descriptive error indicating the appropriate alternative methods to use, enhancing clarity in the API and guiding users towards correct usage.

* refactor: update error message in idx() method of HeaderList for clarity

- Modified the error message in the idx() method to guide users towards using all()[index] or get(name) instead of the unsupported idx() method, enhancing the clarity of the API documentation.

* refactor: update HeaderList to extend ReadOnlyPropertyList and remove unimplemented methods

- Changed HeaderList to extend ReadOnlyPropertyList instead of PropertyList, streamlining its functionality.
- Removed unimplemented methods (prepend, insert, insertAfter) from HeaderList, clarifying the API and guiding users towards using supported methods.
- Updated related tests to reflect these changes, ensuring consistency and accuracy in header management.

* test: add translations for pm.request.headers methods in request tests

- Introduced new tests to validate the translation of pm.request.headers methods (prepend, insert, insertAfter) to their corresponding req.headerList.append method.
- Enhanced existing tests to ensure accurate conversion and functionality of header management in the Bruno converters.

* feat: enhance header translation methods for pm.request.headers

- Added translations for additional pm.request.headers methods (get, has, one, all, count, indexOf, find, filter, each, map, reduce, toObject, clear) to their corresponding req.headerList methods.
- Updated tests to validate the new translations and ensure accurate header management functionality in the Bruno converters.

---------

Co-authored-by: Pragadesh-45 <[email protected]>
Co-authored-by: Sid <[email protected]>
Co-authored-by: gopu-bruno <[email protected]>
Co-authored-by: Chirag Chandrashekhar <[email protected]>
Co-authored-by: shubh-bruno <[email protected]>
Co-authored-by: shubh-bruno <[email protected]>
Co-authored-by: naman-bruno <[email protected]>
Co-authored-by: sanish chirayath <[email protected]>
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