Files
tutti/packages/agent/gui/agent-gui/agentGuiNode/controller/useAgentGUISessionDetailTransport.spec.tsx
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

81 lines
2.5 KiB
TypeScript

import { renderHook } from "@testing-library/react";
import type {
AgentActivityMessage,
AgentActivitySnapshot
} from "@tutti-os/agent-activity-core";
import type { PropsWithChildren, RefObject } from "react";
import { describe, expect, it } from "vitest";
import {
AgentGUIRuntimeProvider,
type AgentGUIRuntime
} from "../../../agentActivityRuntime";
import { createTestAgentSessionEngine } from "../../../shared/testing/createTestAgentSessionEngine";
import type { AgentGUINodeData } from "../../../types";
import { useAgentGUISessionDetailTransport } from "./useAgentGUISessionDetailTransport";
describe("useAgentGUISessionDetailTransport", () => {
it("renders optimistic text without treating its version as history coverage", () => {
const optimisticMessage = message();
const runtime = createRuntime({
sessionMessagesById: { "session-1": [optimisticMessage] }
} as unknown as AgentActivitySnapshot);
const wrapper = ({ children }: PropsWithChildren) => (
<AgentGUIRuntimeProvider runtime={runtime}>
{children}
</AgentGUIRuntimeProvider>
);
const rendered = renderHook(
() =>
useAgentGUISessionDetailTransport({
activeConversationId: "session-1",
activeConversationIdRef: ref("session-1"),
agentActivityRuntime: runtime,
agentActivityRuntimeOrigin: "test",
dataRef: ref({ provider: "codex" } as AgentGUINodeData),
isMountedRef: ref(true),
sessionEngine: createTestAgentSessionEngine("workspace-1"),
sessionFamily: {
childSessions: [],
messagesBySessionId: {},
pendingInteractions: [],
rootSession: null
},
workspaceId: "workspace-1"
}),
{ wrapper }
);
expect(rendered.result.current.activeSessionView).toBeNull();
expect(rendered.result.current.resolveSessionMessages("session-1")).toEqual(
[optimisticMessage]
);
});
});
function createRuntime(snapshot: AgentActivitySnapshot): AgentGUIRuntime {
return {
getSnapshot: () => snapshot,
origin: "test",
subscribe: () => () => {}
} as unknown as AgentGUIRuntime;
}
function message(): AgentActivityMessage {
return {
agentSessionId: "session-1",
kind: "text",
messageId: "message-1",
occurredAtUnixMs: 1,
payload: { text: "streaming" },
role: "assistant",
status: "streaming",
turnId: "turn-1",
version: 0,
workspaceId: "workspace-1"
};
}
function ref<T>(current: T): RefObject<T> {
return { current };
}