fix: announce chat replies from the active pane

This commit is contained in:
Shakker
2026-07-15 00:59:27 +01:00
committed by Shakker
parent 59dd62d1af
commit c6dfda6eee
4 changed files with 44 additions and 1 deletions

View File

@@ -1944,6 +1944,7 @@ class ChatPane extends OpenClawLightDomElement {
transcript: this.transcript,
paneId: this.paneId,
sessionKey: state.sessionKey,
announceTranscript: this.active,
onSessionKeyChange: (next) => {
this.onPaneSessionChange?.(this.paneId, next);
},

View File

@@ -1103,6 +1103,45 @@ describe("chat transcript rendering", () => {
"New answer",
);
});
it("does not announce appended rows from an inactive split pane", () => {
const transcript = new ChatTranscriptController({
addController: () => undefined,
removeController: () => undefined,
requestUpdate: () => undefined,
updateComplete: Promise.resolve(true),
} satisfies ReactiveControllerHost);
const container = document.createElement("div");
const existing = {
__testVirtualRow: true,
__testVirtualKey: "assistant-1",
__testVirtualRole: "assistant",
content: "Existing answer",
};
const appended = {
__testVirtualRow: true,
__testVirtualKey: "assistant-2",
__testVirtualRole: "assistant",
content: "New answer",
};
render(
renderChat(createChatProps({ announceTranscript: false, transcript, messages: [existing] })),
container,
);
render(
renderChat(
createChatProps({
announceTranscript: false,
transcript,
messages: [existing, appended],
}),
),
container,
);
expect(container.querySelector(".chat-transcript-announcement")?.textContent).toBe("");
});
});
describe("chat goal status", () => {

View File

@@ -72,6 +72,7 @@ export type ChatProps = {
transcript: ChatTranscriptController;
paneId: string;
sessionKey: string;
announceTranscript?: boolean;
onSessionKeyChange: (next: string) => void;
thinkingLevel: string | null;
showThinking: boolean;
@@ -264,6 +265,7 @@ export function renderChat(props: ChatProps) {
{
paneId: props.paneId,
sessionKey: props.sessionKey,
announceTranscript: props.announceTranscript,
loading: props.loading,
historyPagination: props.historyPagination,
messages: props.messages,

View File

@@ -91,6 +91,7 @@ type ChatThreadState = {
type ChatThreadProps = {
paneId: string;
sessionKey: string;
announceTranscript?: boolean;
loading: boolean;
historyPagination?: {
loading: boolean;
@@ -1113,7 +1114,7 @@ function renderChatThreadContents(
transcriptRows,
(row) => (row.kind === "item" ? renderItem(row.item) : row.content),
latestTranscriptAnnouncement(collapsedItems),
!state.searchOpen && !props.loading,
props.announceTranscript !== false && !state.searchOpen && !props.loading,
props.historyPagination
? renderHistorySentinel(props.historyPagination.loading)
: nothing,