Repository navigation
feat: Add keyboard shortcuts and accessibility improvements - #707
Conversation
- Added keyboard shortcuts for toggling last response playback and focusing the message list. - Implemented accessibility features such as `accessibleFocusable` for better keyboard navigation. - Updated internationalization files to include new shortcut descriptions. - Enhanced `VoiceSettingsSection` with animated visibility and additional UI components. - Added a new `KeyboardShortcutsDialog` for displaying keyboard shortcuts information.
There was a problem hiding this comment.
🟡 Changes recommended
The cached voice playback path can throw an uncaught VoiceServiceException, potentially leaving UI state stuck (e.g., loadingMessageId) and failing without showing an error.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds new global keyboard shortcuts and improves keyboard accessibility across the desktop UI, including a dedicated “Keyboard Shortcuts” dialog and better focus visibility for icon-only controls. It also introduces an in-memory TTS playback cache with configurable bounds to reduce repeat synthesis calls when replaying recent AI responses.
Changes:
- Added new keyboard shortcuts (show shortcuts dialog, toggle last response playback, focus message list) and surfaced them via Help menu + a new dialog.
- Improved keyboard navigation/focus visibility via
accessibleFocusableand message-list focus targeting. - Added configurable bounds for an in-memory TTS audio playback cache, with UI controls and i18n updates.
File summaries
| File | Description |
|---|---|
| shared/src/main/kotlin/io/askimo/core/config/AppConfig.kt | Adds voice playback cache configuration fields and update parsing. |
| desktop/src/main/kotlin/io/askimo/desktop/shell/ComposeTopMenuBar.kt | Adds a Help-menu entry to open the keyboard shortcuts dialog. |
| desktop/src/main/kotlin/io/askimo/desktop/settings/VoiceSettingsSection.kt | Adds UI controls for TTS cache limits and a reusable validated int field. |
| desktop/src/main/kotlin/io/askimo/desktop/Main.kt | Wires the new dialog into app state + shortcut handling + menu actions. |
| desktop-shared/src/main/resources/i18n/messages.properties | Adds new menu/shortcut/cache-related strings (base locale). |
| desktop-shared/src/main/resources/i18n/messages_zh_TW.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/resources/i18n/messages_zh_CN.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/resources/i18n/messages_vi_VN.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/resources/i18n/messages_pt_BR.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/resources/i18n/messages_ko_KR.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/resources/i18n/messages_ja_JP.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/resources/i18n/messages_fr.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/resources/i18n/messages_es.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/resources/i18n/messages_de.properties | Adds translations for the new menu/shortcut/cache-related strings. |
| desktop-shared/src/main/kotlin/io/askimo/ui/shell/NativeMenuBar.kt | Adds macOS native Help-menu shortcut entry for the shortcuts dialog. |
| desktop-shared/src/main/kotlin/io/askimo/ui/shell/KeyboardShortcutsDialog.kt | Introduces the new global keyboard shortcuts “cheat sheet” dialog. |
| desktop-shared/src/main/kotlin/io/askimo/ui/settings/ShortcutsSettingsSection.kt | Extracts reusable shortcuts list UI for settings + dialog reuse. |
| desktop-shared/src/main/kotlin/io/askimo/ui/common/ui/ModifierExtensions.kt | Adds accessibleFocusable for a clearer keyboard focus ring. |
| desktop-shared/src/main/kotlin/io/askimo/ui/common/keymap/KeyMapManager.kt | Registers new shortcuts and their display strings/category placement. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/MessageComponents.kt | Adds bounded in-memory TTS audio caching + focus-ring for playback button. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatViewModel.kt | Invalidates cached TTS audio when a message is edited. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatView.kt | Implements message-list focus shortcut and “toggle last response playback”. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatInputField.kt | Adds focus-ring to mic/send icon buttons for keyboard accessibility. |
Review details
- Files reviewed: 23/23 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @Synchronized | ||
| private fun cacheChunks(messageId: String, chunks: List<ByteArray>) { | ||
| ttsCache.remove(messageId) // re-insert at the end (most-recent) if already present | ||
| ttsCache[messageId] = chunks | ||
| val maxMessages = AppConfig.voice.ttsCacheMaxMessages | ||
| val maxBytes = AppConfig.voice.ttsCacheMaxBytes | ||
| val iterator = ttsCache.entries.iterator() | ||
| while (iterator.hasNext() && (ttsCache.size > maxMessages || cacheTotalBytes() > maxBytes)) { | ||
| iterator.next() | ||
| iterator.remove() | ||
| } | ||
| } |
| playbackJob = scope.launch { | ||
| val thisJob = coroutineContext[Job] | ||
| try { | ||
| val ttsService = withContext(Dispatchers.IO) { VoiceServiceRegistry.textToSpeech(AppConfig.voice) } | ||
| playCachedChunks(messageId, cached, ttsService.outputFormat) | ||
| } catch (e: AudioPlaybackException) { | ||
| if (playingMessageId != messageId) return@launch | ||
| loadingMessageId = null | ||
| playingMessageId = null | ||
| onError(e.message ?: "Voice playback failed") | ||
| } finally { | ||
| if (playbackJob === thisJob) playbackJob = null | ||
| } |
| }, | ||
| textStyle = AppTextStyles.body, | ||
| singleLine = true, | ||
| isError = isEditing && textValue.toIntOrNull()?.let { it < minValue } ?: (textValue.toIntOrNull() == null), |
accessibleFocusablefor better keyboard navigation.VoiceSettingsSectionwith animated visibility and additional UI components.KeyboardShortcutsDialogfor displaying keyboard shortcuts information.