Skip to content

Conversation

@jhr-debug
Copy link
Contributor

修复了桌面端 Playground 页面切换 Tab 时,原 Tab 中的 prompt 和参数被清空的问题。

原因:Tab 切换时 Zustand 状态和 URL 更新存在竞态条件,导致 setSelectedModel 被错误调用。

When switching tabs, there was a race condition between Zustand state update
and React Router URL update. The useEffect that syncs model from URL was
incorrectly calling setSelectedModel when activeTab and modelId were
temporarily out of sync, causing form data to be cleared.

Fix: Only sync model from URL when the active tab has no model selected yet,
avoiding the race condition entirely.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@chengzeyi
Copy link
Member

@codex improve this pr

@chatgpt-codex-connector
Copy link

Summary

  • Avoid resetting tab state when setSelectedModel is called with the same model id, reducing accidental prompt/parameter loss.

Testing

  • ⚠️ Not run (not requested).

View task →

@chengzeyi chengzeyi merged commit 9cc3513 into main Dec 27, 2025
4 checks passed
@chengzeyi chengzeyi deleted the fix/tab-switching-data-loss branch December 27, 2025 15:54
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