Skip to content

Apps: normalize filetype associations to bare lowercase extensions - #3479

Merged
jelveh merged 2 commits into
mainfrom
apps/normalize-filetype-associations
Jul 30, 2026
Merged

Apps: normalize filetype associations to bare lowercase extensions#3479
jelveh merged 2 commits into
mainfrom
apps/normalize-filetype-associations

Conversation

@jelveh

@jelveh jelveh commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

Apps with filetype associations stored in dotted form (e.g. .docx) never show up in the Open With menu or other app suggestions for matching files.

SuggestedAppsService extracts the bare lowercase extension from the filename (docx) and AppStore.getAppsByFiletype matched app_filetype_association.type against it with an exact equality check. But the write path (setFiletypeAssociations, fed by Dev Center / puter-js app create/update) stored whatever string the developer typed, verbatim. Anyone who entered .docx instead of docx got association rows that could never match, and their app silently dropped out of suggestions. In production roughly one fifth of all association rows are stored in the dotted form, so this is a common failure mode (it is how word-processor went missing from Open With for doc/docx files).

Fix

Both sides are handled in AppStore, the single choke point for reads and writes:

  • Write canonicalization: setFiletypeAssociations now trims, lowercases, strips leading dots, dedupes, and drops entries that normalize to nothing before inserting. Cache invalidation keys are normalized the same way.
  • Read tolerance: getAppsByFiletype normalizes the requested extension, matches both the bare and dotted forms (docx and .docx), and dedupes apps associated under both. Existing dotted rows start working immediately, no data migration required. A follow-up cleanup migration of legacy rows is possible later but no longer a prerequisite.

Tests

  • 6 new tests in AppStore.test.js covering write canonicalization, empty-input handling, legacy dotted-row matching, both-forms dedupe, requested-extension normalization, and empty-extension behavior.
  • Updated 2 AppDriver tests that asserted the old verbatim round-trip of dotted input.
  • AppStore, AppDriver, and SuggestedAppsService suites pass (101 tests).

Suggested-apps lookups match app_filetype_association rows against the
bare lowercase extension ('docx'), but writes stored whatever the
developer typed. Rows like '.docx' never matched, so those apps
silently dropped out of Open With suggestions.

AppStore now canonicalizes on write (trim, lowercase, strip leading
dots, dedupe, drop empties) and tolerates the dotted legacy form on
read: getAppsByFiletype normalizes the requested extension, matches
both 'docx' and '.docx', and dedupes apps associated under both forms.
Cache invalidation keys are normalized the same way. Existing dotted
rows work without a data migration.
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 77.64%
⬆️ +0.01%
17227 / 22186
🔵 Statements 75.95%
⬆️ +0.01%
18345 / 24153
🔵 Functions 74.39%
🟰 ±0%
2867 / 3854
🔵 Branches 64.66%
⬆️ +0.02%
12122 / 18747
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/backend/stores/app/AppStore.js 66.55%
⬆️ +0.58%
54.49%
⬆️ +0.84%
77.77%
🟰 ±0%
67.69%
⬆️ +0.57%
176, 210, 229, 247-251, 262, 282, 283, 318-319, 322-323, 338-340, 375-376, 379-382, 412, 419, 434, 491-502, 506-508, 519, 572, 592, 605, 669-670, 759, 776-778, 799, 861, 878, 882, 885, 890, 892, 896, 908, 928, 934, 961, 963, 976, 998, 1017, 1123-1144, 1151, 1197-1500
Generated in workflow #625 for commit 6dc448d by the Vitest Coverage Report Action

Adjust apps API tests to match current normalization behavior for `filetypeAssociations`: extension values are stored as lowercase bare extensions (e.g. `.txt` -> `txt`), while MIME types remain unchanged. Added inline comments in both test suites to document this expected remap.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for puter.js SDK

Status Category Percentage Covered / Total
🔵 Lines 36.04%
⬆️ +0.05%
2126 / 5898
🔵 Statements 35.07%
⬆️ +0.04%
2218 / 6323
🔵 Functions 32.42%
⬆️ +0.09%
359 / 1107
🔵 Branches 28.28%
⬇️ -0.02%
1195 / 4225
File CoverageNo changed files found.
Generated in workflow #101 for commit 6dc448d by the Vitest Coverage Report Action

@jelveh
jelveh merged commit f34c4dc into main Jul 30, 2026
8 checks passed
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