PR1: data-driven voice-action registry (Telegram as first built-in) - #58
Merged
Conversation
First step of generalizing named voice actions: replace the hardcoded
enum Action/actionPhrases + the single editable telegramPostPrompt with a
data-driven registry, so built-in and pack/user actions share one mechanism and
packs can later add NEW actions (not only retune Telegram).
- VoiceAction {id, displayName, triggerPhrases, prompt} + VoiceActionRegistry
(allPhrases, action(id:), merging(_:) — override-by-id / append-new) in
OpenWhispCore (Codable, so packs can carry actions later). Built-in Telegram
action holds the exact phrases + default prompt that used to live in AppState.
- VoiceCommandParser: Result.action: Action? -> actionID: String?; matches
against an injected registry (default .builtins), phrases tried longest-first
so a specific phrase beats a substring. Wake/imperative/generic paths unchanged.
- AppState: applyVoiceCommand looks up the action by id and uses its prompt; new
computed voiceActionRegistry overlays the user's editable telegramPostPrompt
onto the builtins (empty or == default -> builtins). defaultTelegramPostPrompt
is now an alias to VoiceAction.defaultTelegramPostPrompt.
- Adversarial review: Telegram path + generic path behavior-identical (all 12
EN/RU phrases preserved, default prompt byte-identical, directive identical in
empty/default/custom cases). Only change is a cosmetic status string.
- Tests: +10 (VoiceAction registry merge/override/codable, custom-action triggers
by id, longest-phrase-wins); parser tests migrated to actionID. 181 -> 191.
No behavior change for users; this only adds the extensibility seam packs use next.
swift test 191/191; ./build.sh clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step of generalizing named voice actions. Replaces the hardcoded
enum Action { case telegramPost }+actionPhrasestable + single editabletelegramPostPromptwith a data-driven registry, so built-in and pack/user actions share one mechanism — and packs can later add new actions (tweet, commit message…), not only retune the Telegram prompt.This is behavior-preserving; it only adds the extensibility seam PR2 (packs) will use.
Changes
VoiceAction{id, displayName, triggerPhrases, prompt}+VoiceActionRegistry(allPhrases,action(id:),merging(_:)= override-by-id / append-new) in OpenWhispCore,Codableso actions can travel in a pack later. The built-in Telegram action carries the exact phrases + default prompt that used to live in AppState.VoiceCommandParser:Result.action: Action?→actionID: String?; matches an injected registry (default.builtins), phrases tried longest-first so a specific phrase beats a substring. Wake / imperative / generic paths unchanged.applyVoiceCommandlooks up the action by id and uses its prompt; new computedvoiceActionRegistryoverlays the user's editabletelegramPostPromptonto the builtins.defaultTelegramPostPromptbecomes an alias.actionID. 181 → 191.swift test191/191 ·./build.shclean.🤖 Generated with Claude Code