Skip to content

fix: unify OpenAPI comparison logic, improve OpenAPI Sync tab banner consistency and error handling#7483

Merged
bijin-bruno merged 1 commit intousebruno:mainfrom
abhishek-bruno:fix/openapi-sync-issues-v3
Mar 13, 2026
Merged

fix: unify OpenAPI comparison logic, improve OpenAPI Sync tab banner consistency and error handling#7483
bijin-bruno merged 1 commit intousebruno:mainfrom
abhishek-bruno:fix/openapi-sync-issues-v3

Conversation

@abhishek-bruno
Copy link
Member

@abhishek-bruno abhishek-bruno commented Mar 13, 2026

Description

JIRA

  • Fix banner/content mismatch in Spec Updates tab where "spec has been updated" banner showed with empty endpoint list below (caused by hash-based vs endpoint-count comparison)
  • Unify field-level comparison (compareRequestFields) across all three drift computations (specDrift, collectionDrift, remoteDrift)
  • Show version transition info (e.g. v1.0 → v2.0) in Overview banner and details grid
  • Wire version and last sync date into Collection Changes banner (was dead code)
  • Show error-appropriate empty state in Spec Updates tab instead of misleading "No updates from the spec" checkmark when fetch fails
  • Fix stale closure bug in reloadDrift using ref
  • Add loading states to Collection Changes and Spec Updates tabs
  • Add "Update connection settings" button to error banners across all tabs
  • Clean up dead code: unused imports, unreachable branches, vestigial removedIds

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

  • New Features

    • Added version delta display (e.g., v1 → v2) in sync status and details sections
    • Added "View Details" button to navigate to spec updates
  • Improvements

    • Enhanced endpoint comparison with field-by-field analysis for more accurate change detection
    • Improved error messaging for update check failures
    • Refined endpoint categorization logic to distinguish spec-driven changes from local edits
    • Updated modified endpoint badge styling for clearer visual distinction

… feedback

- Removed unused props and improved error handling in OpenAPISyncTab components.
- Updated messaging in CollectionStatusSection and OverviewSection for clarity.
- Enhanced the SpecDiffModal to provide better visual feedback on changes.
- Refactored sync flow logic to ensure accurate endpoint categorization and improved performance.
- Added new utility functions for better handling of spec changes and endpoint comparisons.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

Walkthrough

This PR significantly refactors the OpenAPI sync feature, introducing version delta display across multiple UI components, refining three-way merge categorization to exclude local-only updates from spec-driven endpoints, and replacing MD5-based comparison with field-by-field request analysis in the Electron backend. The changes span from UI banner logic through sync hooks to core IPC processing, with signature modifications to key components.

Changes

Cohort / File(s) Summary
Banner & UI Components
OpenAPISyncTab/CollectionStatusSection/index.js, OpenAPISyncTab/OverviewSection/index.js, OpenAPISyncTab/SpecStatusSection/index.js, OpenAPISyncTab/SpecDiffModal/index.js
Added version delta display (vX → vY) to banners, removed StatusBadge and fileNotFound prop from OverviewSection, added error state UI with IconAlertTriangle in SpecStatusSection, changed modified badge from info to warning style, and introduced "View Details" button for spec updates.
Sync Categorization Logic
OpenAPISyncTab/SyncReviewPage/index.js, OpenAPISyncTab/hooks/useSyncFlow.js
Refined three-way merge to exclude local-only updates from spec-driven categories; updated specAddedEndpoints and specRemovedEndpoints to be truly spec-driven; removed removedIds from performSync signature and default selections; introduced spec-based tracking with specAddedIds/specRemovedIds.
Sync State Management
OpenAPISyncTab/hooks/useOpenAPISync.js, OpenAPISyncTab/index.js
Added specDriftRef for closure tracking; enhanced reloadDrift to async-refresh remote drift via IPC when newSpec exists; removed fileNotFound prop usage in OverviewSection invocation.
Backend Comparison Refactor
packages/bruno-electron/src/ipc/openapi-sync.js
Replaced MD5-hash-based change detection with modular field-by-field comparison; introduced extractJsonKeys and compareRequestFields helpers; refactored spec comparison flow to analyze params, headers, body, auth, and form fields for more granular diff reporting.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • PR #7378 — Modifies useSyncFlow hook signature and sync logic, overlapping directly with performSync changes in this PR.
  • PR #7467 — Overlaps on same OpenAPISyncTab components and electron IPC logic; both PRs refactor sync behavior.
  • PR #7408 — Touches CollectionStatusSection, useOpenAPISync, and openapi-sync.js; related refactoring in OpenAPI sync pipeline.

Suggested labels

size/XXL

Suggested reviewers

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

Poem

🔄 The sync flow awakens with delta in sight,
Version echoes dance from left to right,
Field-by-field truths replace the hash's old sway,
Three-way merges refined—spec leads the way,
Bruno's sync grows wiser, brighter, more tight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main objectives of this multi-file changeset: unifying OpenAPI comparison logic and improving banner consistency/error handling across the OpenAPI Sync tab.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
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: 2

Caution

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

⚠️ Outside diff range comments (1)
packages/bruno-app/src/components/OpenAPISyncTab/SpecStatusSection/index.js (1)

50-59: ⚠️ Potential issue | 🟠 Major

Treat metadata-only spec drift as a pending update.

This branch only considers added/modified/removed endpoints. If the remote spec changes just info.version, info.title, or info.description, the IPC layer still returns hasChanges: true, but this component falls through to the “No updates from the spec” path and gives the user no way to refresh the stored spec file. The same condition should drive the other overview/pending surfaces too, otherwise the UI will drift again.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/OpenAPISyncTab/SpecStatusSection/index.js`
around lines 50 - 59, Update the pending-update detection in SpecStatusSection
by expanding the hasEndpointUpdates check (the const hasEndpointUpdates and its
branch) to also treat metadata-only changes as a pending update: include
specDrift.hasChanges (or explicitly check differing metadata like
specDrift.storedVersion !== specDrift.newVersion and/or
specDrift.info?.version/title/description differences) so the branch returns the
warning variant and actions when only metadata changed, not just when
added/modified/removed endpoint arrays are non-empty.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/src/components/OpenAPISyncTab/hooks/useSyncFlow.js`:
- Around line 17-25: The confirm modal is showing updates from raw
remoteDrift.modified while the actual sync payload filters add/remove to
spec-driven endpoints, causing a mismatch; in performSync, derive the update
list using the same filtered source used by confirmGroups (e.g., use
specUpdates, resolvedConflicts or a filteredRemoteModified variable) instead of
raw remoteDrift.modified so the confirmation dialog only promises changes that
will be applied; update any references in performSync and the confirm modal
construction to use that filtered set (and ensure newToCollection, specUpdates,
resolvedConflicts, localChangesToReset are used consistently).

In `@packages/bruno-electron/src/ipc/openapi-sync.js`:
- Around line 540-546: The header comparison in compareRequestFields() currently
maps header names directly, causing case-sensitive mismatches; normalize header
names (e.g., convert to lower-case and trim) when building specHeaderNames and
actualHeaderNames before sorting and JSON-stringifying so that headers like
"Content-Type" and "content-type" are treated as equal; update the logic that
produces specHeaderNames and actualHeaderNames (and any other header-name
comparisons) to use the normalized names for the diff check.

---

Outside diff comments:
In `@packages/bruno-app/src/components/OpenAPISyncTab/SpecStatusSection/index.js`:
- Around line 50-59: Update the pending-update detection in SpecStatusSection by
expanding the hasEndpointUpdates check (the const hasEndpointUpdates and its
branch) to also treat metadata-only changes as a pending update: include
specDrift.hasChanges (or explicitly check differing metadata like
specDrift.storedVersion !== specDrift.newVersion and/or
specDrift.info?.version/title/description differences) so the branch returns the
warning variant and actions when only metadata changed, not just when
added/modified/removed endpoint arrays are non-empty.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c4208ca-25fa-4532-b64f-d1d797d8e4f0

📥 Commits

Reviewing files that changed from the base of the PR and between 1ab296f and bc1ef00.

📒 Files selected for processing (9)
  • packages/bruno-app/src/components/OpenAPISyncTab/CollectionStatusSection/index.js
  • packages/bruno-app/src/components/OpenAPISyncTab/OverviewSection/index.js
  • packages/bruno-app/src/components/OpenAPISyncTab/SpecDiffModal/index.js
  • packages/bruno-app/src/components/OpenAPISyncTab/SpecStatusSection/index.js
  • packages/bruno-app/src/components/OpenAPISyncTab/SyncReviewPage/index.js
  • packages/bruno-app/src/components/OpenAPISyncTab/hooks/useOpenAPISync.js
  • packages/bruno-app/src/components/OpenAPISyncTab/hooks/useSyncFlow.js
  • packages/bruno-app/src/components/OpenAPISyncTab/index.js
  • packages/bruno-electron/src/ipc/openapi-sync.js
💤 Files with no reviewable changes (1)
  • packages/bruno-app/src/components/OpenAPISyncTab/index.js

@bijin-bruno bijin-bruno merged commit 83ddfc3 into usebruno:main Mar 13, 2026
9 checks passed
@wwwnuk
Copy link

wwwnuk commented Mar 13, 2026 via email

lohit-bruno pushed a commit to lohit-bruno/bruno that referenced this pull request Mar 18, 2026
… feedback (usebruno#7483)

- Removed unused props and improved error handling in OpenAPISyncTab components.
- Updated messaging in CollectionStatusSection and OverviewSection for clarity.
- Enhanced the SpecDiffModal to provide better visual feedback on changes.
- Refactored sync flow logic to ensure accurate endpoint categorization and improved performance.
- Added new utility functions for better handling of spec changes and endpoint comparisons.
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