fix: example tab not closing post delete, tab not found issue when i …#6561
Conversation
…delete intermediate example
WalkthroughWhen response examples are deleted, associated tabs are now closed via Redux before deletion. A new cache synchronization mechanism rebuilds the example UIDs index whenever requests are saved through IPC, ensuring consistency between examples and cached UIDs. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Modal as DeleteResponseExampleModal
participant Redux as Redux Store
participant IPC as IPC Handler
participant Cache as requestUids Cache
User->>Modal: Click delete example
Modal->>Modal: e.stopPropagation()
Modal->>Redux: dispatch closeTabs(exampleUid)
Modal->>Redux: dispatch deleteResponseExample
Modal->>Redux: dispatch saveRequest
rect rgba(200, 220, 240, 0.3)
Note over Redux,IPC: Request persisted via IPC
end
Redux->>IPC: renderer:save-request
IPC->>Cache: syncExampleUidsCache(pathname, examples)
Cache->>Cache: Clear old UID entries<br/>Rebuild from examples
IPC->>IPC: Save request to disk
rect rgba(200, 240, 200, 0.3)
Note over Cache: Cache synchronized
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/bruno-electron/src/ipc/collection.js (1)
363-379: Apply cache sync in batch save operations as well.The
renderer:save-multiple-requestshandler doesn't callsyncExampleUidsCache, which could leave the cache stale if examples are modified during batch operations. This inconsistency may reintroduce the "tab not found" issue.🔎 Proposed fix
ipcMain.handle('renderer:save-multiple-requests', async (event, requestsToSave) => { try { for (let r of requestsToSave) { const request = r.item; const pathname = r.pathname; if (!fs.existsSync(pathname)) { throw new Error(`path: ${pathname} does not exist`); } + // Sync example UIDs cache to maintain consistency when examples are added/deleted/reordered + syncExampleUidsCache(pathname, request.examples); + const content = await stringifyRequestViaWorker(request, { format: r.format }); await writeFile(pathname, content); } } catch (error) { return Promise.reject(error); } });packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/ExampleItem/DeleteResponseExampleModal/index.js (1)
12-22: Removee.stopPropagation()— it will crash when ENTER key is pressed.The Modal component calls
handleConfirm()without arguments when the ENTER key is pressed (line 94 of Modal/index.js), but your function expects an event parameter and callse.stopPropagation()unconditionally. This will throwTypeError: Cannot read property 'stopPropagation' of undefined.Either remove the line entirely (likely unnecessary) or add a guard:
e?.stopPropagation?.().The tab closure order before deletion is correct.
🧹 Nitpick comments (1)
packages/bruno-electron/src/cache/requestUids.js (1)
67-72: Cache rebuild logic is sound.The function correctly rebuilds the cache using current example indices. The
if (example.uid)check is defensive, though silently skipping examples without UIDs could mask issues during development.Consider logging when an example lacks a UID to aid debugging:
🔎 Optional enhancement
examples.forEach((example, index) => { if (example.uid) { exampleUids.set(`${pathname}-${index}`, example.uid); + } else { + console.warn(`Example at index ${index} for ${pathname} is missing a UID`); } });
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/ExampleItem/DeleteResponseExampleModal/index.jspackages/bruno-electron/src/cache/requestUids.jspackages/bruno-electron/src/ipc/collection.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/ExampleItem/DeleteResponseExampleModal/index.jspackages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/cache/requestUids.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.
Applied to files:
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/ExampleItem/DeleteResponseExampleModal/index.jspackages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/cache/requestUids.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/ipc/collection.js (1)
packages/bruno-electron/src/cache/requestUids.js (1)
syncExampleUidsCache(59-73)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Playwright E2E Tests
- GitHub Check: SSL Tests - macOS
- GitHub Check: SSL Tests - Windows
- GitHub Check: Unit Tests
🔇 Additional comments (6)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/ExampleItem/DeleteResponseExampleModal/index.js (1)
7-7: LGTM! Import follows existing pattern.The
closeTabsimport is correctly placed and follows Redux naming conventions.packages/bruno-electron/src/ipc/collection.js (2)
54-54: LGTM! Import follows existing pattern.The
syncExampleUidsCacheimport is correctly placed with related cache utilities.
352-353: Cache sync correctly placed before file write.The
syncExampleUidsCachecall ensures UID consistency when examples are modified.packages/bruno-electron/src/cache/requestUids.js (3)
52-59: LGTM! Well-documented function signature.JSDoc is comprehensive, and the default parameter provides a safe fallback.
60-65: LGTM! Cache clearing logic is correct.The prefix-based matching ensures all related entries are removed before rebuilding.
75-81: LGTM! Export follows existing pattern.The
syncExampleUidsCacheis correctly added to the module exports.
Description
example tab not closing post delete, tab not found issue when i delete intermediate example
Contribution Checklist:
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
✏️ Tip: You can customize this high-level summary in your review settings.