ADFA-2977: Fix stale editor tabs persisting across projects after crash#1057
ADFA-2977: Fix stale editor tabs persisting across projects after crash#1057Daniel-ADFA merged 2 commits intostagefrom
Conversation
📝 WalkthroughRelease NotesFeatures
Changes
Backward Compatibility
Risks & Best Practices Violations
WalkthroughThe change adds project path context to the OpenedFilesCache data class to prevent tab state from being incorrectly restored across different projects. The editor activity now validates that the cached project path matches the current project on startup and discards mismatched caches. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 the current code and only fix it if needed.
Inline comments:
In
`@app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt`:
- Around line 353-356: When comparing cache.projectPath to the current project,
treat blank cache paths as stale and avoid directly accessing
ProjectManagerImpl.getInstance().projectDirPath without guarding for
uninitialized state: change the condition to treat cache.projectPath.isBlank()
as stale (e.g., if (cache.projectPath.isBlank() || cache.projectPath !=
currentProjectPath) { log and return }), and wrap the retrieval of
ProjectManagerImpl.getInstance().projectDirPath in a try/catch for
UninitializedPropertyAccessException so that if the property isn't initialized
you log the exception and treat the cache as stale (clear/return) instead of
letting the exception bubble up.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 19e4393f-4c90-48c4-91ff-2ef8417e0b73
📒 Files selected for processing (2)
app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.ktapp/src/main/java/com/itsaky/androidide/models/OpenedFilesCache.kt
Add projectPath to OpenedFilesCache so tab restoration is scoped to the correct project. After a crash or force stop, tabs from a previously opened project no longer appear when opening a different project.