Skip to content

fix(tui): dismiss stale forms after failed reply#36591

Draft
kitlangton wants to merge 1 commit into
v2from
stale-form-submit
Draft

fix(tui): dismiss stale forms after failed reply#36591
kitlangton wants to merge 1 commit into
v2from
stale-form-submit

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Dismiss a stale TUI form when submitting it returns FormNotFoundError.

Before this change, a form lost during a managed-service restart remained mounted and trapped the user outside the composer. After this change, the TUI refreshes the server's authoritative form list, removes the missing form, and restores the composer.

Fixes #36585.

How

  • packages/tui/src/routes/session/form.tsx handles the generated V2 FormNotFoundError for both immediate single-question replies and review-style form submissions.
  • Session and home form hosts request data.session.form.refresh(...), which uses the existing V2 /api/session/:sessionID/form or location-scoped form list endpoint and replaces local form state.
  • Other reply failures retain the existing inline error behavior.
  • packages/tui/test/cli/tui/form.test.tsx reproduces a stale form reply and verifies that the form is dismissed.

Scope

This does not make forms or suspended tool execution durable across server restarts. It only ensures that a user is not trapped by a form the replacement server no longer owns.

Testing

  • bun run test test/cli/tui/form.test.tsx (3 passed)
  • bun run test test/cli/tui/data.test.tsx (32 passed)
  • bun typecheck from packages/tui
  • Push hook: bun turbo typecheck --concurrency=3 (31 packages passed)
  • Prettier and git diff --check

Flow

sequenceDiagram
    participant User
    participant TUI
    participant Client as V2 client
    participant Server

    User->>TUI: Submit stale form
    TUI->>Client: form.reply(...)
    Client->>Server: POST form reply
    Server-->>Client: FormNotFoundError
    Client-->>TUI: Typed error
    TUI->>Client: form.list / form.request.list
    Client->>Server: Refresh authoritative forms
    Server-->>TUI: Empty form list
    TUI-->>User: Remove form and restore composer
Loading

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