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
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { useMemo, useRef } from "react";
|
|
import type { AgentConversationVM } from "../contracts/agentConversationVM";
|
|
import type { WorkspaceAgentSessionDetailViewModel } from "../../workspaceAgentSessionDetailViewModel";
|
|
import {
|
|
projectAgentConversationVM,
|
|
reconcileProjectedAgentConversationVM
|
|
} from "./agentConversationProjection";
|
|
|
|
export function useProjectedAgentConversation({
|
|
conversation,
|
|
detail,
|
|
avoidGroupingEdits = false
|
|
}: {
|
|
conversation?: AgentConversationVM | null;
|
|
detail?: WorkspaceAgentSessionDetailViewModel | null;
|
|
avoidGroupingEdits?: boolean;
|
|
}): AgentConversationVM | null {
|
|
const previousConversationRef = useRef<AgentConversationVM | null>(null);
|
|
|
|
return useMemo(() => {
|
|
if (!conversation && !detail) {
|
|
previousConversationRef.current = null;
|
|
return null;
|
|
}
|
|
|
|
const nextConversation =
|
|
conversation ??
|
|
projectAgentConversationVM(
|
|
detail as WorkspaceAgentSessionDetailViewModel,
|
|
{
|
|
avoidGroupingEdits
|
|
}
|
|
);
|
|
const reconciledConversation = reconcileProjectedAgentConversationVM(
|
|
previousConversationRef.current,
|
|
nextConversation
|
|
);
|
|
previousConversationRef.current = reconciledConversation;
|
|
return reconciledConversation;
|
|
}, [avoidGroupingEdits, conversation, detail]);
|
|
}
|