feat(ai): run agent sessions as background tasks

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-08-26 14:09:08 +08:00
1 parent b37a1f8538
commit eeeb4e5011
34 files changed
+3440 -184

No files matched your search

+13 -2
View File
@@ -1,9 +1,12 @@
import { ref, type Ref } from "vue";
export type ToastAction = { label: string; onClick: () => void };
type ToastState = {
message: Ref<string>;
visible: Ref<boolean>;
timer: number;
action: Ref<ToastAction | undefined>;
};
declare global {
@@ -16,17 +19,25 @@ const toastState =
message: ref(""),
visible: ref(false),
timer: 0,
action: ref<ToastAction | undefined>(undefined),
});
export function useToast() {
function toast(msg: string, duration = 2000) {
function toast(msg: string, duration = 2000, action?: ToastAction) {
toastState.message.value = msg;
toastState.action.value = action;
toastState.visible.value = true;
clearTimeout(toastState.timer);
toastState.timer = window.setTimeout(() => {
toastState.visible.value = false;
toastState.action.value = undefined;
}, duration);
}
return { message: toastState.message, visible: toastState.visible, toast };
function dismissToast() {
toastState.visible.value = false;
toastState.action.value = undefined;
}
return { message: toastState.message, visible: toastState.visible, action: toastState.action, toast, dismissToast };
}