Skip to content

armgit / chops

Public Imported from GitHub
0

Your AI agent skills, finally organized. A macOS app to browse, edit, and manage skills across Claude Code, Cursor, Codex, Windsurf, and Amp.

fix: inject Opus model options into Claude ACP model picker (#89)

Josh Pigford475f071e61c3
diff --git a/Chops/Services/ACP/ACPClient.swift b/Chops/Services/ACP/ACPClient.swift
index 21fc1a9..f6eb858 100644
--- a/Chops/Services/ACP/ACPClient.swift
+++ b/Chops/Services/ACP/ACPClient.swift
@@ -131,7 +131,7 @@ open class BaseACPAgent: ClientDelegate {
let sessionResp = try await client.newSession(workingDirectory: cwd.path)
guard !Task.isCancelled else { await client.terminate(); return }
sessionId = sessionResp.sessionId
- sessionConfigOptions = sessionResp.configOptions ?? []
+ sessionConfigOptions = processConfigOptions(sessionResp.configOptions ?? [])
acpLog.debug("Session created: \(sessionResp.sessionId) (\(sessionConfigOptions.count) config options)")
acpClient = client
@@ -210,7 +210,7 @@ open class BaseACPAgent: ClientDelegate {
func setConfigOption(id: SessionConfigId, value: SessionConfigValueId) async throws {
guard let client = acpClient, let sid = sessionId else { return }
let resp = try await client.setConfigOption(sessionId: sid, configId: id, value: value)
- sessionConfigOptions = resp.configOptions
+ sessionConfigOptions = processConfigOptions(resp.configOptions)
}
// MARK: - Prompt
@@ -370,7 +370,7 @@ open class BaseACPAgent: ClientDelegate {
case .agentThoughtChunk(let c): onThoughtChunk(c)
case .toolCall(let t): onToolCall(t)
case .toolCallUpdate(let d): onToolCallUpdate(d)
- case .configOptionUpdate(let u): sessionConfigOptions = u
+ case .configOptionUpdate(let u): sessionConfigOptions = processConfigOptions(u)
case .sessionInfoUpdate(let i): if let t = i.title { acpLog.debug("Session: \(t)") }
default: break
}
@@ -400,6 +400,7 @@ open class BaseACPAgent: ClientDelegate {
func additionalFlags() -> [String] { [] }
func sessionCwd(for workingDirectory: URL) -> URL { workingDirectory }
+ func processConfigOptions(_ options: [SessionConfigOption]) -> [SessionConfigOption] { options }
func postProcess(_ text: String) -> String { text }
func conversationalText(from text: String) -> String { postProcess(text) }
diff --git a/Chops/Services/ACP/Agents/ClaudeACPAgent.swift b/Chops/Services/ACP/Agents/ClaudeACPAgent.swift
index f788881..3779b5d 100644
--- a/Chops/Services/ACP/Agents/ClaudeACPAgent.swift
+++ b/Chops/Services/ACP/Agents/ClaudeACPAgent.swift
@@ -126,6 +126,46 @@ final class ClaudeACPAgent: BaseACPAgent {
}
}
+ // MARK: - Config Option Enrichment
+
+ /// Claude Code's ACP adapter omits Opus from the model picker due to an upstream SDK bug
+ /// (anthropics/claude-agent-sdk-typescript#117). Inject it client-side so users can select it.
+ /// Self-healing: if the upstream fix ships, hasOpus detects it and skips injection.
+ override func processConfigOptions(_ options: [SessionConfigOption]) -> [SessionConfigOption] {
+ options.map { option in
+ guard option.name == "Model", case .select(let select) = option.kind else { return option }
+
+ let existingOptions: [SessionConfigSelectOption]
+ switch select.options {
+ case .ungrouped(let opts): existingOptions = opts
+ case .grouped(let groups): existingOptions = groups.flatMap(\.options)
+ }
+
+ let hasOpus = existingOptions.contains { $0.value.value == "opus" }
+ guard !hasOpus else { return option }
+
+ var newOptions = existingOptions
+ let insertIndex = newOptions.lastIndex(where: { $0.value.value.contains("sonnet") })
+ .map { newOptions.index(after: $0) } ?? newOptions.endIndex
+
+ newOptions.insert(contentsOf: [
+ SessionConfigSelectOption(value: SessionConfigValueId("opus"), name: "Opus"),
+ SessionConfigSelectOption(value: SessionConfigValueId("opus[1m]"), name: "Opus (1M context)"),
+ ], at: insertIndex)
+
+ return SessionConfigOption(
+ id: option.id,
+ name: option.name,
+ description: option.description,
+ category: option.category,
+ kind: .select(SessionConfigSelect(
+ currentValue: select.currentValue,
+ options: .ungrouped(newOptions)
+ ))
+ )
+ }
+ }
+
// MARK: - Response Post-Processing
override func postProcess(_ text: String) -> String {