kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Detect community library channel updates via v2 API

Open rtibbles opened this issue 7 months ago • 2 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Kolibri currently checks for channel updates by querying Studio's v1 API for the latest published version and comparing it against the installed version. For community library channels, this is incorrect — a newer published version may not be approved for the community library. Instead, community library channel updates should be detected by checking the v2 API for the current approved version.

Complexity: Medium Target branch: release-v0.19.x

Context

The frontend checks for updates via RemoteChannelResource (backed by RemoteChannelViewSet in kolibri/core/content/api.py), which queries the v1 API by channel ID. The returned version is compared against the installed version — if the remote version is higher, an update indicator is shown.

For community library channels (where ChannelMetadata.library == "COMMUNITY"), the v2 API at /api/public/v2/channel/ provides the current approved version. This can be queried with ?public=false to get community library channels.

Key files:

  • kolibri/plugins/device/frontend/views/ManageContentPage/api.js:getChannelOnStudio — fetches remote channel by ID
  • kolibri/core/content/api.py:RemoteChannelViewSet — proxies requests to Studio v1 API

The Change

Update RemoteChannelViewSet in kolibri/core/content/api.py to check the installed channel's library field. For community library channels, query the v2 API (?public=false) for the approved version instead of the v1 API. This is transparent to the frontend — the response format remains the same.

How to Get There

RemoteChannelViewSet._make_channel_endpoint_request in kolibri/core/content/api.py currently always queries the v1 API. When checking a specific channel (the retrieve method), look up the installed ChannelMetadata for that channel ID. If library == "COMMUNITY", query the v2 API endpoint instead and map the response to the same format via _studio_response_to_kolibri_response.

Acceptance Criteria

  • [ ] For installed community library channels, update checks query the v2 API for the approved version
  • [ ] For non-community channels, update checks continue to use the v1 API
  • [ ] The frontend is unaware of the different update check path — response format is unchanged
  • [ ] The v2 API response is mapped to the same Kolibri response format as v1 via _studio_response_to_kolibri_response (or a v2 variant)

Testing

  • [ ] Tests cover update check for a community library channel returns the v2 approved version
  • [ ] Tests cover update check for a regular channel still uses v1

References

  • learningequality/studio#5772 — Added channel version token support to Studio's v1 public channel endpoint

AI usage

Used Claude Code to draft this issue interactively. I provided the requirements and Claude explored the Kolibri device plugin frontend and backend to understand the update detection flow. All content reflects my decisions and was reviewed section by section.

rtibbles avatar Apr 12 '26 00:04 rtibbles

Plan: Make RemoteChannelViewSet.retrieve() query Studio's v2 API for community library channels instead of v1, so the approved version (not just the latest published version) is used for update detection.

  • [ ] Bump content schema version and update import machinery
  • [ ] Add library field to base_models.py, run generate_schema, generate migration
  • [ ] Add get_v2_channel_lookup_url to paths.py
  • [ ] Update RemoteChannelViewSet.retrieve() to use v2 for community channels

status


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Apr 15 '26 02:04 rtibblesbot

Fixed in #14608

rtibbles avatar Apr 15 '26 18:04 rtibbles