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

80 lines
2.2 KiB
TypeScript

import { act, renderHook } from "@testing-library/react";
import {
createAgentSessionFamilySnapshotSelector,
normalizeAgentActivitySession,
type AgentActivityMessage
} from "@tutti-os/agent-activity-core";
import { describe, expect, it } from "vitest";
import { useEngineSelector } from "../../../shared/engine/useEngineSelector";
import { createTestAgentSessionEngine } from "../../../shared/testing/createTestAgentSessionEngine";
describe("AgentGUI Session-family subscription", () => {
it("does not render an unrelated AgentGUI when another Session streams", () => {
const engine = createTestAgentSessionEngine("workspace-1");
engine.dispatch({
sessions: [
normalizeAgentActivitySession(session("session-a")),
normalizeAgentActivitySession(session("session-b"))
],
type: "session/snapshotReceived"
});
const selectA = createAgentSessionFamilySnapshotSelector("session-a");
const selectB = createAgentSessionFamilySnapshotSelector("session-b");
let rendersA = 0;
let rendersB = 0;
renderHook(() => {
rendersA += 1;
return useEngineSelector(engine, selectA);
});
renderHook(() => {
rendersB += 1;
return useEngineSelector(engine, selectB);
});
const initialRendersA = rendersA;
const initialRendersB = rendersB;
act(() => {
engine.dispatch({
messages: [message("message-a", "session-a")],
type: "message/snapshotReceived"
});
});
expect(rendersA).toBeGreaterThan(initialRendersA);
expect(rendersB).toBe(initialRendersB);
});
});
function session(agentSessionId: string) {
return {
activeTurnId: null,
agentSessionId,
cwd: "/workspace",
latestTurnInteractions: [],
pendingInteractions: [],
provider: "codex",
title: agentSessionId,
workspaceId: "workspace-1"
};
}
function message(
messageId: string,
agentSessionId: string
): AgentActivityMessage {
return {
agentSessionId,
kind: "text",
messageId,
occurredAtUnixMs: 1,
payload: { text: messageId },
role: "assistant",
sequence: 1,
status: null,
turnId: "turn-1",
version: 1,
workspaceId: "workspace-1"
};
}