Repository navigation
feat(chat): offer plugin-defined primary agents in the mode picker - #2
Merged
Merged
Conversation
The mode chip only listed build/plan, so primaries registered by OpenCode plugins (e.g. oh-my-opencode-slim's orchestrator) were unreachable from the app. List every non-hidden primary/all agent, and default to the agent the server sorts first (its default_agent) instead of hard-coding build.
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.
Summary
The chat mode chip only offered
build/plan, so primary agents registered by OpenCode plugins(e.g. oh-my-opencode-slim's
orchestrator) were unreachable from the app even though the serverreported them and set them as
default_agent.OpenCodeAgentnow decodeshidden.selectablePrimaryAgents()(non-hiddenprimary/all/unreported-mode agents, server order kept)and
defaultAgentName()(first of those; OpenCode'sGET /agentsortsdefault_agentfirst, orbuildwhen unset).SettingsViewModel.agents,AppPreferencesRepository.reconcileandAssistantProfileResolveruse them instead of hard-codingbuild.Behavior note: a previously auto-saved
buildselection stays valid, so existing users keepbuilduntil they pick another agent in the chip; new installs or invalid selections follow the server's
default_agent.Testing
OpenCodeAgentSelectionTest; added adefault_agentcase toAssistantProfileTest.Pre-PR review
判定: APPROVE
ブロッカー
なし
提案(非ブロッキング)
data/settings/AppPreferencesRepository.kt:150-155: 既存ユーザーは旧reconcileが自動保存した"build"がagentIdに残っているため、サーバーdefault_agentがorchestratorでも更新後はbuildのまま。ユーザー選択と自動デフォルトを区別できない以上妥当な挙動だが、PR 説明に「新規/無効化時のみサーバーデフォルトに従う」と一言あると誤解が減る。feature/chat/ChatHomeScreen.kt:1886: チップはwidthIn(max = 92.dp)のためorchestrator等の長い名前は省略表示になる。TextOverflow.Ellipsis済みで破綻はしないが、実機で見切れ具合を確認推奨。data/settings/AppPreferencesRepository.kt:132のreconcile自体には単体テストがない。ロジックの中心はdefaultAgentName/selectablePrimaryAgents側にありOpenCodeAgentSelectionTestで網羅されているので必須ではない。feature/assistant/AssistantProfile.kt:28:AssistantProfileResolverは main 側に呼び出し元がない(テストのみ)。今回の変更とは無関係で既存の状態。チェック済み項目
core/api/OpenCodeApiModels.kt:163-184):hiddenはデフォルトfalse(省略 JSON でもデコード可、テスト 67-76 行で確認)。selectablePrimaryAgentsは mode null/primary/allかつ非 hidden のみ、サーバー順を保持。defaultAgentNameはfirstOrNull()?.nameのみで build フォールバック削除済み。defaultAgentName()→ null(OpenCodeAgentSelectionTest.kt:62-64)、stock サーバー(build, plan 順)→build(50-59 行)、プラグイン構成でorchestrator先頭・subagent/hidden(compaction/title/summary/councillor-gpt)除外を確認。AssistantProfileTestの 2 件(既存 build-only と新規 orchestrator 優先)も実装と整合。ChatHomeScreen.kt:1862-1928): 旧実装の build/plan 限定+ラベル固定"build"から、全 selectable primary の表示へ。ラベルは「有効な選択 →defaultAgentName()→"build"」で、最後の"build"はランタイム停止中の空リスト時のみ(旧挙動を維持)。コメント修正内容も実装と一致。AndCodeApp.kt:612,1061,1064はsettingsState.agents(SettingsViewModel.kt:208でフィルタ済み)を使用し、チップ・設定画面・selectConfiguration検証が同一集合で一貫。CatalogReconcileInitializer.kt:19→reconcileは生リストを渡すが内部でフィルタ。空リスト時のreconcileはselectAgent(null)となり旧挙動と同じ。CodexModels.kt:39)、Claude Code(ClaudeCodeTarget.kt:358)、Antigravity(AntigravityTarget.kt:158)はいずれもmode="primary"・hidden 未指定で選択可能。Claude/Antigravity は ModeChip ではなく PermissionModeChip 分岐(ChatHomeScreen.kt:1579-1597)。Codex は単一エージェントがそのまま表示され、旧ifEmpty { agents }経由と同結果。/workspace/and-code側の旧実装(AppPreferencesRepository.kt:147-151、AssistantProfile.kt:56、SettingsViewModel.kt:207、ChatHomeScreen.kt:1871-1875)と突き合わせ、意図しない後退がないことを確認。