mirror of
https://github.com/aiclientproxy/proxycast.git
synced 2026-09-24 23:10:56 +08:00
release: bump version to v0.75.0
This commit is contained in:
@@ -421,6 +421,48 @@ export type ServerMessage =
|
||||
| { beginRendering: BeginRendering }
|
||||
| { deleteSurface: DeleteSurface };
|
||||
|
||||
/** 插件任务状态 */
|
||||
export type PluginTaskState =
|
||||
| "queued"
|
||||
| "running"
|
||||
| "retrying"
|
||||
| "succeeded"
|
||||
| "failed"
|
||||
| "cancelled"
|
||||
| "timed_out";
|
||||
|
||||
/** 插件任务错误 */
|
||||
export interface PluginTaskError {
|
||||
code?: string;
|
||||
message: string;
|
||||
retryable: boolean;
|
||||
}
|
||||
|
||||
/** 插件任务事件 */
|
||||
export interface PluginTaskEventPayload {
|
||||
pluginId: PluginId;
|
||||
taskId: string;
|
||||
operation: string;
|
||||
state: PluginTaskState;
|
||||
attempt: number;
|
||||
timestamp: string;
|
||||
error?: PluginTaskError;
|
||||
}
|
||||
|
||||
/** 插件任务记录 */
|
||||
export interface PluginTaskRecord {
|
||||
taskId: string;
|
||||
pluginId: PluginId;
|
||||
operation: string;
|
||||
state: PluginTaskState;
|
||||
attempt: number;
|
||||
maxRetries: number;
|
||||
startedAt: string;
|
||||
endedAt?: string;
|
||||
durationMs?: number;
|
||||
error?: PluginTaskError;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// 消息类型 (Client → Server)
|
||||
// ============================================================================
|
||||
|
||||
@@ -11,6 +11,7 @@ import { surfaceManager, SurfaceManager } from "./SurfaceManager";
|
||||
import { initPluginUI } from "./index";
|
||||
import type {
|
||||
PluginId,
|
||||
PluginTaskEventPayload,
|
||||
SurfaceId,
|
||||
SurfaceState,
|
||||
ServerMessage,
|
||||
@@ -31,6 +32,8 @@ interface UsePluginUIOptions {
|
||||
interface UsePluginUIResult {
|
||||
/** 插件的所有 Surface */
|
||||
surfaces: SurfaceState[];
|
||||
/** 插件任务事件(用于状态可观测) */
|
||||
taskEvents: PluginTaskEventPayload[];
|
||||
/** 是否正在加载 */
|
||||
loading: boolean;
|
||||
/** 错误信息 */
|
||||
@@ -49,6 +52,7 @@ export function usePluginUI(options: UsePluginUIOptions): UsePluginUIResult {
|
||||
const { pluginId, autoInit = true, manager = surfaceManager } = options;
|
||||
|
||||
const [surfaces, setSurfaces] = useState<SurfaceState[]>([]);
|
||||
const [taskEvents, setTaskEvents] = useState<PluginTaskEventPayload[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const initializedRef = useRef(false);
|
||||
@@ -73,6 +77,41 @@ export function usePluginUI(options: UsePluginUIOptions): UsePluginUIResult {
|
||||
return unsubscribe;
|
||||
}, [pluginId, manager]);
|
||||
|
||||
// 监听插件任务事件
|
||||
useEffect(() => {
|
||||
let unlisten: UnlistenFn | null = null;
|
||||
|
||||
const setupTaskListener = async () => {
|
||||
try {
|
||||
unlisten = await safeListen<PluginTaskEventPayload>(
|
||||
"plugin-task-event",
|
||||
(event) => {
|
||||
if (event.payload.pluginId !== pluginId) {
|
||||
return;
|
||||
}
|
||||
setTaskEvents((prev) => {
|
||||
const next = [...prev, event.payload];
|
||||
if (next.length > 100) {
|
||||
return next.slice(next.length - 100);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("[usePluginUI] 监听任务事件失败:", err);
|
||||
}
|
||||
};
|
||||
|
||||
setupTaskListener();
|
||||
|
||||
return () => {
|
||||
if (unlisten) {
|
||||
unlisten();
|
||||
}
|
||||
};
|
||||
}, [pluginId]);
|
||||
|
||||
// 监听来自 Rust 的 UI 消息
|
||||
useEffect(() => {
|
||||
let unlisten: UnlistenFn | null = null;
|
||||
@@ -178,6 +217,7 @@ export function usePluginUI(options: UsePluginUIOptions): UsePluginUIResult {
|
||||
|
||||
return {
|
||||
surfaces,
|
||||
taskEvents,
|
||||
loading,
|
||||
error,
|
||||
handleAction,
|
||||
|
||||
@@ -131,7 +131,8 @@ const defaultMocks: Record<string, any> = {
|
||||
success: true,
|
||||
reused: false,
|
||||
browser_source: "system",
|
||||
browser_path: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||
browser_path:
|
||||
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||
profile_dir: "/tmp/proxycast/chrome_profiles/search_google",
|
||||
remote_debugging_port: 13001,
|
||||
pid: 12345,
|
||||
@@ -172,12 +173,11 @@ const defaultMocks: Record<string, any> = {
|
||||
auto_fallback: true,
|
||||
}),
|
||||
set_browser_backend_policy: (args: any) => ({
|
||||
priority:
|
||||
args?.policy?.priority ?? [
|
||||
"aster_compat",
|
||||
"proxycast_extension_bridge",
|
||||
"cdp_direct",
|
||||
],
|
||||
priority: args?.policy?.priority ?? [
|
||||
"aster_compat",
|
||||
"proxycast_extension_bridge",
|
||||
"cdp_direct",
|
||||
],
|
||||
auto_fallback: args?.policy?.auto_fallback ?? true,
|
||||
}),
|
||||
get_browser_backends_status: () => ({
|
||||
@@ -321,6 +321,10 @@ const defaultMocks: Record<string, any> = {
|
||||
unload_plugin: () => ({ success: true }),
|
||||
uninstall_plugin: () => ({ success: true }),
|
||||
launch_plugin_ui: () => ({}),
|
||||
list_plugin_tasks: () => [],
|
||||
get_plugin_task: () => null,
|
||||
cancel_plugin_task: () => true,
|
||||
get_plugin_queue_stats: () => [],
|
||||
|
||||
// 凭证池相关
|
||||
get_relay_providers: () => [],
|
||||
|
||||
Reference in New Issue
Block a user