























@@ -520,7 +520,8 @@ describe("switchChatSession", () => {
520520compactionStatus: { phase: "active" },
521521fallbackStatus: { phase: "active" },
522522chatAvatarUrl: "/avatar/old",
523-chatQueue: [{ id: "queued" }],
523+chatQueue: [{ id: "queued", text: "message B", createdAt: 1 }],
524+chatQueueBySession: {},
524525chatRunId: "run-1",
525526chatSideResultTerminalRuns: new Set(["btw-run-1"]),
526527chatStreamStartedAt: 1,
@@ -542,6 +543,10 @@ describe("switchChatSession", () => {
542543switchChatSession(state, "agent:main:test-b");
543544await Promise.resolve();
544545546+expect(state.chatQueue).toEqual([]);
547+expect(state.chatQueueBySession.main).toEqual([
548+{ id: "queued", text: "message B", createdAt: 1 },
549+]);
545550expect(state.chatSideResult).toBeNull();
546551expect(state.chatSideResultTerminalRuns.size).toBe(0);
547552expect(
@@ -562,6 +567,50 @@ describe("switchChatSession", () => {
562567});
563568});
564569570+it("restores queued messages when switching back to their session", async () => {
571+const settings = createSettings();
572+const state = {
573+sessionKey: "main",
574+chatMessage: "",
575+chatAttachments: [],
576+chatMessages: [],
577+chatToolMessages: [],
578+chatStreamSegments: [],
579+chatThinkingLevel: null,
580+chatStream: "stream",
581+chatSideResult: null,
582+lastError: null,
583+compactionStatus: null,
584+fallbackStatus: null,
585+chatAvatarUrl: null,
586+chatQueue: [{ id: "queued-1", text: "message B", createdAt: 1 }],
587+chatQueueBySession: {},
588+chatRunId: "run-1",
589+chatSideResultTerminalRuns: new Set<string>(),
590+chatStreamStartedAt: 1,
591+ settings,
592+applySettings(next: typeof settings) {
593+state.settings = next;
594+},
595+loadAssistantIdentity: vi.fn(),
596+resetToolStream: vi.fn(),
597+resetChatScroll: vi.fn(),
598+resetChatInputHistoryNavigation: vi.fn(),
599+} as unknown as AppViewState;
600+601+refreshChatAvatarMock.mockResolvedValue(undefined);
602+refreshSlashCommandsMock.mockResolvedValue(undefined);
603+loadChatHistoryMock.mockResolvedValue(undefined);
604+loadSessionsMock.mockResolvedValue(undefined);
605+606+switchChatSession(state, "agent:main:other");
607+expect(state.chatQueue).toEqual([]);
608+609+switchChatSession(state, "main");
610+611+expect(state.chatQueue).toEqual([{ id: "queued-1", text: "message B", createdAt: 1 }]);
612+});
613+565614it("does not force agentId=main for plain session keys", async () => {
566615const settings = createSettings();
567616const state = {
@@ -579,6 +628,7 @@ describe("switchChatSession", () => {
579628fallbackStatus: null,
580629chatAvatarUrl: null,
581630chatQueue: [],
631+chatQueueBySession: {},
582632chatRunId: null,
583633chatSideResultTerminalRuns: new Set<string>(),
584634chatStreamStartedAt: null,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。