Repository navigation
fix(mount): show requests that failed to load in the collection overview - #8545
bijin-bruno merged 5 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughCollection request parsing now propagates partial/error state through mount storage, reducer updates, sizing, and the failed-requests overview. ChangesError/raw propagation and UI display
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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/CollectionSettings/Overview/RequestsNotLoaded/index.js (1)
72-83: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRender filter diverges from
itemsFailedLoadingfilter — useitemsFailedLoadingfor rendering.The
<tbody>maps overflattenedItemsand filters withitem?.partial && !item?.loading(line 73), butitemsFailedLoading(line 24) also checksitem?.error. Currently both match because the tree-builder always setspartial: truealongsideerror, but this coupling is fragile. If the contract changes, the section would show with missing rows.🛡️ Proposed fix: render from `itemsFailedLoading` directly
<tbody> - {flattenedItems?.map((item, index) => ( - item?.partial && !item?.loading ? ( + {itemsFailedLoading?.map((item, index) => ( <tr key={index} className="cursor-pointer" onClick={handleRequestClick(item)}> <td className="py-1.5 px-3"> {toRelativePathname(item?.pathname, collection?.pathname)} </td> <td className="py-1.5 px-3"> {item?.size?.toFixed?.(2)} MB </td> </tr> - ) : null ))} </tbody>🤖 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/CollectionSettings/Overview/RequestsNotLoaded/index.js` around lines 72 - 83, The rendering logic in RequestsNotLoaded is duplicating the failure filter instead of using the existing itemsFailedLoading source. Update the tbody map in the RequestsNotLoaded component to render directly from itemsFailedLoading, and keep the row click/label behavior tied to handleRequestClick, toRelativePathname, and the item fields already used there. This keeps the displayed rows aligned with the failure criteria defined earlier and avoids relying on the fragile partial/loading coupling.packages/bruno-electron/src/app/collection-watcher.js (1)
576-615: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winGuard against undefined
content/fileStatsin thechange()catch block.If
fs.readFileSyncorfs.statSyncthrows (e.g., file deleted between watcher events),contentandfileStatsremainundefined. The catch block then setsfile.size = sizeInMB(undefined)→NaNandfile.data.raw = undefined, which would render "NaN MB" in the RequestsNotLoaded UI.🛡️ Proposed fix
} catch (err) { file.data = { name: path.basename(pathname), type: 'http-request' }; file.error = { message: err?.message }; file.partial = true; file.loading = false; - file.size = sizeInMB(fileStats?.size); - file.data.raw = content; + file.size = fileStats ? sizeInMB(fileStats.size) : 0; + file.data.raw = content ?? null; hydrateRequestWithUuid(file.data, pathname); win.webContents.send('main:collection-tree-updated', 'change', file); }🤖 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-electron/src/app/collection-watcher.js` around lines 576 - 615, In the change() handler in collection-watcher.js, the catch block assumes content and fileStats were populated even when fs.readFileSync or fs.statSync fails, which can produce NaN size and undefined raw data. Update the error path to guard those fields before assigning file.size and file.data.raw, using safe fallbacks when content/fileStats are unavailable. Keep the fix localized to the existing change flow and preserve hydrateRequestWithUuid and the collection-tree-updated send behavior.
🧹 Nitpick comments (1)
packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js (1)
20-26: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueReuse
flattenedItemsin the memoized filter to avoid duplicateflattenItemscall.
flattenItems(collection.items)is called at line 20 (unmemoized) and again inside theuseMemoat line 23. Reuse the already-computedflattenedItemsto avoid the duplicate traversal.♻️ Proposed refactor
- const flattenedItems = flattenItems(collection.items); - - const itemsFailedLoading = useMemo(() => { - return flattenItems(collection.items)?.filter((item) => { - return (item?.partial && !item.loading) || (item?.error); - }); - }, [collection.items]); + const flattenedItems = useMemo(() => flattenItems(collection.items), [collection.items]); + + const itemsFailedLoading = useMemo(() => { + return flattenedItems?.filter((item) => { + return (item?.partial && !item.loading) || (item?.error); + }); + }, [flattenedItems]);🤖 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/CollectionSettings/Overview/RequestsNotLoaded/index.js` around lines 20 - 26, The RequestsNotLoaded component is flattening collection items twice, once for flattenedItems and again inside the useMemo filter. Update the useMemo in RequestsNotLoaded/index.js to reuse the existing flattenedItems value instead of calling flattenItems(collection.items) again. Keep the dependency list aligned with the reused variable so the memo stays correct and avoids duplicate traversal.
🤖 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.
Outside diff comments:
In
`@packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js`:
- Around line 72-83: The rendering logic in RequestsNotLoaded is duplicating the
failure filter instead of using the existing itemsFailedLoading source. Update
the tbody map in the RequestsNotLoaded component to render directly from
itemsFailedLoading, and keep the row click/label behavior tied to
handleRequestClick, toRelativePathname, and the item fields already used there.
This keeps the displayed rows aligned with the failure criteria defined earlier
and avoids relying on the fragile partial/loading coupling.
In `@packages/bruno-electron/src/app/collection-watcher.js`:
- Around line 576-615: In the change() handler in collection-watcher.js, the
catch block assumes content and fileStats were populated even when
fs.readFileSync or fs.statSync fails, which can produce NaN size and undefined
raw data. Update the error path to guard those fields before assigning file.size
and file.data.raw, using safe fallbacks when content/fileStats are unavailable.
Keep the fix localized to the existing change flow and preserve
hydrateRequestWithUuid and the collection-tree-updated send behavior.
---
Nitpick comments:
In
`@packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js`:
- Around line 20-26: The RequestsNotLoaded component is flattening collection
items twice, once for flattenedItems and again inside the useMemo filter. Update
the useMemo in RequestsNotLoaded/index.js to reuse the existing flattenedItems
value instead of calling flattenItems(collection.items) again. Keep the
dependency list aligned with the reused variable so the memo stays correct and
avoids duplicate traversal.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 49ad12a4-5ab8-4cce-8e81-064b398103e1
📒 Files selected for processing (4)
packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.jspackages/bruno-electron/src/app/collection-watcher.jspackages/bruno-electron/src/services/mount/manager.jspackages/bruno-electron/src/services/mount/tree-builder.js
There was a problem hiding this comment.
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/CollectionSettings/Overview/RequestsNotLoaded/index.js (1)
10-16: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winNormalize
toRelativePathnamebefore slicing
packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js:10-16— the currentstartsWith/slicelogic breaks whenpathnameandcollectionPathnameuse different separators, so Windows paths can fall back to the full pathname. Usepath.relative(...)or normalize both inputs first.🤖 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/CollectionSettings/Overview/RequestsNotLoaded/index.js` around lines 10 - 16, The toRelativePathname helper is doing a direct startsWith/slice on raw path strings, which breaks when pathname and collectionPathname use different separators. Update toRelativePathname to normalize both inputs first, or switch to path.relative, so RequestsNotLoaded/index.js returns the correct relative path for Windows-style paths as well as POSIX paths.
🧹 Nitpick comments (1)
packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js (1)
22-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid optional chaining on array-iterated items.
itemcomes from.filter()on an array, so it is always defined. Per coding guidelines,?.should be avoided when it hides whether a value can genuinely be null. Same applies toitem?.pathnameandcollection?.pathnameon line 74, anditem?.sizeon line 77 —collectionis a required prop.♻️ Proposed fix
- return (item?.partial && !item.loading) || (item?.error); + return (item.partial && !item.loading) || item.error;And on line 74:
- {toRelativePathname(item?.pathname, collection?.pathname)} + {toRelativePathname(item.pathname, collection.pathname)}🤖 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/CollectionSettings/Overview/RequestsNotLoaded/index.js` around lines 22 - 23, Remove unnecessary optional chaining where the values are guaranteed to exist. In RequestsNotLoaded, update the filter callback over flattenItems(collection.items) to use item directly instead of item?.partial/item?.error, and also replace item?.pathname, collection?.pathname, and item?.size with direct property access in the same component. Keep the logic unchanged, just align the RequestsNotLoaded component with the guideline that array-iterated items and required props should not be guarded with optional chaining.Source: Coding guidelines
🤖 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/CollectionSettings/Overview/RequestsNotLoaded/index.js`:
- Line 77: The size display in RequestsNotLoaded should not render the “MB”
suffix when item.size is missing, since item?.size?.toFixed?.(2) can be
undefined. Update the JSX in the RequestsNotLoaded component to conditionally
render the formatted size only when a value exists, and provide a clear fallback
for missing sizes so the label doesn’t show a blank number. Use the existing
item.size expression as the location to apply the guard.
- Around line 71-72: The list in RequestsNotLoaded uses the array index as the
React key, which is unstable when itemsFailedLoading changes order or content.
Update the map in the RequestsNotLoaded component to use a stable unique
identifier from each item, such as item.uid, while keeping the existing
handleRequestClick(item) behavior unchanged.
---
Outside diff comments:
In
`@packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js`:
- Around line 10-16: The toRelativePathname helper is doing a direct
startsWith/slice on raw path strings, which breaks when pathname and
collectionPathname use different separators. Update toRelativePathname to
normalize both inputs first, or switch to path.relative, so
RequestsNotLoaded/index.js returns the correct relative path for Windows-style
paths as well as POSIX paths.
---
Nitpick comments:
In
`@packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js`:
- Around line 22-23: Remove unnecessary optional chaining where the values are
guaranteed to exist. In RequestsNotLoaded, update the filter callback over
flattenItems(collection.items) to use item directly instead of
item?.partial/item?.error, and also replace item?.pathname,
collection?.pathname, and item?.size with direct property access in the same
component. Keep the logic unchanged, just align the RequestsNotLoaded component
with the guideline that array-iterated items and required props should not be
guarded with optional chaining.
🪄 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: 835235f7-0ef7-479d-ad8c-11cba97b7a71
📒 Files selected for processing (2)
packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.jspackages/bruno-electron/src/services/mount/tree-builder.js
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/bruno-electron/src/services/mount/tree-builder.js
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/providers/ReduxStore/slices/collections/index.js`:
- Around line 2981-2990: The partial/error update path in the collections slice
is overwriting the existing item type with the watcher fallback from
file.data.type, which can बदल ws/grpc/graphql entries to http-request on parse
failures. Update the item merge logic in the collections reducer to preserve the
current item.type during the file.partial/file.error branch, while still
refreshing the other fields from file.data and file.meta.
🪄 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: 27049083-be15-4cc9-a251-6f9d275d6816
📒 Files selected for processing (5)
packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/file-mode.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/utils/collections/index.jspackages/bruno-electron/src/services/mount/tree-builder.js
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/bruno-electron/src/services/mount/tree-builder.js
36da4a3 to
007bfd7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
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/providers/ReduxStore/slices/collections/index.js (1)
2981-2999: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winpackages/bruno-app/src/providers/ReduxStore/slices/collections/index.js:2981-3021 — Reset
loadingandsizeon recovery
item.loadinganditem.sizeare only refreshed in thefile.partial || file.errorbranch. If a failed parse is followed by a normal change event, the item can stay stuck with the old loading state and size even though the file recovered. Clearloadingand carrysizethrough the success branches too.🤖 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/providers/ReduxStore/slices/collections/index.js` around lines 2981 - 2999, The item update logic in the collections slice is leaving stale `loading` and `size` values after a file recovers from a partial/error state. Update the main item refresh flow around `areItemsTheSameExceptSeqUpdate` so `item.loading` is cleared and `item.size` is kept in sync not only in the `file.partial || file.error` branch but also in the normal success branches when applying `file.data` updates.
🤖 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/CollectionSettings/Overview/RequestsNotLoaded/index.js`:
- Around line 11-19: The prefix check in toRelativePathname is too loose and can
mis-slice paths when a pathname only shares a partial prefix with
collectionPathname. Update the logic in toRelativePathname to only treat it as a
match when the normalized paths are equal or the next character after
normalizedCollection is a “/” boundary, then keep the existing slice behavior
only for valid collection-descendant paths.
---
Outside diff comments:
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js`:
- Around line 2981-2999: The item update logic in the collections slice is
leaving stale `loading` and `size` values after a file recovers from a
partial/error state. Update the main item refresh flow around
`areItemsTheSameExceptSeqUpdate` so `item.loading` is cleared and `item.size` is
kept in sync not only in the `file.partial || file.error` branch but also in the
normal success branches when applying `file.data` updates.
🪄 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: 25386dd7-014d-44bf-9f0d-943dbba2f75a
📒 Files selected for processing (5)
packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/file-mode.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/utils/collections/index.jspackages/bruno-electron/src/services/mount/tree-builder.js
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/bruno-electron/src/services/mount/tree-builder.js
- packages/bruno-app/src/utils/collections/index.js
- packages/bruno-app/src/providers/ReduxStore/slices/collections/file-mode.spec.js
a237d24 to
e4ad9bc
Compare
Partial/errored requests were being dropped or mis-rendered: - collection-watcher (v1): the synchronous add path and the change path only logged parse errors and never emitted the item, so failed requests never reached the renderer. Both now send a partial item, matching the async worker path. - mount v2: reconcile dropped `raw` for errored items; it is now forwarded so the item's size can be derived, and size is set for every item. - RequestsNotLoaded: the relative pathname is computed separator-agnostically so it renders on Windows, and errored items are included.
An errored request had no parsed `request`, so tree-builder set `request: undefined`. The main->renderer payload is JSON round-tripped, which drops undefined keys, so the item reached the renderer without a `request` property and `isItemARequest` (which requires it) excluded it from the sidebar. Give errored items an empty `request` object so they survive serialization and render. Also render the "not loaded" table from the same filtered list used for the empty-state check, so errored items are listed consistently.
e4ad9bc to
8aafcb1
Compare
* fix: handle missing location header in redirect error response (usebruno#7725) * fix(request-panel)/websocket and grpc tooltip overflow fixed in request panel (usebruno#8544) * fix(request-panel)/websocket and grpx tooltip overflow fixed in request panel * added test ids and updated the locators for request panel icons * test(auth): fix modified-indicator inherit spec test (usebruno#8550) * test(auth): fix modified-indicator inherit spec test * fix(locators): updated locators for inherit * feat(description): file binary description implementation (usebruno#8434) * Add description support to file body entries Covers the UI table, FileEntry schema, .bru and .yml file persistence, OpenCollection converters, and end-to-end tests. * chore: update @opencollection/types to version 0.10.0 and adjust related code * fix: ensure placeholder is displayed correctly in description editor * fix: improve column resizing logic in EnvironmentVariablesTable * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * fix: remove unused import of FileEntry in body.ts * feat: enhance file handling and selection logic in various components * test: refactor file description tests for improved readability and structure * refactor: streamline test setup for binary file selection * test: improve comments for clarity in file body description tests * refactor: simplify selection update logic in collections slice --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * fix(mount): show requests that failed to load in the collection overview (usebruno#8545) * fix(mount): show requests that failed to load in the collection overview Partial/errored requests were being dropped or mis-rendered: - collection-watcher (v1): the synchronous add path and the change path only logged parse errors and never emitted the item, so failed requests never reached the renderer. Both now send a partial item, matching the async worker path. - mount v2: reconcile dropped `raw` for errored items; it is now forwarded so the item's size can be derived, and size is set for every item. - RequestsNotLoaded: the relative pathname is computed separator-agnostically so it renders on Windows, and errored items are included. * fix(mount): render v2 requests that failed to parse in the sidebar An errored request had no parsed `request`, so tree-builder set `request: undefined`. The main->renderer payload is JSON round-tripped, which drops undefined keys, so the item reached the renderer without a `request` property and `isItemARequest` (which requires it) excluded it from the sidebar. Give errored items an empty `request` object so they survive serialization and render. Also render the "not loaded" table from the same filtered list used for the empty-state check, so errored items are listed consistently. * fix(mount): guard against NaN size and unstable keys for unloaded requests * fix(mount): recover unloaded requests on valid re-parse without crashing the reducer * feat(mount): moved the assignments in change reducer --------- Co-authored-by: Chirag Chandrashekhar <[email protected]> --------- Co-authored-by: Pragadesh-45 <[email protected]> Co-authored-by: sachin-thakur-bruno <[email protected]> Co-authored-by: Pooja <[email protected]> Co-authored-by: Sid <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> Co-authored-by: Chirag Chandrashekhar <[email protected]> Co-authored-by: Chirag Chandrashekhar <[email protected]> Co-authored-by: Bijin A B <[email protected]>
Problem
When a request file fails to parse, it should appear in the "Following requests were not loaded" table in the collection overview. In several cases it didn't:
console.error'd the parse failure and never emitted the item to the renderer, so the failed request silently disappeared from the tree.rawfor errored items, so their size couldn't be derived./, which never matches Windows\paths — so the Pathname column rendered blank.Changes
app/collection-watcher.js: both the synchronous add path and the change path now emit a partial item (error,partial,size,raw) on parse failure, matching the async worker path.services/mount/manager.js: forwardrawfor errored items during reconcile.services/mount/tree-builder.js: derive itemsizefromrawand set it for every item.components/CollectionSettings/Overview/RequestsNotLoaded: compute the relative pathname separator-agnostically (fixes the blank Pathname on Windows) and include errored items.Summary by CodeRabbit