Skip to content

Make workbench test state transitions explicit - #132

Merged
ruibaby merged 1 commit into
mainfrom
improvement/workbench-explicit-state-machine
Nov 12, 2026
Merged

ruibaby merged 1 commit into
mainfrom
improvement/workbench-explicit-state-machine

Conversation

@ruibaby

@ruibaby ruibaby commented Nov 12, 2026

Copy link
Copy Markdown
Member

Summary

The AI model test workbench tracked request ownership with a mix of module-level variables and per-message flags. This made several transitions implicit: approval continuations kept the previous request id, stale stream snapshots could overwrite newer state, RAG could flip a stopped message back to done, external tool submissions could be sent twice, and the selected test mode was lost on refresh.

This change introduces a small message state machine and an explicit active request id for the chat and RAG flows, while keeping the existing public composable contract additive.

Changes

  • Add model-test-workbench-message-state.ts with beginAssistantMessage, resumeAssistantMessage, and applyAssistantMessageEvent for the streaming -> done | stopped | error transitions.
  • Track an active requestId per chat/RAG request. Stream snapshots, terminal errors, and cleanup now ignore stale requests.
  • Write the new request id back to the message when an approval continuation starts, so streamed output and stop target the original message.
  • Persist the selected test mode in the mode query parameter. An explicit mode is authoritative; chat remains the default and clears the parameter.
  • Add an in-flight key for external tool result/error submissions and disable the corresponding controls while pending.
  • Mark RAG messages as stopped immediately and keep them stopped if the transport later resolves normally.

User-visible behavior

  • Refreshing or sharing a workbench URL preserves the selected test mode (?mode=rag, ?mode=embedding, etc.).
  • Stopping a chat or RAG response marks it as stopped immediately and it no longer changes to done afterward.
  • External tool result/error buttons are disabled while the continuation is being submitted, preventing duplicate submissions.
  • Approval continuations now stream into the approved message and can be stopped.

Reproduction

Before the fix:

  1. Open the model test workbench and enable a tool test with approval.
  2. Send a message and wait for the approval request.
  3. Approve the request.

The message remained in the done state, no continuation content appeared, and stopping had no effect.

After the fix, the approved message switches to streaming, receives the continuation, and can be stopped. The regression is covered by the approval continuation test in streaming-tests.test.ts.

Validation

  • pnpm test:unit: 68 files, 597 tests passed
  • pnpm exec vue-tsc --build: passed
  • pnpm lint: 0 warnings, 0 errors
  • pnpm build: passed
  • git diff --check: clean

No live Halo browser E2E was run; verification is source-level plus unit/integration tests and a production build.

Compatibility

The changes are limited to the Console workbench UI. Backend DTOs, persisted extension fields, generated API clients, and plugin SDK contracts are unchanged. Additions to the workbench composable return value are optional/additive.

@ruibaby
ruibaby merged commit 045204a into main Nov 12, 2026
1 check passed
@ruibaby
ruibaby deleted the improvement/workbench-explicit-state-machine branch November 12, 2026 08:14
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