源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
import { useMemo } from "react";
|
||||
import type {
|
||||
AgentGUITargetConnectionSource,
|
||||
AgentGUITargetConnectionState
|
||||
} from "../../../types";
|
||||
import { useEngineSelector } from "../../../shared/engine/useEngineSelector";
|
||||
import {
|
||||
AgentGUITargetConnectionController,
|
||||
type AgentGUITargetConnectionBinding
|
||||
} from "./AgentGUITargetConnectionController";
|
||||
|
||||
export function useAgentGUITargetConnectionState(input: {
|
||||
agentTargetId?: string | null;
|
||||
source?: AgentGUITargetConnectionSource | null;
|
||||
}): {
|
||||
blocked: boolean;
|
||||
visibleState: AgentGUITargetConnectionState | null;
|
||||
} {
|
||||
const binding = useMemo<AgentGUITargetConnectionBinding>(
|
||||
() => ({
|
||||
getSnapshot: () => {
|
||||
const agentTargetId = input.agentTargetId?.trim() ?? "";
|
||||
return agentTargetId
|
||||
? (input.source?.getConnectionState(agentTargetId) ?? null)
|
||||
: null;
|
||||
},
|
||||
subscribe: (listener) =>
|
||||
input.source?.subscribe(listener) ?? (() => undefined)
|
||||
}),
|
||||
[input.agentTargetId, input.source]
|
||||
);
|
||||
const state = useEngineSelector(
|
||||
binding,
|
||||
identityTargetConnectionState,
|
||||
targetConnectionStatesEqual
|
||||
);
|
||||
const controller = useMemo(
|
||||
() => new AgentGUITargetConnectionController({ source: binding }),
|
||||
[binding]
|
||||
);
|
||||
const visibleState = useEngineSelector(
|
||||
controller,
|
||||
identityTargetConnectionState,
|
||||
targetConnectionStatesEqual
|
||||
);
|
||||
return {
|
||||
blocked: state?.status === "connecting" || state?.status === "unavailable",
|
||||
visibleState
|
||||
};
|
||||
}
|
||||
|
||||
function identityTargetConnectionState(
|
||||
state: AgentGUITargetConnectionState | null
|
||||
): AgentGUITargetConnectionState | null {
|
||||
return state;
|
||||
}
|
||||
|
||||
function targetConnectionStatesEqual(
|
||||
left: AgentGUITargetConnectionState | null,
|
||||
right: AgentGUITargetConnectionState | null
|
||||
): boolean {
|
||||
return (
|
||||
left?.status === right?.status && left?.retryAttempt === right?.retryAttempt
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user