Skip to content

[studio] fix: scope LLM operations to the current form - #755

Open
ai-yang wants to merge 1 commit into
apache:rocketmq-studiofrom
ai-yang:agent/fix-llm-operation-ownership
Open

[studio] fix: scope LLM operations to the current form#755
ai-yang wants to merge 1 commit into
apache:rocketmq-studiofrom
ai-yang:agent/fix-llm-operation-ownership

Conversation

@ai-yang

@ai-yang ai-yang commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • rebase the fix onto the latest rocketmq-studio branch and adapt it to the redesigned LLM settings flow from feat: add claude-code and qoder agent engines with streaming prompt enhance #954
  • bind connection-test and explicit-save callbacks to the current component lifecycle, form generation, and operation generation
  • ignore late success, error, and loading callbacks after provider/engine/form changes, a newer operation, or unmount
  • prevent a stale save from clearing a replacement API key or publishing a success notification for an obsolete form
  • keep the current no-auto-save connection-test contract and temporarily disable connection tests while an explicit save is in flight

Fixes #738.

This remains separate from the initial configuration/model request ownership fixed by #737.

Root cause

handleTest and handleSave allowed every Promise callback to update the current form and shared loading/result state. A request started for an older form could therefore publish its result after the user changed provider, engine, or fields. An older explicit save could also clear a newly entered API key when its response arrived late.

The fix uses a shared operation generation for result ownership and per-request generations for loading ownership. Form changes invalidate connection tests immediately, while an already-sent save keeps its loading guard until it settles so another mutation cannot be started accidentally.

Compatibility

Verification

  • latest base: 228ad5298dbbeaa769f1c1de242117c6cfbe4216
  • unmodified rebased baseline: 6 deterministic ownership regressions failed in the targeted suite
  • targeted operation-ownership suite: 20 isolated processes, 8/8 each (160/160)
  • clean Node 20.20.2 container: 81 test files / 396 tests passed
  • ESLint: 0 errors (4 pre-existing Fast Refresh warnings)
  • TypeScript/Vite production build: passed, 7,997 modules transformed
  • Prettier check and git diff --check: passed

@ai-yang
ai-yang force-pushed the agent/fix-llm-operation-ownership branch from 97f56e7 to 0904d60 Compare August 5, 2026 02:29

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Well-implemented fix for stale state updates in LlmSettings. The generation counter pattern (beginOperation/ownsOperation) correctly prevents async callbacks from updating state after the component unmounts or the user switches providers. This fixes a common React race condition where a slow test/save request could overwrite newer state.

LGTM — clean implementation with good test coverage.


Automated review by github-manager-bot

@lizhimins

Copy link
Copy Markdown
Member

Closing: this area belongs to Track 3 (AI Native), which already has a complete design in progress (see #1024). Further LLM/AI changes should follow that design discussion instead of ad-hoc PRs. Thanks for the effort! / 关闭说明:该改动属于赛道三(AI Native)范围,赛道三已有完整的设计方案正在推进(见 #1024),LLM/AI 相关改动请跟随该设计讨论,不再单独接收零散 PR。感谢贡献!

@lizhimins lizhimins closed this Aug 6, 2026
@lizhimins lizhimins reopened this Aug 6, 2026
@lizhimins

Copy link
Copy Markdown
Member

Reopened — the previous close was applied in error; it does not fall under the Track 3 batch closure. / 重新打开:刚才的关闭属误操作,此 PR 不在赛道 3 批量关闭范围内。

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