
































@@ -689,6 +689,69 @@ extension TestChatTransportState {
689689}
690690}
691691692+@Test func appendsExternalSessionUserMessageForActiveSession() async throws {
693+let now = Date().timeIntervalSince1970 * 1000
694+let (transport, vm) = await makeViewModel(historyResponses: [historyPayload()])
695+696+await MainActor.run { vm.load() }
697+try await waitUntil("bootstrap history loaded") { await MainActor.run { vm.messages.isEmpty } }
698+699+ transport.emit(
700+.sessionMessage(
701+OpenClawSessionMessageEventPayload(
702+ sessionKey: "agent:main:main",
703+ message: OpenClawChatMessage(
704+ role: "user",
705+ content: [
706+OpenClawChatMessageContent(
707+ type: "text",
708+ text: "spoken transcript",
709+ mimeType: nil,
710+ fileName: nil,
711+ content: nil),
712+],
713+ timestamp: now),
714+ messageId: "msg-1",
715+ messageSeq: 1)))
716+717+try await waitUntil("external transcript visible") {
718+await MainActor.run {
719+ vm.messages.count == 1 &&
720+ vm.messages.first?.role == "user" &&
721+ vm.messages.first?.content.first?.text == "spoken transcript"
722+}
723+}
724+}
725+726+@Test func ignoresExternalSessionUserMessageForOtherSession() async throws {
727+let now = Date().timeIntervalSince1970 * 1000
728+let (transport, vm) = await makeViewModel(historyResponses: [historyPayload()])
729+730+await MainActor.run { vm.load() }
731+try await waitUntil("bootstrap history loaded") { await MainActor.run { vm.messages.isEmpty } }
732+733+ transport.emit(
734+.sessionMessage(
735+OpenClawSessionMessageEventPayload(
736+ sessionKey: "other",
737+ message: OpenClawChatMessage(
738+ role: "user",
739+ content: [
740+OpenClawChatMessageContent(
741+ type: "text",
742+ text: "other transcript",
743+ mimeType: nil,
744+ fileName: nil,
745+ content: nil),
746+],
747+ timestamp: now),
748+ messageId: "msg-2",
749+ messageSeq: 2)))
750+751+try await Task.sleep(nanoseconds: 50_000_000)
752+ #expect(await MainActor.run { vm.messages.isEmpty })
753+}
754+692755@Test func preservesMessageIDsAcrossHistoryRefreshes() async throws {
693756let now = Date().timeIntervalSince1970 * 1000
694757let history1 = historyPayload(messages: [chatTextMessage(role: "user", text: "hello", timestamp: now)])
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。