Update default database entries and add idempotent synchronization#113
Update default database entries and add idempotent synchronization#113Android-PowerUser wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Summary
This PR updates default database entries and implements idempotent synchronization for help content. The implementation is mostly sound, but 3 critical issues must be fixed before merge:
Critical Issues Blocking Merge
- Bash Syntax Error (Line 88): Incorrect negation syntax in the bash script will cause Android SDK setup to fail
- Data Loss Risk (Lines 237, 247): Case-insensitive matching will incorrectly delete or replace user-created entries that differ only in case from default entries
Required Actions
Please fix the bash syntax error and change to case-sensitive title matching to prevent unintended data loss of user entries.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
| echo "sdk.dir=android_sdk" > local.properties | ||
|
|
||
| # Add android_sdk to .gitignore if it's not already there | ||
| if ! grep -q "android_sdk/" .gitignore; then |
There was a problem hiding this comment.
🛑 Syntax Error: The bash condition has incorrect syntax. The negation operator ! should be inside the brackets and needs proper spacing.
This will cause the bash script to fail when users follow these instructions, preventing the Android SDK setup from working correctly.
| if ! grep -q "android_sdk/" .gitignore; then | |
| if ! grep -q "android_sdk/" .gitignore; then |
| ) { | ||
| val matchingTitles = legacyTitles + requiredEntry.title | ||
| val firstMatchingIndex = entries.indexOfFirst { entry -> | ||
| matchingTitles.any { title -> entry.title.equals(title, ignoreCase = true) } |
There was a problem hiding this comment.
🛑 Logic Error: Case-insensitive matching can cause unintended deletions of user-created entries. If a user creates an entry with a title that differs only in case from a default entry (e.g., "TERMUX" vs "Termux"), the synchronization logic will incorrectly replace or delete the user's entry.
Change to case-sensitive comparison to prevent data loss of user entries that have similar titles with different casing.
| matchingTitles.any { title -> entry.title.equals(title, ignoreCase = true) } | |
| matchingTitles.any { title -> entry.title == title } |
|
|
||
| entries[firstMatchingIndex] = requiredEntry | ||
| for (index in entries.indices.reversed()) { | ||
| if (index != firstMatchingIndex && matchingTitles.any { entries[index].title.equals(it, ignoreCase = true) }) { |
There was a problem hiding this comment.
🛑 Logic Error: Case-insensitive matching can incorrectly identify user entries as duplicates. If a user creates an entry "ROOT AVAILABILITY" (all caps), this logic will delete it as a duplicate of the default "Root availability" entry, causing data loss.
Change to case-sensitive comparison to ensure only actual duplicates are removed, not entries with different casing.
| if (index != firstMatchingIndex && matchingTitles.any { entries[index].title.equals(it, ignoreCase = true) }) { | |
| if (index != firstMatchingIndex && matchingTitles.any { entries[index].title == it }) { |
Motivation
KEY_DEFAULT_DB_ENTRIES_POPULATEDis already set.Description
If "Termux("command")" doesn't workand the supplied multi-line troubleshooting guide inSystemMessageEntryPreferences.kt.If a field to click is not spelled outand updated its content, and added new default entries:Root availability,Set thumbnail for videos,Codex, andDeveloping Android appswith the provided multi-line content.Termux,Miscellaneous,If a field is not spelled out) while preserving other user entries via the helper functionssynchronizeDefaultEntriesandupsertRequiredEntryinSystemMessageEntryPreferences.kt.app/src/main/kotlin/com/google/ai/sample/util/SystemMessageEntryPreferences.ktand ensured duplicates/legacy titles are cleaned up during synchronization.Testing
./gradlew :app:compileDebugKotlinand the build completed successfully with only existing warnings about deprecated/opt-in usages; the compilation succeeded.Codex Task