fix: eliminate training panel flash on page load
- Don't restore applied state from localStorage on mount (was causing first-frame flash when skill was already enabled) - Always start with applied=false; only set true on user click Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -71,18 +71,10 @@ export function useModelIterationEnabled(): {
|
||||
// - 刷新页面也保持
|
||||
// 不走后端 PATCH 是为了避开 __LOCALID_* 临时 session id 导致 404
|
||||
export function useAppliedTraining(sessionId: string | null) {
|
||||
// 不再从 localStorage 恢复 applied 状态——面板只通过用户本次会话中
|
||||
// 显式点击 skill 按钮打开,避免页面加载时闪烁。
|
||||
const [applied, setApplied] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!sessionId || typeof window === "undefined") {
|
||||
setApplied(false);
|
||||
return;
|
||||
}
|
||||
const stored =
|
||||
window.localStorage.getItem(APPLIED_STORAGE_PREFIX + sessionId) === "1";
|
||||
setApplied(stored);
|
||||
}, [sessionId]);
|
||||
|
||||
const setAppliedPersist = useCallback(
|
||||
(next: boolean) => {
|
||||
setApplied(next);
|
||||
|
||||
Reference in New Issue
Block a user