Skip to content

fix(chat): make the favorite star work in the voice assistant model picker - #398

Merged
yuga-hashimoto merged 1 commit into
mainfrom
claude/favorite-model-switch-bug-8aa78b
Oct 23, 2026
Merged

yuga-hashimoto merged 1 commit into
mainfrom
claude/favorite-model-switch-bug-8aa78b

Conversation

@yuga-hashimoto

Copy link
Copy Markdown
Owner

Summary

  • The voice assistant settings (Settings → Voice → assistant model) opened the shared model picker without passing favoriteModelKeys or onToggleFavorite. Both parameters had defaults (an empty set and a no-op), so that picker drew a star on every row that did nothing when tapped. The chat and schedule pickers passed them and toggled fine, which is why the star only failed "sometimes".
  • Thread the favorites from SettingsViewModel through SettingsNavGraph and VoiceSettingsScreen into the picker, so the voice picker shares the same favorites store as chat and schedules.
  • Drop the defaults on ModelAndRuntimePickerSheet.favoriteModelKeys / onToggleFavorite, so a caller that forgets them no longer compiles.

Test plan

  • ./gradlew :app:compileGithubDebugKotlin :app:compileGithubDebugAndroidTestKotlin
  • ./gradlew spotlessCheck (after spotlessApply fixed an import order in the test)
  • ./gradlew :app:testGithubDebugUnitTest — 1394 tests, 0 failures, 8 skipped
  • ModelAndRuntimePickerSheetInstrumentedTest on the API 36 emulator — 2 tests, 0 failed (includes the new tappingStarTogglesFavoriteWithoutSelectingModel)
  • Manual: open Settings → Voice → assistant agent picker, tap a star, confirm it fills and the model shows under Favorites; confirm the same model is starred in the chat picker

Note: the new instrumented test exercises the sheet's tap behavior (toggle without selecting the model). It would also have passed before this change, because the sheet itself was fine; the regression guard for the wiring bug is the removal of the defaults, which turns a missed call site into a compile error.

Pre-PR review

repo-reviewer is an OpenCode agent definition (.opencode/agents/repo-reviewer.md) and is not available as a subagent type in this Claude Code session. The review below was run by a read-only general-purpose subagent instructed to follow that definition exactly. It reviewed git diff origin/main...HEAD at commit 3b70257.

判定: APPROVE

ブロッカー

なし

提案(非ブロッキング)

  • app/src/main/java/com/yugahashimoto/andcode/feature/settings/VoiceSettingsScreen.kt:108, :133 — VoiceSettingsScreen 自体の favoriteModelKeys: Set<String> = emptySet() と onToggleFavoriteModel = { _, _ -> } にはデフォルト値が残っている。今回ピッカー側で潰した「渡し忘れでスターが無反応になる」問題が、1階層上で再発しうる。ただし本番の呼び出し元は SettingsNavGraph.kt:162 の1箇所だけで、そこは今回配線済み。残りの呼び出しはデフォルトを使う @Preview のみ。同ファイルの他のコールバックも全部デフォルト付きなので、ファイル内の流儀とは揃っている。直すなら必須化したうえで Preview(VoiceSettingsScreen.kt:1092 付近)にも渡す。やらなくてもマージ可。
  • hidden / recent を音声画面のピッカーに渡していない件は、今回の回帰ではなく非ブロッキングの提案。
    • hidden: 音声ピッカーは元から hiddenModelKeys を一度も渡していない(diff 前の呼び出しにも無い)。既存の挙動で、今回の変更で悪化していない。渡すなら ChatHomeScreen / ScheduleEditorScreen と同じく providerModelList == true でゲートする必要がある。
    • recent: recentModelKeys を書き込むのは AppPreferencesRepository.selectModel のみ(チャット側)。音声側の setAssistantModel は recent を記録しないため、渡すと意味が曖昧になる。別 PR で仕様を決めてからにするのがよい。
    • 結論: 今回の PR のスコープ(スターが効くこと)では不要。

チェック済み項目

  • ModelAndRuntimePickerSheet の全呼び出し箇所(定義を除く5箇所)が新しい必須引数 2 つを渡している。ChatHomeScreen.kt:768 と ScheduleEditorScreen.kt:547 は元から渡していた。VoiceSettingsScreen.kt:650 は今回追加。androidTest の2箇所は明示的に渡している。位置引数の呼び出しは無い。
  • VoiceSettingsScreen への配線: 呼び出し元は SettingsNavGraph.kt:162(本番)と Preview の2箇所。SettingsNavGraph は settingsState.favoriteModelKeys と settingsViewModel::toggleFavoriteModel を渡し、AssistantTargetSection 経由でピッカーまで抜けなく渡っている。settingsState は collectAsState() された値なので、トグル後に再コンポーズされスターの塗りが更新される。
  • トグル先のロジック: SettingsViewModel.toggleFavoriteModel → AppPreferencesRepository.toggleFavoriteModel が "$providerId/$modelId" をトグルして永続化。キー形式はピッカーの判定と一致し、チャット・スケジュール画面と共有ストア。
  • i18n: app/src/main/res 配下の変更なし。新規のユーザー向け文字列なし。R.string.cd_favorite は既存キーで全8ロケールに存在する。
  • テスト: 新規テストは cd_favorite の content description でスターを特定し、「トグルされ、選択は起きない」をコード上も裏付けている。追加 import は全て使用されている。
  • ブランチは origin/main 起点の1コミットで、ワークツリー規約に違反していない。シークレットの混入なし。
  • 範囲外: ktlint/detekt はレビュアーでは実行していない(読み取り専用のため)。spotlessCheck は作成者がローカルで実行して通過済み。

🤖 Generated with Claude Code

…icker

The voice assistant settings opened the shared model picker without passing
favoriteModelKeys or onToggleFavorite. Both had defaults (an empty set and a
no-op), so that picker drew a star on every row that did nothing when tapped,
while the chat and schedule pickers toggled fine.

Thread the favorites from SettingsViewModel through SettingsNavGraph and
VoiceSettingsScreen into the picker, and drop the defaults so a caller that
forgets them no longer compiles. Add an instrumented test that tapping the
star toggles the favorite without selecting the model.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@yuga-hashimoto
yuga-hashimoto merged commit 4d1fa4d into main Oct 23, 2026
4 checks passed
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.

1 participant