:library:feature:changelog

Purpose

Owns changelog retrieval and presentation: the package-aware Markdown fetch, its legacy fallback, and the bottom sheet that renders it.

Owns

  • ChangelogPreferencesDataSource and its default in data/local, using the shared settings file.

  • ChangelogRepository and DefaultChangelogRepository, including selection of the Android App Metadata API call and the legacy GitHub fallback.

  • GetChangelogUseCase, which picks the current-version section or the full history, and extractChangesForVersion, which finds that section's heading.

  • ChangelogViewModel, ChangelogUiState (whose markdown is a Loadable), and ChangelogEvent.Load, sent on start and on retry.

  • ChangelogDialog, in feature.changelog.ui, the modal bottom sheet the host shows from its drawer, and the stateless ChangelogDialogContent it draws inside the sheet. The content draws each part of the Markdown on its own and the Toolkit's HorizontalWavyDivider where the Markdown has a rule (splitAtThematicBreaks), in place of the renderer's flat line. ChangelogDialog(releasesUrl) adds an info button beside the title that opens that page, such as GithubConstants.APP_TOOLKIT_RELEASES; without one the sheet shows no button.

Does not own

  • The drawer entry that opens the dialog, owned by :library:navigation and the host shell.

  • In-app update triggering, owned by :library:integration:update.

  • The About screen and its metadata, owned by :library:feature:about.

Depends on

  • :library:core:common, :library:core:datastore, :library:core:network, and :library:core:ui for shared state, persistence, HTTP, and Compose.

  • compose-markdown to render the fetched Markdown.

Used by

  • :library:apptoolkit and :sample.

Flow chart

flowchart TD
    Dialog[ChangelogDialog] --> VM[ChangelogViewModel]
    Dialog --> Content[ChangelogDialogContent]
    VM --> UseCase[GetChangelogUseCase]
    UseCase --> Repo[ChangelogRepository]
    Repo --> Api[App metadata API]
    Repo --> Legacy[Legacy GitHub changelog]
    Content -->|retry| Load[ChangelogEvent.Load]
    Load --> VM

Architectural decisions

  • The dialog is on core.ui.screen. ChangelogRepository.getChangelog returns the Markdown or throws a NetworkException, the use case passes a failure through, and ChangelogViewModel maps it with toFailed: an offline device sees the offline text, anything else the changelog's own, and the sheet's action retries only a failure that a retry can fix. A changelog with nothing in it is Loadable.Empty, shown as no new updates. Neither the ViewModel nor the repository needs a dispatcher: Ktor suspends.

  • The package endpoint is authoritative and the legacy URL is a compatibility fallback, used only when the package name is blank or the endpoint answers 404, so a host that has not been published to the metadata API still shows release notes.

  • Heading selection and thematic-break splitting share a fence scanner. Backtick and tilde fences close only with the same marker, a sufficient run length and a blank suffix. Code examples do not create version boundaries or dividers.

  • The use case prefers the current version's section but falls back to the full history, so a version-format mismatch never hides content that was fetched successfully.

  • The sheet keeps its header and action fixed while the body scrolls, so long release notes cannot push the dismissal action off-screen.

  • Shared button labels come from :library:core:ui rather than being duplicated here.

Public contracts

  • ChangelogPreferencesDataSource and its default in data/local, using the shared settings file.

  • ChangelogRepository, GetChangelogUseCase, ChangelogViewModel, ChangelogUiState, ChangelogEvent, ChangelogDialog, and changelogModule. ChangelogDialogContent is internal.

Internal implementations

  • HTTP fetch in data/remote/ChangelogRemoteDataSource, its data/remote/models/MarkdownResponse, status-to-NetworkException mapping, fallback selection, and Markdown rendering.

Current risks

The legacy fallback keeps a second source of truth alive. Until every host is published to the metadata API, a 404 silently changes which document the user reads.

Markdown ownership

Version-section parsing lives beside GetChangelogUseCase; thematic-break parsing lives in ui/extensions/ChangelogMarkdownExtensions.kt. The former utils/extensions/ChangelogExtensions.kt is removed. DefaultChangelogRepository takes ChangelogRemoteDataSource directly instead of an HttpClient. Callers constructing the repository directly must update that argument; the feature's Koin module supplies it automatically.

Packages