Choose which preset claude-mode <provider> picks
Omitting the preset used a fixed name per provider (default, zai, lmstudio). It can now be chosen: claude-mode preset default what each picks, and why claude-mode preset default openrouter cheap claude-mode preset default openrouter --clear The choice is stored in ~/.claude-mode/defaults.json and read first by default_preset_for, while its file still exists. A choice whose file is gone falls back to the built-in name, and if that is gone too, to the first preset by name, as before. Renaming a chosen preset moves the choice with it, and deleting it clears the choice. The terminal menu marks what resolve_preset would actually pick. health.json publishes defaultPresetFor (what each provider resolves to, in the CLI's order) and defaultPresetChosen (the explicit choices only). The panel sorts and tags from it, and the editor gains Make default / Clear default. preset new, rename and rm now refresh health.json, so the bar follows edits made in a terminal too. This changes existing CLI behaviour only once a default is chosen. The Windows build does not read defaults.json yet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -317,7 +317,27 @@ Panel {
|
||||
property string editTier: ""
|
||||
property string editModel: ""
|
||||
|
||||
// Which preset `claude-mode <provider>` picks when none is named. The CLI
|
||||
// publishes it now that it can be chosen; the built-in names in Modes.js
|
||||
// are only the fallback for a health.json written by an older CLI.
|
||||
readonly property var defaultPresets: {
|
||||
var out = {}
|
||||
var builtin = Modes.DEFAULT_PRESET
|
||||
for (var b in builtin) out[b] = builtin[b]
|
||||
var pub = health && health.defaultPresetFor ? health.defaultPresetFor : null
|
||||
if (pub) for (var p in pub) if (pub[p]) out[p] = pub[p]
|
||||
return out
|
||||
}
|
||||
readonly property var chosenDefaults: health && health.defaultPresetChosen ? health.defaultPresetChosen : ({})
|
||||
|
||||
readonly property var editEntry: root.editPreset !== "" ? root.presetEntry(root.editPreset) : null
|
||||
readonly property bool editIsDefault: root.editPreset !== "" && root.defaultPresets[root.editProvider] === root.editPreset
|
||||
readonly property bool editIsChosenDefault: root.editPreset !== "" && root.chosenDefaults[root.editProvider] === root.editPreset
|
||||
|
||||
function setDefault(on) {
|
||||
root.runOps("saving", [on ? ["preset", "default", root.editProvider, root.editPreset]
|
||||
: ["preset", "default", root.editProvider, "--clear"]], "preset")
|
||||
}
|
||||
readonly property string editProvider: editEntry ? String(editEntry.provider) : ""
|
||||
readonly property bool editIsActive: root.mode !== "anthropic" && root.editPreset !== "" && root.editPreset === root.preset
|
||||
|
||||
@@ -847,7 +867,7 @@ Panel {
|
||||
readonly property string thisMode: String(modelData)
|
||||
readonly property bool isCurrent: thisMode === root.mode
|
||||
readonly property bool isExpanded: root.expandedMode === thisMode
|
||||
readonly property var presetList: Modes.presetsFor(root.health, thisMode, Modes.DEFAULT_PRESET)
|
||||
readonly property var presetList: Modes.presetsFor(root.health, thisMode, root.defaultPresets)
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
@@ -968,10 +988,24 @@ Panel {
|
||||
font.bold: presetRow.isActive
|
||||
}
|
||||
|
||||
// Only worth saying when there is a choice to tell apart.
|
||||
Text {
|
||||
id: defaultTag
|
||||
visible: modeEntry.presetList.length > 1
|
||||
&& String(presetRow.modelData.name) === root.defaultPresets[modeEntry.thisMode]
|
||||
anchors.left: presetName.right
|
||||
anchors.leftMargin: Style.space(6)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: "default"
|
||||
color: Color.muted
|
||||
font.family: root.bar ? root.bar.fontFamily : Style.font.family
|
||||
font.pixelSize: Style.space(9)
|
||||
}
|
||||
|
||||
// The opus mapping is the one that tells you what you are
|
||||
// about to be talking to; the rest is in the tooltip.
|
||||
Text {
|
||||
anchors.left: presetName.right
|
||||
anchors.left: defaultTag.visible ? defaultTag.right : presetName.right
|
||||
anchors.leftMargin: Style.space(8)
|
||||
anchors.right: gearButton.visible ? gearButton.left : parent.right
|
||||
anchors.rightMargin: Style.space(4)
|
||||
@@ -1311,6 +1345,17 @@ Panel {
|
||||
font.pixelSize: Style.space(10)
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: root.editIsDefault
|
||||
text: "claude-mode " + root.editProvider + " picks this one when no preset is named"
|
||||
+ (root.editIsChosenDefault ? "." : " (the built-in choice).")
|
||||
color: Color.muted
|
||||
wrapMode: Text.WordWrap
|
||||
font.family: root.bar ? root.bar.fontFamily : Style.font.family
|
||||
font.pixelSize: Style.space(10)
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Style.space(1)
|
||||
@@ -1392,6 +1437,8 @@ Panel {
|
||||
visible: root.editProvider === "lmstudio"
|
||||
onTriggered: root.openServerSettings(root.editPreset, "preset")
|
||||
}
|
||||
PillButton { label: "Make default"; visible: !root.editIsDefault; onTriggered: root.setDefault(true) }
|
||||
PillButton { label: "Clear default"; visible: root.editIsChosenDefault; onTriggered: root.setDefault(false) }
|
||||
PillButton { label: "Duplicate…"; onTriggered: root.openNewPreset(root.editProvider, root.editPreset) }
|
||||
PillButton { label: "Rename…"; onTriggered: root.openRename() }
|
||||
// The CLI refuses to delete the preset in use. A button that always
|
||||
|
||||
Reference in New Issue
Block a user