Skip to content

ADFA-2838: Add jetpack compose preview documentation tooltip - #960

Merged
Daniel-ADFA merged 3 commits into
stagefrom
ADFA-2838
Feb 12, 2026
Merged

ADFA-2838: Add jetpack compose preview documentation tooltip#960
Daniel-ADFA merged 3 commits into
stagefrom
ADFA-2838

Conversation

@Daniel-ADFA

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitaiBot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Release Notes - ADFA-2838: Add Jetpack Compose Preview Documentation Tooltip

  • Context-aware tooltips: Added a distinct Compose preview tooltip key editor.compose.preview (TooltipTag.EDITOR_TOOLBAR_PREVIEW_COMPOSE).
  • Compose detection: Implemented moduleUsesCompose() helpers to detect the presence of the Compose runtime dependency:
    • moduleUsesCompose(): scans workspace Android modules for androidx.compose.runtime:runtime.
    • moduleUsesCompose(file): resolves the module for a file and checks that module specifically.
  • Safer editor/data access: prepare() rewritten to use data.getEditor(), data.getActivity() guards, and viewModel initialization checks instead of requireEditor(); postExec() updated to safely retrieve editor/file before invoking editor handlers.
  • Preview type handling: Preview action now distinguishes XML layout previews and Compose previews (COMPOSE), and sets visibility/enabled flags appropriately; supports pre-setting COMPOSE when module-level Compose is present even without an open file.
  • XML/Kotlin handling: XML layout detection now uses extractPathData(file).type to identify layout files; Kotlin files (.kt) are treated as Compose candidates only if moduleUsesCompose(file) is true.
  • Internal helpers added and private logic refactored to avoid throwing on missing editors/files; no public API signatures changed.

⚠️ Risks and Best-Practices Concerns

  • Performance: moduleUsesCompose() may be invoked frequently from prepare() (on editor interactions) and traverses workspace modules/dependencies each time. Recommendation: cache results and invalidate on workspace/module changes.
  • Module vs. project scope: The implementation includes both module-aware and project-scan helpers, but some code paths pre-check project modules without module context. In multi-module repositories, ensure the check used is the module-specific one to avoid showing Compose preview for files in non-Compose modules.
  • State staleness: previewType is computed in prepare() and used in postExec(); without synchronization or caching, workspace/module changes between calls could produce stale state.
  • Error handling: extractPathData() and other file-inspection failures silently set invisibility; consider explicit logging or user-visible diagnostics to aid debugging.
  • Complexity and testability: prepare() contains multiple guarded paths and flags (visibility/enabled); consider refactoring to smaller, testable functions or a single sealed-state model.
  • Testing gaps: add tests for mixed Compose/non-Compose multi-module projects, rapid file switching, null workspace/editor scenarios, and validation that editor handler invocations receive valid data.

Lines changed (approximate):

  • PreviewLayoutAction.kt: +56 / -51
  • TooltipTag.kt: +1 / -0

Walkthrough

Adds Compose preview support to PreviewLayoutAction, detects Compose dependency via IProjectManager, refactors prepare()/postExec() to use safe editor/file retrieval and guarded visibility/enabled states, and introduces a new tooltip constant for Compose previews.

Changes

Cohort / File(s)Summary
Preview Action Enhancement
app/src/main/java/com/itsaky/androidide/actions/etc/PreviewLayoutAction.kt
Rewrote prepare() and postExec() to use safe data.getEditor() and file derivation, added moduleUsesCompose() helpers (workspace- and file-based) to detect androidx.compose.runtime, adjusted visibility/enabled logic for XML (.xml) and Kotlin/Compose (.kt) cases, and switched tooltip tag selection based on preview type.
Tooltip Constants
idetooltips/src/main/java/com/itsaky/androidide/idetooltips/TooltipTag.kt
Added EDITOR_TOOLBAR_PREVIEW_COMPOSE = "editor.compose.preview" constant for Compose preview tooltips.

Sequence Diagram(s)

sequenceDiagram
participant PreviewAction as PreviewLayoutAction
participant ProjManager as IProjectManager
participant Handler as EditorHandlerActivity
participant Editor as Editor/File
rect rgba(100,150,200,0.5)
Note over PreviewAction,Editor: prepare()
PreviewAction->>Editor: request editor from data
Editor-->>PreviewAction: editor / file path or null
end
rect rgba(150,100,200,0.5)
Note over PreviewAction,ProjManager: dependency check
PreviewAction->>ProjManager: moduleUsesCompose(file?) or project-wide check
ProjManager-->>PreviewAction: true / false
end
rect rgba(200,150,100,0.5)
Note over PreviewAction,Handler: postExec()
alt file ends with .xml
PreviewAction->>Handler: invoke XML preview
else file is .kt and Compose available
PreviewAction->>Handler: invoke Compose preview
else no applicable preview
PreviewAction->>PreviewAction: mark action invisible/disabled
end
Handler-->>PreviewAction: preview result
end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • itsaky-adfa
  • jomen-adfa
  • dara-abijo-adfa

Poem

🐰 I sniffed the modules, found Compose light,
Switched tooltips quick and kept things tight.
XML hops in, Kotlin joins the show,
A tiny preview garden begins to grow! 🌱✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check❓ InconclusiveNo description was provided, making it impossible to assess relevance to the changeset.Provide a description explaining the motivation and implementation details for adding Jetpack Compose preview documentation tooltip support.
✅ Passed checks (1 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly relates to the main changeset: adding a new tooltip for Jetpack Compose preview, reflected in the new EDITOR_TOOLBAR_PREVIEW_COMPOSE constant and updated PreviewLayoutAction logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ADFA-2838

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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 and usage tips.

Comment threadapp/src/main/java/com/itsaky/androidide/actions/etc/PreviewLayoutAction.kt Outdated

@coderabbitaicoderabbitaiBot 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

🤖 Fix all issues with AI agents
In `@app/src/main/java/com/itsaky/androidide/actions/etc/PreviewLayoutAction.kt`:
- Around line 85-90: The catch block around extractPathData in
PreviewLayoutAction currently swallows all Throwables and just calls
markInvisible(); update it to log the exception (at debug or warn level) with
context before calling markInvisible() and returning so failures are
diagnosable; locate the try/catch around extractPathData(...) in
PreviewLayoutAction (the catch handling Throwable err) and add a process or
logger call that includes err and a short message identifying the
file/operation.
🧹 Nitpick comments (1)
app/src/main/java/com/itsaky/androidide/actions/etc/PreviewLayoutAction.kt (1)

109-117: Fallback shows Compose tooltip even for XML files during initialization.

When viewModel.isInitializing is true andfile is non-null (e.g., an .xml file), this branch still sets previewType = COMPOSE if the project uses Compose. The button is disabled so it's not clickable, but the tooltip will briefly show the Compose preview hint instead of the layout preview one until initialization completes and prepare() is re-invoked.

If that transient tooltip mismatch is acceptable, feel free to ignore.

@Daniel-ADFA
Daniel-ADFA merged commit 50f6997 into stageFeb 12, 2026
2 checks passed
@Daniel-ADFA
Daniel-ADFA deleted the ADFA-2838 branch February 12, 2026 13:34
jatezzz pushed a commit that referenced this pull request Jun 22, 2026
* ADFA-2838: Add jetpack compose preview documentation tooltip
* fixes
Sign up for freeto 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.

3 participants

@Daniel-ADFA@itsaky-adfa@dara-abijo-adfa