Skip to content

[codex] Preserve photo-picker fallback extension#533

Merged
vinceglb merged 1 commit intomainfrom
codex/photo-picker-fallback-extension
Mar 9, 2026
Merged

[codex] Preserve photo-picker fallback extension#533
vinceglb merged 1 commit intomainfrom
codex/photo-picker-fallback-extension

Conversation

@vinceglb
Copy link
Owner

@vinceglb vinceglb commented Mar 8, 2026

This fixes the Android photo-picker regression behind issue #526.

On Android photo-picker URIs, FileKit tries to replace synthetic picker names like 18.jpg with the real MediaStore display name. That is the right first choice because it preserves the user-visible filename when the lookup succeeds. The problem is the failure path: when the MediaStore query is blocked or returns no row, simply surfacing the synthetic picker display name restores the extension but reintroduces the ambiguity that the stable fallback was meant to avoid. Different picker URIs can still be distinct files even when they expose the same synthetic display name pattern, so reusing that value directly is not a safe fallback.

The root cause was that the fallback strategy mixed together two separate concerns: preserving uniqueness and preserving the extension. The provider/id-based fallback solved the uniqueness problem, while the synthetic picker name still contained useful extension metadata. Treating the whole synthetic name as the final fallback discarded the stability guarantees; treating only the provider/id fallback as final discarded the extension.

This change keeps the existing priority order. FileKit still prefers the real MediaStore display name when it can resolve it, and still returns non-synthetic openable display names directly. When the URI is a photo-picker URI and only a synthetic picker display name is available, the code now keeps the stable provider/id-based fallback name and appends only the synthetic extension if one exists. That produces names such as photopicker-18.jpg, which remain stable and distinct while allowing PlatformFile.extension to stay populated.

The Android host tests were updated to cover the intended contract: MediaStore lookup failures now resolve to a stable fallback with the original extension, the no-display-name case still falls back to the stable provider/id name without an extension, and multiple synthetic picker names still resolve to distinct stable names.

Validation used ./gradlew :filekit-core:testAndroidHostTest --tests 'io.github.vinceglb.filekit.PlatformFileAndroidTest' and ./gradlew :filekit-core:check, both of which passed.

@vinceglb
Copy link
Owner Author

vinceglb commented Mar 8, 2026

@codex review this

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@vinceglb vinceglb marked this pull request as ready for review March 9, 2026 01:14
@vinceglb vinceglb merged commit c4eb995 into main Mar 9, 2026
10 checks passed
@vinceglb vinceglb deleted the codex/photo-picker-fallback-extension branch March 9, 2026 01:14
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.

1 participant