Skip to content

Review pass over the Sep 8 and 9 commits: plan-limit gauge, codex resume fallback, engine resolver #226

Open

Description

@RemilioNubilio

A review pass over main from f7b34ab (engine banner) to e437cbf (usage gauge as the primary chip), plus 8f1e43e (engine resolver) since it had not been looked at yet. Every claim was verified against origin/main with file:line and had to survive a second pass that tried to refute it. Grouped by who owns the fix.

Core: the rate-limit contract (one fix closes items 1 to 4)

  1. The contract lies about units. runtime/contract.ts:128 declares utilization as 0-100 and :130 resetsAt as epoch ms, but convert/claude.ts:159-164 copies the SDK fields verbatim, and the engine we spawn (claude 2.1.265 via spawn.ts:406) sends rate_limit_event.utilization as a 0-1 fraction (its own doc string: "usually 0-1 ... values above 1 occur when usage legitimately runs past a window's cap") and resetsAt as epoch seconds. Each consumer patches around it privately: shell.ts:131 guesses the scale from magnitude, shell.ts:137 and Composer.tsx:114 guess seconds vs ms with < 1e12. The two-scale confusion comes from the SDK itself (its /usage response is 0-100 while rate_limit_event is a fraction), so it wants one conversion in core, not one per surface. Fix: in convert/claude.ts multiply utilization by 100 and clamp to 100, multiply resetsAt by 1000, keep contract.ts:128-130 at 0-100 / ms, delete both surface heuristics, add a converter test with a 0.73 frame.

  2. The mobile gauge from dcbd682 never renders. state/store.tsx:397 stores the fraction raw and Composer.tsx:569 gates on limitPct >= 50, so a real 0.73 (or 1.0, or an over-cap 1.2) never passes; the gate can only pass at 5000% of plan. If it did mount, LimitDot would round it to "1%" (Composer.tsx:107). Same session, same engine: the VS Code panel shows 73%, the phone shows nothing. Closed by 1; add a reducer test for a 0.73 frame.

  3. The panel misreads over-cap values. shell.ts:131 raw <= 1 ? raw * 100 : raw treats 1.15 as an already-percent value, so a user past the 5-hour cap sees "1%" with a 1% fill bar; 1.0 happens to render as 100%, so only the past-cap case is wrong. The chip tints amber via :132 only when the engine status says so; the text and fill are wrong either way. Closed by 1 (clamp at the source).

  4. A rejection without a utilization number is dropped, so neither gauge ever shows the blocked state. SDKRateLimitInfo has status required and utilization optional, and in the spawned CLI the rejected state object never carries a top-level utilization, so convert/claude.ts:158 typeof rl.utilization === "number" discards every rejection. Both surfaces special-case status === 'rejected' (shell.ts:132, Composer.tsx:108) but can never receive it. What the user sees: the gauge freezes at the last allowed reading, for example a green 72% (reproduced), at the moment the plan blocks the turn; on mobile it never turns red. A converter-only fix makes it worse: forwarding a status-only frame today makes shell.ts:130 set usage = null and store.tsx:397 set limitPct undefined, so the gauge vanishes at the moment of rejection (reproduced in jsdom, display none). Fix: make utilization optional in contract.ts:128 and surfaces/webview/src/transport/protocol.ts:196, forward status-only events from convert/claude.ts, and have renderLimitMeter and the store keep the previous pct while painting warn/danger from status.

Core: the codex resume fallback (94db8fd)

  1. The recovery notice goes through the error channel, which the runtime treats as a turn end. spawn.ts:989 emits "[codex] previous thread unavailable" via cb.emitErr, then awaits startThread (:990) before the turn is sent (:1096 -> :1011). runtime/index.ts:277-282 turns every onError into a tool message plus the turn callbacks, so chat/session.ts:331 does busy.delete(h) and sends turnEnd: the panel flips Stop back to Send (main.ts:59, composer.ts:34-43) and Esc stops interrupting (composer.ts:321, 324); mobile sets typing false (store.tsx:417). The real turn then runs against an unlocked UI. Verified with a runtime-level repro on origin/main: turnEnd fires with zero turn/start requests written; a second send during the turn is painted and persisted but dropped by spawn.ts:1002 if (running) return with no error and no turnEnd; Stop and Esc cannot interrupt. From the same premature busy.delete: switching sessions in that window hits session.ts:417-428 "idle -> stopHandle" and SIGTERMs codex mid-turn; if the user had already switched away, session.ts:345 retires and kills it at the spurious turnEnd; the cross-device RUNNING marker is closed early (:337). The notice is also persisted into the canonical log as a tool message on every reopen (runtime/index.ts:229). Fix: do not route the notice through emitErr. cb.emitMsg({ role: 'tool', text, ts: Date.now() }) or a dedicated notice hook, so no turnEnd is synthesized while the turn is pending; and log the caught error, since catch { at :988 throws away the app-server's reason. The repro spec's first test (no onTurnEnd before turn/start is written) can go in as the gate.

  2. The fallback thread is empty, nothing records its id, and approvals from it carry an id no surface knows. thread/start at spawn.ts:947-954 sends no input, so the model has none of the conversation the user can still see, even though prepareResume already computed the replayable history (runtime/inject/index.ts:70-71) and injected it for the old id (:86-87, inject/codex.ts:66-68). The new id is emitted (spawn.ts:957-958) but discarded by runtime/index.ts:240-241, and for a codex-born session inject/index.ts:75-77 always re-derives nativeId = canonicalId (the idmap is never consulted), so every respawn (model/mode/effort restage at session.ts:448-453, switch away and back, reload) re-resumes the dead thread; a deterministic rejection repeats the notice plus another amnesic thread each time. Approvals raised inside the new thread carry the new id (spawn.ts:636/957 -> :842/868/878/891/918): the VS Code popup loses its session title (extension.ts:581-586, 616) and the mobile app treats it as another session's approval (App.tsx:67-68 force-notifies, :74-75 never clears, :82-85 tap opens an unknown id). Engine-level repro: requests [initialize, thread/resume, thread/start], thread/start without input, turn/start and the approval both under the new id. Fix: in the fallback mint a fresh uuid, write the replayable history for it (injectCodex accepts any uuid; thread/inject_items on the new thread also works), resume that, record it with setNativeId, and make prepareResume prefer an idmap entry before the birthCli shortcut. At minimum seed the first turn with the history so the model is not amnesic.

Core: the engine resolver (8f1e43e, 6344792)

  1. detectCli reports an engine that cannot start as "no-login". detect.ts:19 resolves true on any exit event, so a --version that dies with 127 still counts as installed. putOnPath (engineBin.ts:114-118) only prepends dirname(bin), assuming node sits beside the shim; that is false for ~/.bun/bin (:95), standalone pnpm (:97) and the legacy ~/.claude/local launcher (:84), which hold a #!/usr/bin/env node shim and no node. In a GUI-launched host with the bare launchd PATH the shim exits 127, isInstalled says yes, the auth status parsers read the 127 output as logged out, and the panel pushes the user to sign in; startClaudeLogin then fails with "claude auth login exited before emitting a URL" (account/claudeAuth.ts:74-77) and getEngineVersions reports installed null. Reproduced with tsx on origin/main: HOME with ~/.bun/bin/{claude,codex} as node shims and PATH=/usr/bin:/bin:/usr/sbin:/sbin gives { codex: 'no-login', claude: 'no-login' }. Fix: p.on("exit", (code) => resolve(code === 0)); in engineBin treat a node shim as usable only when a node is reachable (existsSync(join(dir, "node")), or also prepend the newest version-manager bin dir from the same candidate roots), and surface a distinct "node missing" status instead of "no-login".

  2. ~/.claude/local/claude outranks the native install and is mislabeled. candidates() checks it first under the comment "the official native installer" (engineBin.ts:83-84); that path is the old claude migrate-installer layout (a node shim into ~/.claude/local/node_modules), and the native installer's binary is ~/.local/bin/claude (:85). Users who moved to the native install keep the stale dir, so the resolver pins the old npm claude over the current one, and in a GUI-launched host that launcher cannot start because there is no node beside it. Reproduced: HOME with both, bare PATH, resolveEngineBin('claude') returns the ~/.claude/local path, detectCli says no-login, installed is null, while which claude in the user's terminal points at the working binary. Fix: move it after ~/.local/bin or drop it, correct the comment, and pair with the node-reachability check from 7.

  3. Windows: the .cmd candidates are dead on arrival. engineBin.ts:81 builds <name>.cmd and :100 adds %APPDATA%\npm<name>.cmd, which is where npm -g puts both engines. Every spawn site passes the resolved path to spawn() without shell: detect.ts:17, engineVersions.ts:35, spawn.ts:574 (codex) and :441 (the Agent SDK spawns claude.cmd the same way), codexModels.ts:40, account/claudeAuth.ts:38/87/121, account/codexAuth.ts:39/108/137. Since Node 18.20.2 / 20.12.2 (CVE-2024-27980) a .cmd spawned without shell is refused with a synchronous EINVAL, which is not in the async-emit list, so it throws: detectCli rejects instead of returning "missing" (pushCliStatus at extension.ts:206-208 never sends cliStatus, watchEngineInstall's catch at :232-234 swallows it) and spawnCli throws inside startSession (runtime/index.ts:199), so every send shows "send failed: spawn ...\codex.cmd EINVAL" (session.ts:536-538). To be exact about the blame: npm installs on Windows did not work before this commit either (bare name, ENOENT, a graceful "missing"); the new candidates turn that into a thrown error, and the where branch (:39-52, first line) cannot serve an npm install regardless of line order, because the extensionless shim gets ENOENT and the .cmd gets EINVAL. Reproduced in Node internals, not on a Windows host. Fix: one win32-aware launch helper for every spawn site (shell:true with a quoted path, or resolve past the shim to node <prefix>\node_modules\<pkg>\bin\<entry>.js / the .exe), prefer the .cmd/.exe line from where, and a win32 unit test for candidates() plus spawn.

  4. The Update button cannot see its own result. After the mobile/localhost Update runs npm install -g <engine>@latest (engineInstall.ts:16-17, engineVersions.ts:74-86), the follow-up getEngineVersions (localhost index.ts:642 -> engineVersions.ts:32) reports the pre-update binary whenever the engine was resolved from a non-npm location, which is the case for the native/standalone installers (~/.local/bin, both engines on this machine) and brew: candidates() puts ~/.claude/local and ~/.local/bin (engineBin.ts:84-85) ahead of every npm dir (:87-99), putOnPath (:114-118, :149) has already prepended the old bin dir to PATH so which re-picks it, and the cache (:130-132) only drops a path whose file is gone. So the toast says updated, the versions row stays outdated, and the Update button stays lit. Reproduced; a cache drop alone fixes only the nvm-first layout. Fix: before offering the npm update, check that the resolved binary's realpath is under node_modules and otherwise point at the engine's own updater; after a successful npm update prefer the dir npm wrote (npm prefix -g) or strip the old dir from PATH before re-resolving. In VS Code the banner is sent once per open (extension.ts:648-649) and asks for a reload (panel/main.ts:349), so there it comes back after the reload in the standalone case.

VS Code panel

  1. The Claude plan gauge stays on the codex tab and hides codex's ctx chip. Only claudeEngine emits rateLimit (spawn.ts:493; codexEngine registers onRateLimit at :1093 and never emits). usage (shell.ts:122) is module-level and never reset: clearCtx (:152) resets only ctxLabel and usageExpanded, setTab (engine.ts:180-189) does not touch it, and the platform switch only repaints (session.ts:580-595, which posts clear). Steps: chat on Claude until a rateLimit frame lands (60%), click the codex tab. paintMeters keeps #limitMeter visible with Claude's 60% and, because usage is set and usageExpanded was just reset, hides #ctxMeter (:169-173); every codex usage frame lands in ctxLabel but stays hidden unless the user knows to click the gauge. The comment at :167-168 ("codex ... the slot still shows ctx") is false after any Claude rateLimit in the panel's lifetime, which retainContextWhenHidden makes long (extension.ts:561). Fix: key the gauge by engine (usageByCli[S.cli]) or null it in setTab / on platform; jsdom case: rateLimit, then platform/clear, then usage on codex must show ctx and hide the gauge.

  2. dismissEngineUpdate is unguarded and its handler is on the wrong panel. The banner's close posts { type: 'dismissEngineUpdate', cli } (shell.ts:72) but PANEL_OUTBOUND_TYPES (test/fixtures/panel/contract.ts:5-58) does not list it, and panel.generated.spec.ts:69-72 only checks listed types, so it can be renamed or dropped with every gate green; every other post site is in the fixture. Separately, the only handler (extension.ts:396-399) sits inside openOnboarding's onDidReceiveMessage, whose HTML (onboarding.ts:18) has no #engineBanner; the banner lives in chatHtml (webview.ts:1932) and engineUpdate is only sent to the chat transport (:649). The chat panel's inbound paths (session.ts handle() from :547, attachAuthHandlers :238-244, the newTab listener :782-784) have no case, so the close-button post is silently dropped, engineUpdateDismissed is never populated, and the banner is back on the next chat panel. Fix: add "dismissEngineUpdate" to the fixture (optionally have the spec scan the bundle for unlisted type: literals) and move the case into a chat-panel handler such as attachAuthHandlers or the newTab listener.

Mobile composer (dcbd682)

  1. limitPct survives an engine switch. case "platform" (state/store.tsx:485-486) and case "clear" (:406-414) leave limitPct/limitWindow/limitResetsAt/limitStatus untouched and nothing else clears them. Once the gate in 2 is fixed: the gauge reaches threshold on Claude, the user taps the codex segment, codex never emits rateLimit, so the Claude 5-hour gauge stays in the codex composer with a tooltip claiming "Used N% of your 5-hour limit" for an engine that has no such limit. Fix: reset the limit fields in the platform case, or store them per cli and read state.limit[state.cli].

  2. The gauge floats mid-row (duplicate ml-auto). The wrapper at Composer.tsx:570 is ml-auto mr-2 and CtxDot's root (:39) is also ml-auto in the non-wrapping row at :541; flexbox splits the free space equally between the two auto margins. Rendered the real Composer through the real store in headless Chrome: at a 480px row both margins are 59.75px (gauge 66px right of the chip, 74px left of the dot); 15-24px per side on 412-430px phones; about 39px per side under the tablet cap (index.css:175-179). At 360px there is no free space and the row overflows by about 23px instead. Only observable once 2 is fixed. Fix: a single auto margin, for example wrap LimitDot and CtxDot in one ml-auto flex items-center gap-2 group.

Release

  1. The published vscode 0.1.13 ships the pre-fix gauge. The marketplace VSIX for 0.1.13 contains afde6c2's gauge (the u < 50 gate, none of e437cbf's markers) and was uploaded 2026-09-08T11:05:45Z, about 21 hours before b05565a and e437cbf reached main; the bump was committed retroactively alongside the fix, so main's 0.1.13 does not match the published 0.1.13. Since the engine always sends a fraction, 0.1.13 users on Claude never see the gauge at all. Fix: bump surfaces/vscode/package.json:5 to 0.1.14 and republish once 1 lands; commit the bump after the last user-facing change, not before it.

Happy to take any of these: 7, 8 and 13 are a few lines each, 12 is one fixture line plus moving one case, 1 through 4 are a single core change with the two heuristics deleted and the jsdom and reducer cases are already written, 5 and 6 come with runtime-level repro specs that can land as gates, and 9 wants a Windows host to confirm, which I do not have.

Activity

  1. RemilioNubilio commented on Sep 12, 2026

    @RemilioNubilio
    ContributorAuthor

    Items 1 to 4 are up as #229: the converter scales and clamps once, reports a rejection as a full window, and both surfaces drop their unit guesses. One deliberate change from the wording above: a rejection paints 100 rather than keeping the previous percentage, because the engine names the exhausted window and that can differ from the window of the last reading. Items 11 and 13 are not in it.

  2. RemilioNubilio commented on Sep 13, 2026

    @RemilioNubilio
    ContributorAuthor

    Items 5 and 6 are up as #230: the recovery notice leaves the error channel, a rejected resume recovers under a fresh thread that carries the replayable history and is recorded in the cli map, and approvals carry the canonical session id.

  3. NubsCarson commented on Sep 13, 2026

    @NubsCarson
    Contributor

    Items 7 and 8 are up as #231: detectCli trusts the exit code, the resolver puts a reachable node on PATH and ranks the native install over the legacy launcher. The distinct node-missing status from item 7 is left for a cross-surface PR.

  4. NubsCarson commented on Sep 14, 2026

    @NubsCarson
    Contributor

    Items 10, 11, and 12 are up separately:

    • core: make the Update flow see its own result (#226 item 10) #232: localhost/mobile Update uses the installed engine's updater and verifies the resulting version. A real UI click upgraded standalone Codex 0.153.3 to 0.154.0; the row refreshed and the Update button disappeared.
    • vscode panel: keep the plan gauge per engine (#226 item 11) #234: the VS Code plan gauge stays with its reporting engine. Real Claude and Codex turns verified the 91% Claude gauge, Codex ctx: 24k, and the tab round trip. A switch during a running Claude turn did not put its gauge on Codex; the exact frame-arrival race was not deterministically observed.
    • vscode: persist banner dismissal across chat panels (#226 item 12) #233: banner dismissal is handled by the chat panel and persists across new chat panels in that window. The installed CLI did not naturally emit the stale-cache warning, so the live UI check used an isolated warning fixture delegating to real Codex. Dismissal persisted into a new chat and reset after window reload.

    All three macOS core suites, typechecks, and webview builds passed. Each PR states its remaining limits. These were agent-operated UI checks, not hand-tests performed by nubs. Existing #227, #230, and #231 were not changed.

  5. NubsCarson commented on Sep 14, 2026

    @NubsCarson
    Contributor

    The remaining fixes are up separately:

    Item 15 is also covered by the published Marketplace 0.1.15 artifact: I downloaded the VSIX and verified its version and bundled gauge, dismissal and updater markers. No extra release bump was added.

    The screenshots are assistant-operated QA, with fixtures and unverified surfaces disclosed in each PR. #241 overlaps #238 in the composer/store, so the later merge will need an integration update preserving both changes. Leaving this issue open until the remaining PRs land.

  6. NubsCarson commented on Sep 14, 2026

    @NubsCarson
    Contributor

    The integration follow-ups are now included in #238 and #241. Custom preserves missing-runtime status without requiring Codex sign-in, and the gauge tests cover late Claude quota while Custom is selected. Local checks pass 506 tests for #238 and 479 for #241. The combined runtime/UI code matches the version shown in the saved integration screenshots; only test placement changed. The five PRs remain separate for review, with merge resolutions available on NubsCarson/AgentNet’s codex/pending-pr-integration-20260914 branch. Nothing is deployed.

  7. NubsCarson commented on Sep 19, 2026

    @NubsCarson
    Contributor

    Final tracking update: the remaining PRs have merged, so the earlier pending/integration status is out of date. Item mapping:

    All linked code PRs are merged, including the overlapping Custom work in #238. This accounts for the original checklist; the individual PRs retain their test evidence and limitations. This is a merge/status audit, not a fresh production or all-device certification. Thanks for getting these landed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions