Skip to content

feat(voice): implement Whisper model download management - #758

Merged
haiphucnguyen merged 3 commits into
mainfrom
feature/improvements
Oct 10, 2026
Merged

haiphucnguyen merged 3 commits into
mainfrom
feature/improvements

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

Summary

  • Introduce WhisperModelDownloadManager to centralize the Whisper model download lifecycle.
  • Update VoiceSettingsSection to trigger downloads via the new manager.
  • Add UI notifications to provide feedback for started, completed, and failed downloads.
  • Define new internal and user-facing events to track and communicate download progress.

Related Issue(s)

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactor (no functional change)
  • 🧪 Tests
  • 🔧 Chore / tooling / CI

What Changed & Why

How to Test

./gradlew test

Screenshots / Recordings (if applicable)

Checklist

  • I have read the CONTRIBUTING guide
  • My branch is up to date with main
  • I ran ./gradlew spotlessApply and ./gradlew detekt locally
  • I ran ./gradlew test and all tests pass
  • I added/updated tests for my changes (if applicable)
  • I added/updated documentation (if applicable)
  • My commits are signed off (DCO) — git commit -s
  • This PR is focused on a single feature/fix

Additional Notes

- Introduce `WhisperModelDownloadManager` to centralize the Whisper model download lifecycle.
- Update `VoiceSettingsSection` to trigger downloads via the new manager.
- Add UI notifications to provide feedback for started, completed, and failed downloads.
- Define new internal and user-facing events to track and communicate download progress.
- Add internationalized strings for download status messages across all supported locales.
Copilot AI balanced review requested due to automatic review settings October 10, 2026 20:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Returning Voice settings can miss completed downloads or fail to resume the active tier’s progress.

2 open findings
What changed in this PR

Centralizes Whisper model downloads so they persist across navigation and surface lifecycle notifications.

Changes:

  • Adds an app-scoped download manager and lifecycle events.
  • Integrates persistent progress into Voice settings.
  • Adds localized notification cards for download outcomes.
File Description
shared-jvm/​.../​user/​WhisperModelDownloadEvent.kt Defines user-facing lifecycle events.
shared-jvm/​.../​internal/​WhisperModelDownloadFileReadyEvent.kt Signals completed model availability.
desktop/​.../​VoiceSettingsSection.kt Integrates manager state and downloads.
desktop-shared/​.../​WhisperModelDownloadManager.kt Manages downloads, persistence, and cleanup.
desktop-shared/​.../​NotificationComponents.kt Displays download notifications.
desktop-shared/​.../​messages.properties Adds English notification labels.
desktop-shared/​.../​messages_de.properties Adds German translations.
desktop-shared/​.../​messages_es.properties Adds Spanish translations.
desktop-shared/​.../​messages_fr.properties Adds French translations.
desktop-shared/​.../​messages_ja_JP.properties Adds Japanese translations.
desktop-shared/​.../​messages_ko_KR.properties Adds Korean translations.
desktop-shared/​.../​messages_pt_BR.properties Adds Portuguese translations.
desktop-shared/​.../​messages_vi_VN.properties Adds Vietnamese translations.
desktop-shared/​.../​messages_zh_CN.properties Adds Simplified Chinese translations.
desktop-shared/​.../​messages_zh_TW.properties Adds Traditional Chinese translations.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Completion state can be missed, and persistence failures can incorrectly produce successful notifications while deleting the prior model.

1 open finding
1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Ignored config write failures cause model deletion and false success

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​WhisperModelDownloadManager.kt:84

AppConfig.updateField updates the in-memory cache but catches and only logs YAML write failures (AppConfig.kt:1170-1179). This code therefore deletes the previous model and emits a successful completion even when the new path was not persisted; after restart, the configured path can still point to the now-deleted model. Use a persistence API that reports/throws failures, and only delete the previous model and emit completion after the write succeeds.

This issue also appears on line 85 of the same file.

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Persistence failures and conflated download state can produce crashes, inconsistent configuration, and stale UI state.

3 open findings
1 resolved since last review
Previously missed (3)

In code that hasn't changed since last review

Medium severity Retained tier failures are hidden when reopening Settings

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​settings/​VoiceSettingsSection.kt:835

Only preferring an active state hides retained failures after navigation. If tier B fails while tier A remains configured, reopening this screen selects A, so B's downloadError is filtered out; selecting B then immediately calls clearError(), meaning the Settings UI never displays the failure. Initialize from the manager's tier for both active and failed states.

Medium severity Transient StateFlow transition can lose completed download state

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​settings/​VoiceSettingsSection.kt:850

A StateFlow does not guarantee observing this active→null transition: it conflates rapid updates. If the selected model file already exists (for example after the config was reset), download() returns immediately and the collector may only see null; lastActiveTier is never set, so the screen keeps the stale model path until it is recreated. Represent completed success (including its path) as a terminal manager state, or otherwise expose a replayable completion value instead of inferring success from a transient transition.

Medium severity Download completion event has no consumer

shared-jvm/​src/​main/​kotlin/​io/​askimo/​core/​event/​internal/​WhisperModelDownloadFileReadyEvent.kt:20

There is no consumer of this event in the repository; the only other references are its import/emission and a VoiceSettingsSection comment explaining that the screen deliberately does not collect it. Consequently it cannot refresh Settings as documented and adds a dead event contract. Either wire it to a real consumer (with replay if it must survive navigation) or remove the event and emission.

🧠 Review effort: Balanced

Comment on lines +1173 to +1174
val updatedYaml = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(cached)
Files.writeString(configPath, updatedYaml)
Comment on lines 1171 to +1174
val configPath = resolveOrCreateConfigPath()
if (configPath != null && configPath.exists()) {
try {
val updatedYaml = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(cached)
Files.writeString(configPath, updatedYaml)

log.debug("Updated {}={} in {}", path, value, configPath)
} catch (e: Exception) {
log.error("Failed to persist $path to config file", e)
}
val updatedYaml = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(cached)
Files.writeString(configPath, updatedYaml)
val path = WhisperModelDownloader.download(tier, baseUrl) { done, total ->
_state.value = _state.value?.copy(downloadedBytes = done, totalBytes = total)
}
AppConfig.updateField("voice.localWhisperModelPath", path.toString())
@haiphucnguyen
haiphucnguyen merged commit e9b5f54 into main Oct 10, 2026
12 of 13 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/improvements branch October 10, 2026 20:54
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.

2 participants