Skip to content

Create apple-touch-icon if none exists#937

Merged
chrisvire merged 2 commits intosillsdev:mainfrom
chrisvire:fix/apple-convert-icon
Feb 9, 2026
Merged

Create apple-touch-icon if none exists#937
chrisvire merged 2 commits intosillsdev:mainfrom
chrisvire:fix/apple-convert-icon

Conversation

@chrisvire
Copy link
Member

@chrisvire chrisvire commented Feb 9, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved backward compatibility for older app versions: if iOS icons are missing, the system now derives and resizes available Android icons to create the required iOS icon, and reports an error when none can be found (when verbose mode is enabled).
  • Chores

    • Added an image-processing library to support automatic icon generation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Warning

Rate limit exceeded

@chrisvire has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 37 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds sharp as an image-processing dependency and implements a compatibility path in convert/convertMedia.ts that, for program versions <13.4, generates apple-touch-icon.png by resizing an available Android icon; also replaces throw Error(...) with throw new Error(...).

Changes

Cohort / File(s) Summary
Dependency
package.json
Added sharp (^0.34.5) to devDependencies for image processing.
Icon generation & error handling
convert/convertMedia.ts
Added compatibility branch for versions <13.4 that, when apple-touch-icon.png is missing, searches for icon-512.png, icon-192.png, or icon-144.png, resizes the first found to 180×180 using sharp, writes src/gen-assets/icons/apple-touch-icon.png, and uses throw new Error(...) for explicit errors. Logic added in two locations to ensure generation when needed.

Sequence Diagram(s)

sequenceDiagram
    participant Convert as convertMedia
    participant FS as FileSystem
    participant Sharp as sharp
    participant Version as VersionCheck

    Convert->>Version: check program version
    Version-->>Convert: version < 13.4?
    alt version < 13.4
        Convert->>FS: stat `src/gen-assets/icons/apple-touch-icon.png`
        FS-->>Convert: file exists? (no)
        Convert->>FS: find Android icons (`icon-512.png`, `icon-192.png`, `icon-144.png`)
        FS-->>Convert: return first match or none
        alt found an Android icon
            Convert->>Sharp: open & resize to 180x180
            Sharp-->>Convert: resized image buffer
            Convert->>FS: write `src/gen-assets/icons/apple-touch-icon.png`
            FS-->>Convert: write complete
        else none found
            Convert-->>Convert: throw new Error("apple-touch-icon missing and no Android icon found")
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
Sharp paws trim pixels small,
Android seeds that answer call,
Apple icons rise from fall,
Backward paths now charm them all. 🎨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Create apple-touch-icon if none exists' directly and accurately describes the main change in the pull request: adding logic to generate an apple-touch-icon when it's missing by deriving it from Android icons.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@convert/convertMedia.ts`:
- Around line 163-165: Fix the typo in the inline comment inside the
version-check block that uses compareVersions(configData.data.programVersion!);
change the comment text from "app-touch-icon.png" to the correct
"apple-touch-icon.png" so the comment accurately describes the required file
referenced by src/routes/+layout.svelte.
- Around line 176-178: In convertMedia, the sharp(androidIcon).resize(180,
180).toFile(...) call is not awaited; update the convertMedia function to await
that Promise (or return it) so the file write completes before downstream tasks
and so errors surface as rejections from convertMedia; specifically locate the
sharp chain that writes 'apple-touch-icon.png' and prepend/handle with await and
propagate or catch/log the error appropriately.
- Around line 170-175: The current logic builds preferredAndroidIconSizes and
sets androidIcon by mapping to paths and using .find(...) ?? path.join(...
'icon-512.png'), which can still point to a non-existent file; change this to
capture the result of the .find into a variable (e.g., foundAndroidIcon) and if
it's undefined either skip icon generation/log a warning via your logger or
explicitly verify that path.join(androidIconFolder, 'icon-512.png') exists
before using it; update uses of androidIcon (in functions like convertMedia or
any call sites) to only proceed when a real file path was found, otherwise
return/skip the Android icon generation and emit a clear warning.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 `@convert/convertMedia.ts`:
- Around line 178-180: The code currently only throws when missing an Android
icon if the verbose flag is truthy (the "else if (verbose)" branch) causing
silent failures in quiet mode; change the conditional to an unconditional else
so the Error('No Android icon found to generate apple-touch-icon.png') is always
thrown when no source icon is available (replace "else if (verbose)" with "else"
in the block that throws), ensuring the conversion path in convertMedia.ts fails
fast and surfaces the missing-icon error.

@chrisvire chrisvire force-pushed the fix/apple-convert-icon branch from dc081b7 to 4fadcfd Compare February 9, 2026 22:17
@chrisvire chrisvire merged commit ffa449d into sillsdev:main Feb 9, 2026
4 checks passed
@chrisvire chrisvire deleted the fix/apple-convert-icon branch February 9, 2026 22:25
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