Skip to content

ADFA-4692: Fix unknown project language - #1650

Merged
dara-abijo-adfa merged 8 commits into
stagefrom
ADFA-4692-unknown-project-language
Aug 11, 2026
Merged

ADFA-4692: Fix unknown project language#1650
dara-abijo-adfa merged 8 commits into
stagefrom
ADFA-4692-unknown-project-language

Conversation

@dara-abijo-adfa

@dara-abijo-adfa dara-abijo-adfa commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The project language field, one of the recent project details being persisted was previously being saved in the Room database. As a result, the detail is lost when the app data is cleared or when the app is re-installed.
The project language is now dynamically detected from Filesystem.

@dara-abijo-adfa dara-abijo-adfa self-assigned this Aug 10, 2026
@dara-abijo-adfa
dara-abijo-adfa marked this pull request as ready for review August 11, 2026 10:11

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough
  • Detects Java and Kotlin project languages from source files and Gradle configuration.
  • Stores detected project language in recent projects.
  • Displays project language with fallback handling in ProjectInfoBottomSheet.
  • Improves Kotlin version resolution from Gradle version catalogs.
  • Adds tests for language detection and Kotlin version parsing.
  • Risk: Language detection may return "Unknown" for unsupported project layouts or languages.
  • Risk: Database compatibility may require migration handling if the recent-project schema changed.

Walkthrough

The change adds Java and Kotlin project-language detection, improves Kotlin version parsing, includes language in project details, persists it in recent projects, and displays it in the project information sheet. Other edits reformat existing code.

Changes

Project language detection and details

Layer / File(s) Summary
Language detection and project details
common/src/main/java/com/itsaky/androidide/templates/Language.kt, common/src/main/java/com/itsaky/androidide/utils/..., common/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kt, templates-api/src/main/java/com/itsaky/androidide/templates/template.kt
The common module detects Java, Kotlin, or unknown projects. Kotlin version catalog parsing supports direct keys and version.ref entries. Project details now include language. Tests cover detection and version parsing. The duplicate template API enum is removed.

Recent-project language storage

Layer / File(s) Summary
Recent-project language storage
app/src/main/java/com/itsaky/androidide/roomData/recentproject/RecentProjectDao.kt, app/src/main/java/com/itsaky/androidide/viewmodel/..., app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt
Recent-project insertion and project opening detect and store project language. The DAO updates language by location. Cancellation is rethrown, and only SQL exceptions are logged in the updated persistence path.

Project information display

Layer / File(s) Summary
Project information language display
app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt
The language display selects a valid recent-project language, detected language, or unknown, then capitalizes the result. Other UI behavior is reformatted only.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MainActivity
  participant readProjectLanguage
  participant RecentProjectDao
  participant ProjectInfoBottomSheet

  MainActivity->>readProjectLanguage: detect project language
  readProjectLanguage-->>MainActivity: return language
  MainActivity->>RecentProjectDao: store project language
  ProjectInfoBottomSheet->>RecentProjectDao: load recent project
  ProjectInfoBottomSheet-->>ProjectInfoBottomSheet: select language fallback
Loading

Possibly related PRs

Suggested reviewers: itsaky-adfa, jatezzz, jomen-adfa

Poem

A rabbit checks each project tree,
For Java, Kotlin, or mystery.
Recents store the language bright,
Details show the result right.
Hop, detect, and save with cheer!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing unknown project language detection.
Description check ✅ Passed The description accurately explains the persistence issue and the new filesystem-based language detection.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ADFA-4692-unknown-project-language

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 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/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt`:
- Around line 85-87: Remove the decorative separator comment blocks from the
relevant sections of ProjectInfoBottomSheet, including the GENERAL section and
the sections at the other referenced locations. Keep the surrounding method
implementations unchanged, as their names already provide sufficient context.
- Around line 138-146: Update the language filtering in the languageToDisplay
selection to reject both the localized unknown string and the canonical
"Unknown" sentinel for pLang and details.language. Preserve the existing
fallback order, allowing the localized unknown value to be used only as the
final fallback so it is displayed correctly for the current locale.

In `@app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt`:
- Around line 117-130: Update saveProjectToRecents in
app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt:117-130 to
rethrow CancellationException and catch only expected
DAO/filesystem/security/web-server failures. Apply the same
cancellation-preserving, narrowly typed handling to the coroutine site in
app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt:272-320
and app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt:458-477.
In vacuumDatabase, ensure runCatching failures are logged and propagated through
the required database error state instead of discarded.

In `@common/src/main/java/com/itsaky/androidide/utils/GetProjectBuildVersions.kt`:
- Around line 109-130: Add KDoc to the public `readProjectLanguage` function
documenting that it checks `app/src/main` and `src/main`, gives Kotlin files
precedence over Java, and returns `"Unknown"` when no supported language is
detected or neither source root exists.

In
`@common/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kt`:
- Around line 15-48: Extend the readProjectLanguage tests with one case
containing a .kts source file and assert Kotlin, plus another case with an empty
or unsupported source tree and assert Unknown. Keep the existing Java and .kt
coverage unchanged and use the same temporary-project setup and assertions.
- Around line 3-12: Configure the common test setup with the JUnit Jupiter
dependency and useJUnitPlatform(). In GetProjectBuildVersionsTest, replace the
JUnit 4 Test and Rule/TemporaryFolder APIs with org.junit.jupiter.api.Test and
`@TempDir`, updating temporary-directory usage to match Jupiter.

In `@templates-api/src/main/java/com/itsaky/androidide/templates/template.kt`:
- Around line 235-237: Run ktlint and Spotless on the complete changed
template.kt file, not only the displayed lines. Ensure the Template constructor
parameters use tab indentation and the requireNotNull call near its definition
is formatted according to project style, then apply the resulting file-wide
formatting required by the Spotless ratchet.
🪄 Autofix

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 Plus

Run ID: 6dba55e8-dd66-44bf-90ff-5b113d7aaacc

📥 Commits

Reviewing files that changed from the base of the PR and between 62d5573 and b9ac351.

📒 Files selected for processing (10)
  • app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt
  • app/src/main/java/com/itsaky/androidide/roomData/recentproject/RecentProjectDao.kt
  • app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt
  • app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt
  • app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt
  • common/src/main/java/com/itsaky/androidide/templates/Language.kt
  • common/src/main/java/com/itsaky/androidide/utils/GetProjectBuildVersions.kt
  • common/src/main/java/com/itsaky/androidide/utils/GetProjectDetails.kt
  • common/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kt
  • templates-api/src/main/java/com/itsaky/androidide/templates/template.kt

Comment thread app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
`@common/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kt`:
- Around line 89-98: Add a separate test for readProjectLanguage that creates an
otherwise empty project without app/src/main or src/main, then assert it returns
"Unknown". Keep the existing empty-source-tree test unchanged and target the
early missing-source-directory branch directly.
🪄 Autofix

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 Plus

Run ID: 97011d14-7c4b-43a0-9dc5-f3b903b072c1

📥 Commits

Reviewing files that changed from the base of the PR and between b9ac351 and 92c0689.

📒 Files selected for processing (6)
  • app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt
  • app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt
  • app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt
  • common/src/main/java/com/itsaky/androidide/templates/Language.kt
  • common/src/main/java/com/itsaky/androidide/utils/GetProjectBuildVersions.kt
  • common/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kt
🚧 Files skipped from review as they are similar to previous changes (4)
  • common/src/main/java/com/itsaky/androidide/utils/GetProjectBuildVersions.kt
  • app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt
  • app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt
  • app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt

@dara-abijo-adfa
dara-abijo-adfa merged commit 64d9222 into stage Aug 11, 2026
4 checks passed
@dara-abijo-adfa
dara-abijo-adfa deleted the ADFA-4692-unknown-project-language branch August 11, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants