Skip to content

Fix Android style file selection - #1806

Merged
giswqs merged 1 commit into
mainfrom
fix/issue-1804-android-style-picker
Aug 9, 2026
Merged

Fix Android style file selection#1806
giswqs merged 1 commit into
mainfrom
fix/issue-1804-android-style-picker

Conversation

@giswqs

@giswqs giswqs commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

  • keep extension-based style filters on desktop and iOS
  • use an unfiltered Android document picker for style imports because SLD and QML lack reliable MIME mappings
  • preserve content-based validation after selection in both the layer menu and Style Manager
  • add regression tests for Android platform detection and native filter selection

Testing

  • node --import tsx --test tests/is-mobile.test.ts tests/file-dialog-filters.test.ts
  • npm run test:frontend
  • npm run build
  • pre-commit run --all-files
  • imported the issue probe SLD into us_cities.geojson in light mode
  • imported the issue probe QML into us_cities.geojson in dark mode

Fixes #1804

Summary by CodeRabbit

  • Bug Fixes

    • Improved Android style imports by accepting files with inconsistent or missing MIME types.
    • Style files are now validated based on their content, improving SLD/QML selection reliability.
    • Updated native file dialogs to apply platform-appropriate file filters.
  • Tests

    • Added coverage for Android, iOS, and desktop file-filter behavior and platform detection.

Copilot AI lite review requested due to automatic review settings August 9, 2026 18:21

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0a3c7313-5337-4482-9de5-f3f314bdb2c5

📥 Commits

Reviewing files that changed from the base of the PR and between 8f05318 and 4890f66.

📒 Files selected for processing (7)
  • apps/geolibre-desktop/src/components/panels/LayerPanel.tsx
  • apps/geolibre-desktop/src/components/panels/StyleManagerPanel.tsx
  • apps/geolibre-desktop/src/lib/file-dialog-filters.ts
  • apps/geolibre-desktop/src/lib/is-mobile.ts
  • apps/geolibre-desktop/src/lib/tauri-io.ts
  • tests/file-dialog-filters.test.ts
  • tests/is-mobile.test.ts

📝 Walkthrough

Walkthrough

The change adds Android detection and platform-aware native file-dialog filters. Style import pickers now disable Android-specific extension filters, allowing SLD and QML files to reach content validation. Tests cover Android, iOS, desktop, override, and fallback behavior.

Changes

Android file-dialog filter handling

Layer / File(s) Summary
Platform detection and filter selection
apps/geolibre-desktop/src/lib/is-mobile.ts, apps/geolibre-desktop/src/lib/file-dialog-filters.ts, tests/is-mobile.test.ts, tests/file-dialog-filters.test.ts
Adds isAndroid and nativeFileDialogFilters. Tests verify Android overrides, default fallback, and non-Android behavior.
Native dialog integration
apps/geolibre-desktop/src/lib/tauri-io.ts
Reuses the shared FileDialogFilter type, accepts optional Android filters, and applies platform-aware filters to native local-file dialogs.
Style import overrides
apps/geolibre-desktop/src/components/panels/LayerPanel.tsx, apps/geolibre-desktop/src/components/panels/StyleManagerPanel.tsx
Provides empty Android filter lists for style imports so SLD and QML files are selected before content validation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit found files in a picker’s gray light,
And made SLD and QML take flight.
Android filters now step aside,
While content checks become the guide.
Hop, hop—style imports open wide!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: fixing Android style file selection.
Linked Issues check ✅ Passed The changes address #1804 by allowing Android style files to bypass unreliable filters while retaining content-based validation and existing desktop/iOS filters.
Out of Scope Changes check ✅ Passed All code and tests directly support Android style file selection, platform-specific filtering, and regression coverage for #1804.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1804-android-style-picker

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


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.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🔍 Cloudflare PR preview

Item Value
Site https://78f5e667.geolibre-preview.pages.dev
Demo app https://78f5e667.geolibre-preview.pages.dev/demo/
Commit 4890f66

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🔍 GitHub Pages PR preview

Item Value
Site https://opengeos.org/pages-preview/GeoLibre/pr-1806/
Demo app https://opengeos.org/pages-preview/GeoLibre/pr-1806/demo/
Commit 4890f66

Note

GitHub Pages built this preview successfully, but its serving edge returned HTTP 403 when checked. The links may still be propagating.

* @returns True on Android/iOS (including desktop-UA iPadOS).
*/
const MOBILE_UA_PATTERN = /Android|iPhone|iPad|iPod/i;
const ANDROID_UA_PATTERN = /Android/i;

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.

Minor readability nit: the pre-existing JSDoc block just above this line documents isMobile, but the new isAndroid pattern/function/doc is now spliced in between it and the isMobile function it describes (lines 43+). A reader hits the isMobile doc comment immediately followed by unrelated isAndroid code. Consider moving the whole isAndroid block (pattern + doc + function) above the isMobile doc comment instead, so each doc stays adjacent to what it documents. Purely cosmetic — no functional impact. Confidence: low.

androidFilters: FileDialogFilter[] | undefined,
userAgent: string = typeof navigator !== "undefined" ? navigator.userAgent : "",
): FileDialogFilter[] {
return isAndroid(userAgent) && androidFilters !== undefined ? androidFilters : filters;

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.

Passing an explicit empty array (androidFilters: []) rather than omitting the property is the crux of this fix, and it relies on the Tauri Android dialog plugin treating a zero-length filter list the same as "no filters" (i.e. same as undefined) — showing all documents rather than, say, matching nothing. That's native (Kotlin/Rust) plugin behavior I can't verify from the JS side. The PR description says the author manually tested SLD/QML import on device, so this is presumably already confirmed in practice — flagging only as a low-confidence note in case this assumption needs re-checking on a future @tauri-apps/plugin-dialog upgrade.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Both inline comments posted successfully.

Code review

Bugs: None found. The Android-detection (isAndroid), filter-selection (nativeFileDialogFilters), and both call-site wirings (LayerPanel.tsx, StyleManagerPanel.tsx) are logically consistent — the androidFilters !== undefined check correctly avoids the truthiness pitfall of falling back to the default filters for an intentionally-empty array, and this is explicitly covered by a test. Content-based validation after selection (XML vs JSON, QML vs SLD sniffing, invalid-JSON handling) is unchanged and already handles arbitrary/garbage input gracefully, which matters more now that the Android picker is unfiltered. No other import call sites use SLD/QML extensions that were missed by this fix.

Security: None found. No new user input handling paths beyond what already existed (file content parsing is pre-existing code, untouched by this diff).

Performance: None found — this is UI-thread, one-shot dialog-filter selection with no measurable cost.

Quality:

  • Low confidence: in is-mobile.ts, the new isAndroid pattern/doc/function is inserted between the pre-existing JSDoc block and the isMobile function it documents, splitting them apart. Purely cosmetic; suggested reordering left inline.
  • Low confidence: nativeFileDialogFilters relies on the native Tauri Android dialog plugin treating an explicit empty filters: [] the same as "no filter" — this is native plugin behavior that can't be verified from the JS side alone, though the PR description indicates it was manually verified on-device for both SLD and QML, so this is more of a forward-looking note (e.g. on a future @tauri-apps/plugin-dialog bump) than a concern about this PR as submitted.

CLAUDE.md: No violations — no new user-facing strings requiring t(), no new external tile/map hosts, no touched files under the areas with special mirror/catalog rules (Whitebox catalog, MAX_VECTOR_* constants, etc.).

@giswqs
giswqs merged commit e06500c into main Aug 9, 2026
18 checks passed
@giswqs
giswqs deleted the fix/issue-1804-android-style-picker branch August 9, 2026 18:30
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.

[Bug]: Android file picker disables .sld and .qml files during style import

2 participants