Skip to content

feat: request restore - #7948

Merged
sid-bruno merged 2 commits into
usebruno:mainfrom
sid-bruno:feat/snapshot-request-restore
May 7, 2026
Merged

sid-bruno merged 2 commits into
usebruno:mainfrom
sid-bruno:feat/snapshot-request-restore

Conversation

@sid-bruno

@sid-bruno sid-bruno commented May 7, 2026 •

Copy link
Copy Markdown
Collaborator

Description

JIRA

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

Release Notes

  • Bug Fixes

    • Request tabs now correctly synchronize with collection items, ensuring proper tab state when navigating between different requests
  • Tests

    • Added comprehensive automated tests to verify request pane tab interactivity and UI state restoration after application restart
    • Tests validate persistence behavior across different request types to ensure reliable user experience

@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR implements tab UID synchronization in the RequestTab component to handle cases where a tab's pathname resolves to a collection item with a different UID, followed by comprehensive snapshot tests that verify request-pane tab interactivity is preserved across Electron app restarts for multiple request types.

Changes

Tab UID Synchronization & Snapshot Testing

Layer / File(s) Summary
Tab UID Synchronization Logic
packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
Imports syncTabUid action and adds a useEffect that detects request-type tabs, resolves pathname to a collection item, and dispatches syncTabUid when the resolved item's UID differs from the tab's current UID.
Snapshot Tests
tests/snapshots/basic.spec.ts, tests/snapshots/request-pane-interactivity.spec.ts
Four new snapshot tests verify request-pane tab interactivity persists across Electron restart for generic requests, GraphQL, gRPC, and WebSocket request types. Each test creates a request, persists it through close/restart, and asserts tabs remain visible and clickable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • usebruno/bruno#7942: Implements tab UID/pathname resolution and deserialization logic that pairs with this PR's runtime synchronization for complete tab restoration.

Suggested reviewers

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

Poem

📑 Tab UIDs dance and realign,
When pathnames shift, they now align,
Through electron restarts they persist,
Each pane interactive—none are missed! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'feat: request restore' is vague and doesn't clearly convey what is being restored or how requests are restored. Make the title more specific, e.g., 'feat: sync tab UIDs on request restore' or 'feat: restore request tab state after app restart' to better reflect the actual implementation.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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

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.

@sid-bruno
sid-bruno marked this pull request as ready for review May 7, 2026 15:29
@sid-bruno
sid-bruno requested a review from helloanoop as a code owner May 7, 2026 15:29
Copilot AI review requested due to automatic review settings May 7, 2026 15:29

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

🧹 Nitpick comments (2)
tests/snapshots/basic.spec.ts (1)

820-821: ⚡ Quick win

Avoid hardcoded 2s waits before restart in snapshot tests.

These sleeps can still race debounce timing and slow the suite. Use a condition-based wait (polling persisted snapshot/readiness) before closeElectronApp.

As per coding guidelines: “Try to reduce usage of page.waitForTimeout(); in code unless absolutely necessary and the locator cannot be found using existing expect() playwright calls”.

Also applies to: 870-871

🤖 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 `@tests/snapshots/basic.spec.ts` around lines 820 - 821, The test uses fixed 2s
sleeps (page.waitForTimeout(2000)) before calling closeElectronApp which can
cause flakiness and slow the suite; replace those hardcoded waits with a
condition-based poll that waits for a deterministic snapshot/readiness signal
(e.g., wait until persisted snapshot file exists, a specific DOM/state marker is
present, or a readiness API returns true) before invoking closeElectronApp;
update the two occurrences around lines referenced to use a polling loop with
timeout that checks the snapshot/readiness condition instead of
page.waitForTimeout, and reuse existing helpers or add a small helper (e.g.,
waitForSnapshotPersisted or waitForAppReady) to keep tests deterministic.
tests/snapshots/request-pane-interactivity.spec.ts (1)

37-38: ⚡ Quick win

Replace fixed sleeps with deterministic persistence checks.

page.waitForTimeout(2000) will be flaky under slower/faster CI. Prefer an explicit condition (e.g., polling for snapshot state/file update) before closing the app.

As per coding guidelines: “Try to reduce usage of page.waitForTimeout(); in code unless absolutely necessary and the locator cannot be found using existing expect() playwright calls”.

Also applies to: 86-87

🤖 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 `@tests/snapshots/request-pane-interactivity.spec.ts` around lines 37 - 38, The
test currently uses page.waitForTimeout(2000) before calling
closeElectronApp(app), which is flaky; replace these fixed sleeps (both the
occurrence around page.waitForTimeout and the similar occurrences at lines
86-87) with a deterministic persistence check — e.g., poll for the snapshot
state or file update that the test expects (using page.waitForSelector,
expect.poll, or a custom waitForFunction that checks the snapshot file/DB/state)
and only call closeElectronApp(app) after that condition is satisfied; update
the test code around the page.waitForTimeout calls and the closeElectronApp
invocation to await that explicit condition instead of a fixed timeout.
🤖 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.

Nitpick comments:
In `@tests/snapshots/basic.spec.ts`:
- Around line 820-821: The test uses fixed 2s sleeps (page.waitForTimeout(2000))
before calling closeElectronApp which can cause flakiness and slow the suite;
replace those hardcoded waits with a condition-based poll that waits for a
deterministic snapshot/readiness signal (e.g., wait until persisted snapshot
file exists, a specific DOM/state marker is present, or a readiness API returns
true) before invoking closeElectronApp; update the two occurrences around lines
referenced to use a polling loop with timeout that checks the snapshot/readiness
condition instead of page.waitForTimeout, and reuse existing helpers or add a
small helper (e.g., waitForSnapshotPersisted or waitForAppReady) to keep tests
deterministic.

In `@tests/snapshots/request-pane-interactivity.spec.ts`:
- Around line 37-38: The test currently uses page.waitForTimeout(2000) before
calling closeElectronApp(app), which is flaky; replace these fixed sleeps (both
the occurrence around page.waitForTimeout and the similar occurrences at lines
86-87) with a deterministic persistence check — e.g., poll for the snapshot
state or file update that the test expects (using page.waitForSelector,
expect.poll, or a custom waitForFunction that checks the snapshot file/DB/state)
and only call closeElectronApp(app) after that condition is satisfied; update
the test code around the page.waitForTimeout calls and the closeElectronApp
invocation to await that explicit condition instead of a fixed timeout.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4e90e3be-3004-49f5-b74c-4299b5e8ef31

📥 Commits

Reviewing files that changed from the base of the PR and between 415b75d and 0070cac.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
  • tests/snapshots/basic.spec.ts
  • tests/snapshots/request-pane-interactivity.spec.ts

Copilot AI 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.

Pull request overview

Adds a safeguard to keep restored request tabs correctly wired to their underlying request items after app restart, and introduces Playwright snapshot tests to prevent regressions where request-pane tabs become non-interactive after restore.

Changes:

  • Sync restored request tab uid to the resolved collection item uid when a restored tab was created with a pathname fallback.
  • Add snapshot e2e coverage for request-pane tab interactivity after restart (HTTP/GraphQL/gRPC/WebSocket).
  • Extend existing snapshot suite with additional restore/interactivity scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/bruno-app/src/components/RequestTabs/RequestTab/index.js Synces restored request tab UID to the real request UID once the item is resolvable, fixing post-restore interactivity issues.
tests/snapshots/request-pane-interactivity.spec.ts New snapshot e2e tests for gRPC and WebSocket request-pane tab interactivity after restart.
tests/snapshots/basic.spec.ts Adds snapshot e2e coverage for basic HTTP and GraphQL request-pane tab interactivity after restart.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/snapshots/basic.spec.ts Resolved
@sid-bruno
sid-bruno merged commit 8552b47 into usebruno:main May 7, 2026
16 of 18 checks passed
sharan-bruno pushed a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jun 4, 2026
2 of 4 tasks
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.

3 participants