ADFA-3879 resilient LastChange table#1302
Conversation
…; never crash regardless of LastChange table
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughRelease NotesResilient Database Version Resolution
Improved Robustness
Code Cleanup
Test Coverage
WalkthroughThis PR centralizes database version resolution by introducing ChangesDatabase Version Resolution Centralization
Sequence DiagramsequenceDiagram
participant TooltipMgr as TooltipManager
participant WebServer
participant Resolver as DatabaseVersionResolver
participant DB as SQLiteDatabase
TooltipMgr->>Resolver: resolveDatabaseVersion(db)
Resolver->>DB: query wholedb from LastChange
alt wholedb found
DB-->>Resolver: wholedb row (changeTime, who)
Resolver->>Resolver: formatVersion(changeTime, who)
Resolver-->>TooltipMgr: formatted version string
else wholedb missing
DB-->>Resolver: no wholedb row
Resolver->>DB: query latest LastChange row
DB-->>Resolver: latest row (changeTime, who, documentationSet)
Resolver->>Resolver: formatVersion(changeTime, who, documentationSet)
Resolver-->>TooltipMgr: formatted version string
end
WebServer->>Resolver: resolveDatabaseVersion(db)
Resolver-->>WebServer: version string
WebServer->>WebServer: log version
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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: 2
🧹 Nitpick comments (1)
common/src/androidTest/java/com/itsaky/androidide/utils/DatabaseVersionResolverTest.kt (1)
42-52: ⚡ Quick winConsider adding a test case for multiple
wholedbrecords.The current test verifies that a single
wholedbrecord is returned correctly. To ensure the query returns the latest record when multiplewholedbentries exist (especially after addingORDER BY changeTime DESCas suggested), consider adding a test case that inserts multiplewholedbrecords with different timestamps and verifies the most recent one is returned.🧪 Example test case
`@Test` fun returnsLatestWholedbRow_whenMultiplePresent() { createTable() insertRow("wholedb", "2026-05-01 10:00:00", "alice") insertRow("wholedb", "2026-05-09 02:00:20", "hal") insertRow("wholedb", "2026-05-03 14:30:00", "bob") assertEquals( "2026-05-09 02:00:20 hal", DatabaseVersionResolver.resolveDatabaseVersion(db), ) }🤖 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 `@common/src/androidTest/java/com/itsaky/androidide/utils/DatabaseVersionResolverTest.kt` around lines 42 - 52, Add a new test in DatabaseVersionResolverTest (e.g., returnsLatestWholedbRow_whenMultiplePresent) that uses createTable() and insertRow() to insert multiple "wholedb" rows with different changeTime values, then assert DatabaseVersionResolver.resolveDatabaseVersion(db) returns the most recent record (timestamp + author); reference the existing returnsWholedbRow_whenPresent test for structure and ensure the inserted timestamps exercise the ORDER BY changeTime DESC behavior.
🤖 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 `@app/src/debug/AndroidManifest.xml`:
- Line 7: Remove the android:exported="true" attribute from the debug-only test
activity declaration (the activity launched by ActivityScenario.launch()) so the
activity is not exported to other apps; edit the debug AndroidManifest entry for
that test activity and either delete the android:exported attribute or set it to
false to restrict visibility.
In `@common/src/main/java/com/itsaky/androidide/utils/DatabaseVersionResolver.kt`:
- Around line 12-17: The QUERY_WHOLEDB SQL constant currently selects LIMIT 1
from LastChange without ordering, which can return non-deterministic rows;
update the QUERY_WHOLEDB constant to include an ORDER BY changeTime DESC
(matching QUERY_FALLBACK_LATEST) so the latest wholedb record is
deterministically returned when using LIMIT 1.
---
Nitpick comments:
In
`@common/src/androidTest/java/com/itsaky/androidide/utils/DatabaseVersionResolverTest.kt`:
- Around line 42-52: Add a new test in DatabaseVersionResolverTest (e.g.,
returnsLatestWholedbRow_whenMultiplePresent) that uses createTable() and
insertRow() to insert multiple "wholedb" rows with different changeTime values,
then assert DatabaseVersionResolver.resolveDatabaseVersion(db) returns the most
recent record (timestamp + author); reference the existing
returnsWholedbRow_whenPresent test for structure and ensure the inserted
timestamps exercise the ORDER BY changeTime DESC behavior.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 016fc624-892c-440f-a64b-02ad7f47ea54
📒 Files selected for processing (7)
app/src/androidTest/kotlin/com/itsaky/androidide/idetooltips/TooltipDebugDialogScreenshotTest.ktapp/src/debug/AndroidManifest.xmlapp/src/debug/java/com/itsaky/androidide/idetooltips/TooltipScreenshotHostActivity.ktapp/src/main/java/com/itsaky/androidide/localWebServer/WebServer.ktcommon/src/androidTest/java/com/itsaky/androidide/utils/DatabaseVersionResolverTest.ktcommon/src/main/java/com/itsaky/androidide/utils/DatabaseVersionResolver.ktidetooltips/src/main/java/com/itsaky/androidide/idetooltips/ToolTipManager.kt
…reenshotHostActivity.kt
…ooltipDebugDialogScreenshotTest.kt
Handle missing documentation.db LastChange wholedb record by fallback
Never crash regardless of LastChange table