fix: use custom event for training panel toggle, no more poll inference
SkillInsertDialog dispatches SKILL_TOGGLED_EVENT on user click. AssistantWorkspace listens for that event to set applied state. Completely eliminates poll-based state inference that caused flash. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
export const SESSION_UPDATED_EVENT = "claw-session-updated";
|
||||
export const SKILL_TOGGLED_EVENT = "claw-skill-toggled";
|
||||
const APPLIED_STORAGE_PREFIX = "claw.training.applied:";
|
||||
|
||||
const MODEL_ITERATION_SKILL_NAMES = new Set(["model-iteration"]);
|
||||
@@ -158,6 +159,15 @@ export function dispatchSessionUpdated(detail: SessionUpdatedDetail) {
|
||||
);
|
||||
}
|
||||
|
||||
export type SkillToggledDetail = { skill: string; enabled: boolean };
|
||||
|
||||
export function dispatchSkillToggled(detail: SkillToggledDetail) {
|
||||
if (typeof window === "undefined") return;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent<SkillToggledDetail>(SKILL_TOGGLED_EVENT, { detail }),
|
||||
);
|
||||
}
|
||||
|
||||
export function useTrainingMode(sessionId: string | null) {
|
||||
const [isTraining, setIsTraining] = useState(false);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user