Skip to content

πŸ› Bugfix: Unlock NL2Agent form after prompt updates and stops - #3788

Merged
WMC001 merged 1 commit into
developfrom
dyx/nl2a-unlock
Aug 27, 2026
Merged

πŸ› Bugfix: Unlock NL2Agent form after prompt updates and stops#3788
WMC001 merged 1 commit into
developfrom
dyx/nl2a-unlock

Conversation

@RedShakespeare

@RedShakespeare RedShakespeare commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix two cases where the right-side Agent configuration form could remain locked during the NL2Agent workflow:

  1. NL2Agent completes a single-field Prompt optimization without emitting the generation-completed state.
  2. The user manually stops model generation before the workflow finishes.

The form and Composer now unlock after either a database-verified Prompt update completion or an explicit user cancellation.

What changed

Unlock after single-field Prompt updates

  • Trigger persisted completion validation after any NL2Agent Prompt field is saved.
  • Support completion detection for individual duty_prompt, constraint_prompt, few_shots_prompt, greeting_message, and example_questions updates.
  • Emit agent_generation_completed only when the authoritative persisted Agent state is complete.
  • Preserve agent_draft_fields_saved for partial Prompt updates when the database state is still incomplete.
  • Keep completion validation tenant-scoped and user-scoped through the existing trusted MCP execution path.

Unlock after user cancellation

  • Propagate explicit NL2Agent stream cancellation from the chat adapter to the Agent configuration flow.
  • Add a dedicated generation_stopped flow action.
  • Reset the flow to idle and clear active cards, failed Prompt fields, pending configuration focus, and completion synchronization errors.
  • Unlock both the right-side Agent configuration form and the chat Composer immediately after cancellation.
  • Keep local stream detachment separate from an explicit user stop.
  • Handle abort events idempotently and prevent duplicate backend stop requests.
  • Ignore late NL2Agent state events after cancellation so delayed SSE messages cannot lock the form again.

Why

NL2Agent previously performed completion validation only when a limited final Prompt field batch was saved. A single-point Prompt optimization could therefore update the database successfully without emitting agent_generation_completed, leaving the frontend flow locked.

Manual cancellation stopped the backend conversation but did not update the NL2Agent frontend flow state. The form consequently remained locked even though generation had already stopped.

Impact

  • The Agent configuration form unlocks after a successful single-field Prompt optimization when the persisted Agent is complete.
  • Partial Prompt updates remain in the normal saved state and do not report false completion.
  • Explicitly stopping NL2Agent generation unlocks the form and Composer immediately.
  • Late state events after cancellation no longer restore a stale locked state.
  • Existing backend conversation cancellation behavior remains unchanged.
  • Local stream detachment does not incorrectly mark generation as stopped.
  • No public API, SSE payload, or database schema changes are introduced.

Validation

  • Added coverage for completion validation after individual Prompt field saves.
  • Added coverage confirming incomplete persisted Prompt state remains agent_draft_fields_saved.
  • Added coverage for trusted context reuse with Prompt completion validation.
  • Focused backend tests passed: 8 passed.
  • git diff --check origin/develop...HEAD passed.
  • Frontend tests and builds were not run in this workspace as requested.

Known limitations

  • No authenticated browser end-to-end test was run for the complete Prompt optimization and manual cancellation workflows.

Screenshots

image

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.

πŸ“’ Thoughts on this report? Let us know!

@WMC001
WMC001 merged commit 36da7f3 into develop Aug 27, 2026
16 checks passed
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.

3 participants