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:
hupenglong1
2026-05-25 17:46:51 +08:00
parent 2acbd0b509
commit 5b708d2996
3 changed files with 24 additions and 24 deletions
@@ -93,6 +93,7 @@ import {
} from "@/lib/claw-active-session";
import { useClawSessionReplay } from "@/lib/claw-session-replay";
import { cn } from "@/lib/utils";
import { dispatchSkillToggled } from "@/lib/use-training-mode";
type ComposerInsertEvent = CustomEvent<{ text: string }>;
@@ -1800,6 +1801,7 @@ function SkillInsertDialog() {
);
}
setSkills(payload);
dispatchSkillToggled({ skill: skill.name, enabled });
setStatus(enabled ? `已启用 ${skill.name}` : `已停用 ${skill.name}`);
} catch (err) {
setSkills(previous);