Skip to content

Enable user-defined appstore sources#299

Open
ttmm-sp-zoo wants to merge 2 commits into
coredevices:masterfrom
ttmm-sp-zoo:user-defined-appstore-sources
Open

Enable user-defined appstore sources#299
ttmm-sp-zoo wants to merge 2 commits into
coredevices:masterfrom
ttmm-sp-zoo:user-defined-appstore-sources

Conversation

@ttmm-sp-zoo

Copy link
Copy Markdown

Two small changes that unlock functionality already implemented in the app, so that third-party appstore feeds can be used end to end. No refactoring.

1. Enable the "Add Source" / "Delete Source" UI

AppstoreSettingsScreen.kt

The Add Source FAB and the per-source delete button were fully implemented but commented out. CreateAppstoreSourceDialog, AppstoreSettingsScreenViewModel.addSource/removeSource and AppstoreSourceDao are already wired up, so this only uncomments the UI entry points.

Delete is deliberately offered only for user-added sources, guarded with the existing isPebbleFeed() / isRebbleFeed() helpers. Removing a built-in feed is unsafe today: deleting the Rebble source strands the user, as AppstoreSourceInitializer never re-adds it, while deleting the Pebble source trips that initializer's re-init path, which deletes and recreates every source and would silently drop user-added ones. Happy to drop this guard if you'd rather handle it differently.

The entered URL is normalized (trim().trimEnd('/')) to the same canonical form as the built-in feed constants. Until now every AppstoreSource.url came from INITIAL_APPSTORE_SOURCES, so it was canonical by construction; this dialog is the first path where the value is typed by a user. The URL is string-concatenated into request URLs ("${source.url}/v1/apps/id/$id") and equality-compared in addHeart() / isLoggedIn(), so a pasted trailing slash would otherwise yield .../api//v1/apps/id/... and a source that looks correct but silently serves nothing.

2. Let appstore deep links specify the feed to open from

PebbleDeepLinkHandler.kt

handleAppstore() already takes the feed URL as a parameter and resolves it against the enabled sources — only the call site was fixed to https://appstore-api.rebble.io/api. As a result an app card could only ever be opened from Rebble.

The feed is now read from an optional ?source= query parameter:

pebble://appstore/{id}?source=https://apps.ttmm.is/api
  • Existing links are unaffected. With no ?source=, the handler falls back to the Rebble feed exactly as before (the inline URL is replaced by the REBBLE_FEED_URL constant it duplicated).
  • Unknown or disabled feeds are handled. The source is matched against enabled sources only; anything else resolves to no store and hits the handler's existing "Failed to find app in enabled feeds" message. No new failure path.

?source= matches the stored source URL exactly, so a link must use the same URL the source was added with — in the canonical, no-trailing-slash form the dialog now stores.

Why

Third-party appstore feeds work today apart from this last mile. A working example is apps.ttmm.is — a store for TTMM watchfaces serving the full store API (per-platform descriptions, screenshots, collections). Browsing → installing a .pbw → loading the watchface config already works end to end on a physical device. What's missing is the ability to add the feed in the official app and to open an app card from it.

This was agreed by email with Eric Migicovsky.

How to test

  1. Appstore Sources → tap the + FAB → add a source, e.g. name TTMM, URL https://apps.ttmm.is/api. Adding it with a trailing slash or surrounding whitespace should behave identically.
  2. The source appears with its collections and can be enabled/disabled. User-added sources can be removed with the delete button; the built-in Pebble and Rebble feeds cannot.
  3. Open pebble://appstore/{id}?source=https://apps.ttmm.is/api for an app id served by that feed — the card opens from that source instead of failing against Rebble. Install the .pbw from the card and confirm it loads on the watch.
  4. Regression: pebble://appstore/{id} with no ?source= still opens the Rebble card while the Rebble source is enabled.
  5. Error path: ?source= pointing at a disabled or unknown feed shows "Failed to find app in enabled feeds" and does not navigate.

Testing status — please read

This has not been built or run. The change is written and reviewed statically, but no JDK or Android SDK was available in the environment used, so neither the Kotlin compile, the existing test suite, nor a device run were executed. It needs a real build and an on-device pass before merging.

No tests were added. PebbleDeepLinkHandlerTest currently covers only the pure parseTokenFrom helper; exercising handleAppstore would need fakes for LibPebble, analytics and the source DAO, and writing tests I cannot execute seemed worse than saying so plainly. Happy to add coverage if you want it in this PR.

@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

ttmm-sp-zoo and others added 2 commits July 17, 2026 19:40
The Add Source FAB and the per-source delete button were implemented but
commented out. The backing code (CreateAppstoreSourceDialog, addSource,
removeSource, AppstoreSourceDao) is already wired up, so this just enables
the UI.

Delete is offered only for user-added sources: removing a built-in feed
either strands the user (the Rebble source is never re-added by
AppstoreSourceInitializer) or trips its re-init path, which deletes and
recreates every source, silently dropping user-added ones.

Normalize the entered feed URL to the same canonical form as the built-in
feeds. It is string-concatenated into request URLs ("${source.url}/v1/...")
and compared for equality in addHeart()/isLoggedIn(), so a pasted trailing
slash or stray whitespace would otherwise produce a source that looks right
but silently fails to serve apps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
pebble://appstore/{id} was hardcoded to the Rebble feed URL, so an app
card could only ever be opened from Rebble. handleAppstore() already takes
the feed URL as a parameter and resolves it against the enabled sources;
only the call site was fixed to Rebble.

Read the feed from an optional ?source= query parameter, falling back to
the Rebble feed when absent, so existing links keep working unchanged. A
source that is unknown or not enabled resolves to no store and hits the
existing "Failed to find app in enabled feeds" path.

Also replaces the inline Rebble URL with the existing REBBLE_FEED_URL
constant it duplicated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ttmm-sp-zoo
ttmm-sp-zoo force-pushed the user-defined-appstore-sources branch from 7d458a5 to 53c1930 Compare July 17, 2026 17:40
@ttmm-sp-zoo
ttmm-sp-zoo marked this pull request as ready for review July 17, 2026 18:00
@ericmigi
ericmigi requested a review from sjp4 July 18, 2026 20:58
@ericmigi

Copy link
Copy Markdown
Contributor

is https://apps.ttmm.is/api up?
CleanShot 2026-07-18 at 13 59 05@2x

@ttmm-sp-zoo

ttmm-sp-zoo commented Jul 18, 2026 via email

Copy link
Copy Markdown
Author

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.

3 participants