Skip to content

settings shows true routing state: live refresh + Bun.TOML parse fallback - #25

Open
dallascrilley wants to merge 3 commits into
RubricLab:mainfrom
dallascrilley:live-routing-status
Open

settings shows true routing state: live refresh + Bun.TOML parse fallback#25
dallascrilley wants to merge 3 commits into
RubricLab:mainfrom
dallascrilley:live-routing-status

Conversation

@dallascrilley

@dallascrilley dallascrilley commented Sep 1, 2026

Copy link
Copy Markdown

Problem

Settings was showing codex routing off while ~/.codex/config.toml had an active model_provider = "tokenmaxx" and all codex traffic flowed through the proxy. Worse, pressing the routing toggle to turn it off computed enable from that wrong false and re-installed the managed block — turning routing off through the dashboard was impossible.

Two compounding causes, one commit each:

1. installStatus() reported codexRouted = false forever on real-world configs

Bun.TOML.parse rejects bare table keys that start with a digit — e.g. [mcp_servers.1password], which codex itself writes and accepts. Repro on bun 1.3.14:

Bun.TOML.parse('[mcp_servers.1password]\nenabled = false\n')    // throws
Bun.TOML.parse('[mcp_servers."1password"]\nenabled = false\n')  // ok

Any config containing such a table threw into installStatus()'s catch, which returned codexRouted = false regardless of what the file actually said. Fix: on parse failure, fall back to detecting our own active selection line, scanning only the top-level region (a model_provider under a table belongs to that table, so swallowed legacy blocks and [profiles.x] entries can't false-positive into healInstalledConfigs re-enabling routing). The semantic TOML check stays the primary path for configs that parse. Regression tests cover the parse failure both directions, the swallowed-legacy case, and the profile case.

2. The dashboard's routing display was a launch-time snapshot

runTuiDashboard received routing once from runCli and never re-read it, so any out-of-band change — tokenmaxx install / uninstall from another shell, first-login auto-enable in login(), the daemon's post-update heal — left Settings contradicting the files for the rest of the session. Fix: reload() re-reads installStatus() alongside the existing piStatus() call, so the 2s tick and manual r refresh converge the display to the files' truth, and the toggle flips from live state.

Testing

  • bun test — 89 pass, 0 fail (2 new regression tests for the parse-failure fallback)
  • bun run typecheck — clean
  • bun x biome check — clean

Not addressed here

While debugging we also found that Codex desktop (ChatGPT app 26.831.20005) attaches no agent tools to turns when model_provider is a custom provider — the model runs chat-only. The proxy forwards tool definitions correctly (verified with direct requests, and codex CLI 0.152.0 executes shell fine through tokenmaxx), so this looks like desktop-side capability negotiation for custom providers, not something tokenmaxx can fix. Flagging in case you want to document it as a known limitation of codex routing.

The dashboard received routing once at launch (options.routing) and never
re-read it, so Settings kept showing the launch-time snapshot for the whole
session. Routing actually lives in the harness config files and can change
while the dashboard is open — tokenmaxx install/uninstall from another
shell, first-login auto-enable, or the daemon's post-update heal — leaving
Settings contradicting the on-disk config (e.g. showing codex routing off
while model_provider still points at the proxy).

reload() now re-reads installStatus() alongside piStatus(), so the 2s tick
and manual refresh both bring the display back to the files' truth, and the
routing toggle flips from the live value instead of the stale snapshot.
Bun.TOML.parse rejects bare table keys that start with a digit — a real-world
example is [mcp_servers.1password], which codex itself writes and accepts.
On any config containing such a table, installStatus() threw into its catch
and reported codexRouted = false no matter what the file actually said.

The visible damage: the dashboard's Settings page showed codex routing off
while model_provider = "tokenmaxx" was actively sending traffic through the
proxy, and pressing the routing toggle computed enable from that wrong false
and re-installed the managed block instead of removing it — turning routing
off through the dashboard was impossible on such a config.

On parse failure, fall back to detecting our own active selection line
(commented-out lines never match). The semantic TOML check stays the primary
path for configs that parse.
@dallascrilley dallascrilley changed the title keep settings routing state live settings shows true routing state: live refresh + Bun.TOML parse fallback Sep 1, 2026
The parse-failure fallback matched our selection line anywhere in the file,
but a model_provider under a table belongs to that table: a legacy selection
swallowed into [notice], or a [profiles.x] naming our provider while another
is active, would read as routed — and healInstalledConfigs would re-enable
routing from that. Scan only the region before the first table header.
Also pin that the installed fixture genuinely breaks Bun.TOML, so the
regression test keeps exercising the fallback if bun's parser improves.
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