feat(subagent): add session-owned task messaging and cancellation (#5985)

let's go!
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-05 05:16:33 +08:00
1 parent f75470e72f
commit 6ff96f2a8f
93 files changed
+5632 -1156

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { useEffect, useState } from "react";
import {
LOCAL_PREFS_CHANGED_EVENT,
readLocalPreferences,
type LocalPreferences,
} from "@/lib/local-preferences";
export function useLocalPreferences(): LocalPreferences {
const [preferences, setPreferences] = useState(readLocalPreferences);
useEffect(() => {
const refresh = () => setPreferences(readLocalPreferences());
const refreshFromEvent = (event: Event) => {
const detail = (event as CustomEvent<LocalPreferences | undefined>).detail;
setPreferences(detail ?? readLocalPreferences());
};
window.addEventListener("storage", refresh);
window.addEventListener("focus", refresh);
window.addEventListener(LOCAL_PREFS_CHANGED_EVENT, refreshFromEvent);
return () => {
window.removeEventListener("storage", refresh);
window.removeEventListener("focus", refresh);
window.removeEventListener(LOCAL_PREFS_CHANGED_EVENT, refreshFromEvent);
};
}, []);
return preferences;
}