Skip to content

fix(tui): recover from terminal forms - #44516

Merged
kitlangton merged 1 commit into
v2from
terminal-form-recovery
Aug 23, 2026
Merged

kitlangton merged 1 commit into
v2from
terminal-form-recovery

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Recover the normal TUI composer when a cached form has already disappeared or been settled elsewhere. Replying or cancelling a stale form now treats both FormNotFoundError and FormAlreadySettledError as terminal outcomes and removes the matching form from the local projection immediately.

This supersedes #44507 with the review findings addressed.

Before / After

Before: If the TUI missed a form settlement event, the stale prompt remained active. A reply or cancellation returned 404 or 409, displayed an error, and continued blocking the normal composer. The previous fix hid the component while waiting for a list refresh, which could leave a blank blocked footer when refresh failed.

After: Form settlement lives in the client data layer. Successful, missing, and already-settled outcomes remove the matching projected form synchronously, so the keyed form component unmounts and normal keymap/composer cleanup runs immediately. Revalidation is advisory; a failed refresh cannot re-block the composer.

How

  • packages/client/src/solid/data.ts adds projection-aware form reply and cancel operations, preserving global-form location headers and accepting 404/409 as terminal only when the error identifies the submitted form.
  • packages/tui/src/routes/session/form.tsx delegates settlement to the data layer instead of coordinating API errors and cache state itself.
  • packages/plugin/src/tui/context.ts exposes the domain-level form operations to TUI data consumers.
  • packages/tui/test/cli/tui/form.test.tsx covers reply and cancellation recovery for 404 and 409, plus failed background revalidation.

Scope

This does not change form protocol or server behavior. Duplicate in-flight form submissions remain outside this stale-projection recovery fix.

Testing

  • bun run test test/cli/tui/form.test.tsx from packages/tui (25 passed)
  • bun run test test/solid-data.test.ts from packages/client (3 passed)
  • bun typecheck from packages/tui, packages/client, and packages/plugin
  • Push hook: repository-wide Turbo typecheck (32 packages passed)
  • bun run lint (0 errors; pre-existing warnings remain)

Flow

sequenceDiagram
  participant TUI as FormPrompt
  participant Data as Client data
  participant API as Form API

  TUI->>Data: reply or cancel
  Data->>API: settle form
  API-->>Data: success, 404, or 409
  Data->>Data: remove matching projected form
  Data-->>TUI: terminal completion
  Note over TUI: Form unmounts; composer resumes
  Data->>API: revalidate forms in background
Loading

@kitlangton
kitlangton merged commit 2e67cee into v2 Aug 23, 2026
9 checks passed
@kitlangton
kitlangton deleted the terminal-form-recovery branch August 23, 2026 20:21
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant