Skip to content

feat(profile): carry Claude Code's modelPicker per account - #185

Merged
uwuclxdy merged 4 commits into
uwuclxdy:mommyfrom
siddicky:feat/model-picker
Nov 27, 2026
Merged

uwuclxdy merged 4 commits into
uwuclxdy:mommyfrom
siddicky:feat/model-picker

Conversation

@siddicky

@siddicky siddicky commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds a per-account [model_picker] table that clauth writes as Claude Code's modelPicker setting, so an API-key account like silk has its own /model list. Closes #184.

It has three commits, plus a merge of mommy that Testing describes:

  1. feat(profile) carries the picker into settings.json. config.toml gains [model_picker] with replace_built_in and [[model_picker.options]] rows (model, label, description, behaves_as). replaceBuiltInOptions and behavesAs load as aliases. clauth drops rows with a blank model, and a table with no live row counts as unset. clauth reads the table and never edits it. The table has no key_shape arm, so a save of any other key leaves the block byte for byte as written. A switch and every clauth start copy write the live rows as top-level modelPicker and remove the key for an account without a picker, the same set-or-remove rule model follows. modelPicker joins PER_PROFILE_TOP_FIELDS in settings_sync, next to model and advisorModel, so one account's list never reaches a sibling's runtime copy or the base. duplicate_profile copies the picker. The profile, writer and sync changes share one commit because ModelPicker::live_options has no caller without the writer and clippy fails the split.
  2. feat(tui) shows the picker on the Setup tab. The account header gets a read-only picker line that reads none, 1 option or N options, with (replaces built-in) after it when replace_built_in is true. It takes no focus stop and opens no editor, and the new-account form doesn't show it.
  3. docs(wiki) adds a Model picker subsection under Model routing with the silk example, the field mapping, and the config.toml key-table row, plus a test that parses the example and checks the exact wording.

User-visible changes

  • New [model_picker] table in config.toml. A freshly created config.toml ends with a short doc block and a commented example. Existing files gain nothing.
  • A switch or clauth start removes an existing modelPicker for an account with no picker, including one set by hand in ~/.claude/settings.json. Anyone who keeps a picker there today needs to move it into the account's [model_picker]. The wiki says so.
  • New picker line in the Setup tab's account header.

Not in this PR

  • Auto-switch mid-session. A clauth start session moved to another account keeps the picker its runtime copy started with, because the swap executor hands over only the effort settings (CLAUDE_CODE_EFFORT_LEVEL and the modelSettings levels). Handing modelPicker over next to them could be a follow-up.
  • Switch-off leaves the last account's modelPicker in ~/.claude/settings.json, as it already does model and advisorModel.
  • Hand edits apply on the next switch. Editing the active account's table updates the Setup line right away, but settings.json only changes when you switch onto the account again. Every hand-edited config.toml field behaves this way today.
  • A malformed table (a wrong type, or one field in both spellings) stops that account's config.toml from loading, as any broken key does. Parsing it leniently could be a follow-up.
  • replace_built_in = true with no live rows writes no modelPicker, so the built-ins stay. The config.toml doc block doesn't say that a row is needed.
  • Managed settings that define modelPicker win over the profile's, by Claude Code's design.

Testing

I merged mommy at 2e5cbbf into the branch (bcebd92), which brings in #173. Four files conflicted: src/claude.rs, src/profile.rs, src/settings_sync.rs and tests/inline/profile.rs. Each resolution keeps both features. The settings writer sets modelPicker and the per-model modelSettings effort levels side by side, a fresh config.toml gets both the [model_picker] and [model_effort] doc blocks, and the doc-digest and table-set tests list both tables. One picker test in tests/inline/settings_sync.rs now passes PerProfileKeys::default() to key_role, whose argument type #173 changed.

  • cargo fmt --all -- --check passes.

  • cargo clippy --locked --all-targets --all-features -- -D warnings passes on the merge.

  • I ran the full suite with cargo nextest run --no-fail-fast on the merge and on mommy at 2e5cbbf, side by side on the same machine. On the merge, 13280 tests ran: 13225 passed, 55 failed and 16 were skipped. On mommy, 13255 ran: 13198 passed, 57 failed and 16 were skipped. Every test that fails on the merge also fails on mommy. The 55 are:

    • 54 usage::scheduler::tests, each panicking with child <pid> never finished its exec (tests/inline/scheduler.rs:10109), the same failures this PR showed before the merge.
    • daemon::gateway::tests::every_restart_only_setting_restarts_once_when_it_changes, which gives up after 10s waiting for the slot to read Starting.

    The two extra failures on mommy are mcp::tests tests that pass on the merge.

  • Every integration test binary passes.

  • The new tests cover a config table that loads with its aliases and blank rows, a save that leaves a hand-written block byte-identical, the set-or-remove write on switch and in a clauth start copy, a picker-only profile creating settings.json, sync keeping each member's picker, the duplicate copy, the Setup line for 0, 1, 2 and 5 rows, and the wiki example.

  • The manual checks and screenshots below ran on the branch before the merge (3474f10).

  • Manual check in a throwaway HOME with three API-key accounts. The Setup tab shows 5 options (replaces built-in) for one holding the silk example, 1 option for a one-row picker and none for an account without one. Moving through the account's rows never stops on the picker line, the new-account form has no picker line, and browsing leaves the silk account's config.toml byte-identical.

    Screenshots

    silk example, 5 options
    one row, 1 option
    no picker, none
    new-account form, no picker line
    Claude Code /model with the silk picker

  • I wrote the settings.json that clauth builds for the silk example into a throwaway Claude Code 2.1.323 config dir, with a dummy key and a base URL that goes nowhere. /model then lists Kimi K3.1 Pro, DeepSeek V4.1 Flash 1017, GLM-5.3, GLM-5.3 Flash and Hy4 in place of the built-in models (last screenshot).

  • Only unit tests cover the removal side of that path. A real switch would touch the keychain, so I didn't run one.

Checklist

  • Secrets redacted from any pasted output (no sk-ant-*, no ~/.claude/~/.clauth contents)
  • cargo fmt --all -- --check, cargo clippy --locked --all-targets --all-features -- -D warnings and cargo test --locked --all-features pass locally (fmt and clippy pass; 55 tests fail the same way on mommy at 2e5cbbf, see Testing)

AI

  • no AI
  • AI-assisted, I reviewed everything
  • AI did most of it under my direction

Abdullah Siddique added 3 commits November 15, 2026 00:59
Claude Code's `modelPicker` setting lists the models `/model` offers. An
API-key account on a third-party endpoint (silk, for one) needs its own
list, and today the only place to put it is the shared
`~/.claude/settings.json`, where every account sees it.

Add a `[model_picker]` table to the profile's `config.toml`:
`replace_built_in` and `[[model_picker.options]]` rows with `model`,
`label`, `description` and `behaves_as`. The camelCase spellings Claude
Code uses (`replaceBuiltInOptions`, `behavesAs`) load as aliases. A row
with a blank `model` is dropped, and a table with no live row counts as
unset.

clauth reads the table and never edits it, so a save of any other key
leaves the hand-written block byte for byte as it was. A freshly
rendered `config.toml` ends with a short doc block and a commented
example, and an existing file gains neither. `duplicate_profile` copies
the picker to the new account.

On a switch and on every `clauth start` copy, `build_settings` writes the
live rows as top-level `modelPicker`, replacing what the base held, and
removes the key for an account with no picker, the same set-or-remove
rule `model` follows. A profile whose only setting is a picker still
creates a missing `settings.json`.

`modelPicker` joins the per-profile top-level keys of the cross-profile
settings sync, next to `model` and `advisorModel`, so one account's list
is never copied into a sibling's runtime copy or into the base.
The picker is hand-edited in `config.toml`, so the Setup tab had no way
to show whether an account has one. Add a read-only `picker` line to the
account header, after the session-token lines: `none`, `1 option` or
`N options`, followed by `(replaces built-in)` when `replace_built_in` is
true. It counts live rows only, the same rule the settings.json writer
uses.

The line is not a config row, takes no focus stop and opens no editor,
and the new-account form does not show it.
Add a `Model picker` subsection under `Model routing`: the
`[model_picker]` table and its fields, how each maps onto Claude Code's
`modelPicker`, the camelCase aliases, and that blank rows are dropped.

Say that an account with no picker strips `modelPicker` on a switch or
start, including one set by hand, that Claude Code takes the setting only
from managed settings, `--settings` or the SDK, and user settings, with
the highest source winning outright, and that a table spelling one field
both ways does not load. Note the cases a picker does not follow yet: a
session moved by auto-switch keeps the picker it started with, and a
switch-off leaves the last account's picker in place.

Include the silk example as a `toml` block, add the table to the
`config.toml` key table, and add a test that parses the example and pins
the wording above so the page cannot drift from the code.
siddicky pushed a commit to siddicky/clauth that referenced this pull request Nov 16, 2026
Brings in the per-model effort work from uwuclxdy#173. The four conflicts keep
both features: modelPicker and modelSettings effort levels are written
side by side, the [model_picker] and [model_effort] doc blocks both
render, and the doc-digest and table-set tests list both tables.
uwuclxdy added a commit that referenced this pull request Nov 27, 2026
A switch removes only the modelPicker clauth recorded writing.
refs #185
uwuclxdy added a commit that referenced this pull request Nov 27, 2026
@uwuclxdy
uwuclxdy merged commit c1d1220 into uwuclxdy:mommy Nov 27, 2026
6 checks passed
@uwuclxdy

Copy link
Copy Markdown
Owner

Thanks for the picker and for testing it against a real /model menu!

Merged with a design change on top: a switch removes modelPicker only while settings.json still holds the one clauth wrote, so a hand-set picker survives a switch to an account without one. When an account's picker replaces a hand-set one, clauth saves it and puts it back on the next switch to an account without a picker, or on a switch-off. Deleting the active account and editing it follow the same rule. It rides the record clauth already keeps for [env] values in ~/.clauth/base-env.json. Your three commits stayed as they were.

Also on top:

  • [model_picker] holding both spellings of a field gets its own error naming the field
  • Setup picker value ends in … on a narrow pane instead of cutting mid-word
  • picker row in the Setup table of wiki/Interface-And-Keys.md
  • fresh config.toml example uses a placeholder model instead of a silk id; its doc block says what Claude Code's schema says about replace_built_in
  • wiki's silk example gets the sixth row their page lists now (deepseek-v4.1-flash-1017-fast-uncensored)
  • unreadable base-env.json refuses a switch that would write the picker, naming the file

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.

Feature: per-account /model picker (Claude Code's modelPicker)

2 participants