Files
tutti/packages/agent/gui/agentSideConversationPresentation.ts
agent-radar 2ed3415fb7
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
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

60 lines
2.1 KiB
TypeScript

import type { AgentGUISideConversationSurfaceProps } from "./agent-gui/agentGuiNode/view/AgentGUISideConversationPane";
export interface AgentGUISideConversationProjection {
sideAgentSessionId: string;
sourceAgentSessionId: string;
surfaceProps: AgentGUISideConversationSurfaceProps;
close(): Promise<void>;
}
export interface AgentGUISideConversationIdentity {
sideAgentSessionId: string;
sourceAgentSessionId: string;
}
export interface AgentGUISideConversationPresentation {
getSnapshot(): AgentGUISideConversationProjection | null;
getIdentitySnapshot(): AgentGUISideConversationIdentity | null;
publish(projection: AgentGUISideConversationProjection | null): void;
subscribe(listener: () => void): () => void;
subscribeIdentity(listener: () => void): () => void;
}
export function createAgentGUISideConversationPresentation(): AgentGUISideConversationPresentation {
let projection: AgentGUISideConversationProjection | null = null;
let identity: AgentGUISideConversationIdentity | null = null;
const listeners = new Set<() => void>();
const identityListeners = new Set<() => void>();
return {
getSnapshot: () => projection,
getIdentitySnapshot: () => identity,
publish(nextProjection) {
if (projection === nextProjection) return;
const nextIdentity = nextProjection
? {
sideAgentSessionId: nextProjection.sideAgentSessionId,
sourceAgentSessionId: nextProjection.sourceAgentSessionId
}
: null;
const identityChanged =
identity?.sideAgentSessionId !== nextIdentity?.sideAgentSessionId ||
identity?.sourceAgentSessionId !== nextIdentity?.sourceAgentSessionId;
projection = nextProjection;
if (identityChanged) {
identity = nextIdentity;
for (const listener of identityListeners) listener();
}
for (const listener of listeners) listener();
},
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
subscribeIdentity(listener) {
identityListeners.add(listener);
return () => identityListeners.delete(listener);
}
};
}