refactor(chat): optimize sandbox status logic and decouple UI/Status hooks#6713
Merged
c121914yu merged 2 commits intolabring:mainfrom Apr 3, 2026
Merged
refactor(chat): optimize sandbox status logic and decouple UI/Status hooks#6713c121914yu merged 2 commits intolabring:mainfrom
c121914yu merged 2 commits intolabring:mainfrom
Conversation
|
✅ Build Successful - Preview code-sandbox Image for this PR: |
|
✅ Build Successful - Preview fastgpt Image for this PR: |
|
✅ Build Successful - Preview mcp_server Image for this PR: |
c121914yu
reviewed
Apr 2, 2026
Collaborator
c121914yu
left a comment
There was a problem hiding this comment.
📊 代码审查总结
整体这是一个不错的重构 PR,将 useSandboxEditor 拆分为 useSandboxStatus(状态/网络逻辑)和 useSandboxEditor(UI 弹窗逻辑),关注点分离清晰。以下是详细的行级评论。
| setApiSandboxExists(false); | ||
| } | ||
|
|
||
| const chatRecords = useContextSelector(ChatRecordContext, (v) => { |
Collaborator
There was a problem hiding this comment.
🟢 优化建议 — 网络请求从轮询改为单次的取舍
原来的实现使用 useInterval(checkSandboxStatus, 10000) 每 10 秒轮询一次,现在改为仅在 chatId 变化时请求一次。
这个改动减少了不必要的网络请求,但也意味着:如果用户在聊天过程中 AI 创建了新的 sandbox(流式响应结束后),状态不会自动更新,用户需要切换聊天再切回来才能看到 sandbox 图标。
hasSandboxInHistory 通过 chatRecords 的 useMemo 派生可以部分弥补这个问题——但前提是 chatRecords 会在新消息完成后及时更新。请确认这个场景是否有覆盖。
Collaborator
PR Review: refactor(chat): optimize sandbox status logic and decouple UI/Status hooks📊 变更概览
✅ 优点
|
c121914yu
approved these changes
Apr 3, 2026
343c21b to
4c1ac36
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.