Skip to content

fix(tui): persist provider/model changes during retry backoff #831

Closed

Description

@agenteinstinct1-max

TUI model selection is not persisted while session status is retry

Mechanism

At dev-vibecoded c54ff0e:

  1. packages/tui/src/context/local.tsx:439-456 updates the TUI's local model selection. The displayed choice can therefore change before the session row is updated.
  2. The effect at local.tsx:899-942 reads the session status but calls selectionUpdate with busy: state.status === "busy" at line 920. A session in retry is excluded.
  3. selectionUpdate at local.tsx:64 returns undefined when busy is false, so the effect does not call sdk.client.session.update. Model/provider switching during backoff can remain local-only.
  4. Backend retry invalidation already exists: processor.ts:873-885 compares the persisted session model with the original request's provider/model. retry.ts:278-298 checks invalidation after each 200 ms chunk, including the last chunk. When invalidated, the processor returns continue and the outer loop reads the latest persisted selection.
  5. Therefore, suppressing the TUI update in retry status prevents the backend from seeing the change it is designed to act on. This is distinct from an inability to interrupt an already persisted switch.

Existing issue and test coverage

Closed issue #66 describes backend stale-retry invalidation and its intended behavior. This follow-up covers the TUI propagation path rather than the backend invalidation already covered by #66.

packages/tui/test/context/local.test.ts covers busy=true updates, busy=false suppression, same-model idempotence and agent isolation. It does not exercise actual TUI status=retry selection propagation. Backend test/session/retry.test.ts covers invalidation before/during/after the delay, but those tests provide the invalidation signal directly and do not prove the TUI writes it.

Expected behavior and acceptance

  • Through the real TUI selection path, change provider/model while a session is in retry status and a long Retry-After wait is active.
  • Verify that the valid new selection is persisted for the correct session and agent, the old-provider pending backoff is invalidated, and the next turn uses the new provider/model. The old provider must receive no further retry after invalidation.
  • Do not merely clear the countdown text or cancel a valid in-flight request. Preserve turn-boundary semantics.
  • Preserve same-selection idempotence, idle-session behavior, agent/session isolation, rejected-write reporting and normal backoff when no selection changes.
  • Separately assert that status leaves the old retry state when the new request begins. If the new provider also rate-limits, show the new provider's actual error rather than treating every visible retry as stale.
  • Use a local fake-provider boundary and a bounded test, not a multi-hour wait, a paid model call, a timeout increase or relaxed assertions.

Limits of attribution

Source establishes the missing retry-status propagation path. A rendered choice plus countdown alone cannot establish whether an individual running process retained the old provider wait, displayed stale status after a successful invalidation, or received another rate limit from the new provider. Distinguish with persisted selection, retry invalidation/new-request events and status provenance.

Sources

#66
https://github.com/mdev34-lab/silvercode/blob/c54ff0ef5a1ba02f84bd96cd1e7c5454f4ef18ba/packages/tui/src/context/local.tsx
https://github.com/mdev34-lab/silvercode/blob/c54ff0ef5a1ba02f84bd96cd1e7c5454f4ef18ba/packages/opencode/src/session/retry.ts
https://github.com/mdev34-lab/silvercode/blob/c54ff0ef5a1ba02f84bd96cd1e7c5454f4ef18ba/packages/opencode/src/session/processor.ts

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