fix: prevent navigation on invalid organization search#68
Conversation
|
Worried about impact? Review this PR in Change Stack to explore blast radius before you approve or request changes. WalkthroughThe PR adds success/failure signaling to the organization exploration flow: the ChangesOrg Exploration and Caching Updates
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
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 `@src/services/github.js`:
- Line 2: The DB_NAME constant was changed to 'orgexplorer_cache' which orphaned
the old 'orgexplorer_v2' DB; add startup cleanup logic (e.g., in the module
initialization or the function that opens the DB) to detect and delete the old
'orgexplorer_v2' IndexedDB database before or after opening the new DB so users
don't retain stale storage—use the DB_NAME constant for the new name and
explicitly call the browser IndexedDB deleteDatabase('orgexplorer_v2') (with
proper promise/error handling and logging) to remove the old database.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: eee8cfac-937c-4804-9341-bd6cde9965a9
📒 Files selected for processing (3)
src/context/AppContext.jsxsrc/pages/HomePage.jsxsrc/services/github.js
| @@ -1,5 +1,5 @@ | |||
| // IndexedDB Cache (L2) | |||
| const DB_NAME = 'orgexplorer_v2' | |||
| const DB_NAME = 'orgexplorer_cache' | |||
There was a problem hiding this comment.
Database rename invalidates existing cache and orphans old database.
Renaming the database from orgexplorer_v2 to orgexplorer_cache means all users' existing cached GitHub API responses become inaccessible. This will cause:
- Cache misses on first requests after update, potentially increasing API calls and hitting rate limits.
- The old
orgexplorer_v2database will remain in users' browsers, wasting storage space.
Consider adding cleanup code to delete the old database on initialization to prevent storage waste.
🧹 Proposed fix to clean up orphaned database
// IndexedDB Cache (L2)
const DB_NAME = 'orgexplorer_cache'
+const OLD_DB_NAME = 'orgexplorer_v2'
const STORE = 'cache'
const TTL_MS = 3_600_000 // 1 hour
function openDB() {
return new Promise((resolve, reject) => {
const req = indexedDB.open(DB_NAME, 1)
req.onupgradeneeded = e => e.target.result.createObjectStore(STORE, { keyPath: 'k' })
req.onsuccess = e => resolve(e.target.result)
req.onerror = () => reject(req.error)
})
}
+
+// Clean up old database on first load
+if (typeof window !== 'undefined') {
+ indexedDB.deleteDatabase(OLD_DB_NAME)
+}🤖 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 `@src/services/github.js` at line 2, The DB_NAME constant was changed to
'orgexplorer_cache' which orphaned the old 'orgexplorer_v2' DB; add startup
cleanup logic (e.g., in the module initialization or the function that opens the
DB) to detect and delete the old 'orgexplorer_v2' IndexedDB database before or
after opening the new DB so users don't retain stale storage—use the DB_NAME
constant for the new name and explicitly call the browser IndexedDB
deleteDatabase('orgexplorer_v2') (with proper promise/error handling and
logging) to remove the old database.
Addressed Issues:
Fixes #
Screenshots/Recordings:
Before
https://drive.google.com/file/d/17xp34CqaO0t8KXSdBCqYWnp3GsTrDgj7/view?usp=drive_link
After
https://drive.google.com/file/d/1LR-OxsV-36fUpHrr1clPqqjwFcuPAjUx/view?usp=drive_link
Additional Notes:
Changes Made
Impact
Checklist
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.
Summary by CodeRabbit