Skip to content

Commit 99508f5

Browse files
committed
fix(sounds): seed reappearing threads without historical cues
1 parent b32b5c5 commit 99508f5

2 files changed

Lines changed: 7 additions & 20 deletions

File tree

‎packages/client-runtime/src/interactionSounds.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,17 @@ describe("interaction sounds", () => {
417417
expect(reconnected.cues).toEqual(["bloom"]);
418418
});
419419

420-
it("compares a thread first discovered after reconnect with an idle baseline", () => {
420+
it("does not replay pending input when a historical thread reappears", () => {
421421
const discovered = observeThreadSoundState(null, makeThread({ hasPendingUserInput: true }), {
422422
environmentLive: true,
423423
environmentPreviouslyLive: true,
424424
settingsHydrated: true,
425425
});
426426

427-
expect(discovered.cues).toEqual(["bloom"]);
427+
expect(discovered.cues).toEqual([]);
428428
});
429429

430-
it("plays completion for a thread first discovered after reconnect", () => {
430+
it("does not replay completion when a historical thread reappears", () => {
431431
const discovered = observeThreadSoundState(
432432
null,
433433
makeThread({
@@ -448,7 +448,7 @@ describe("interaction sounds", () => {
448448
},
449449
);
450450

451-
expect(discovered.cues).toEqual(["success"]);
451+
expect(discovered.cues).toEqual([]);
452452
});
453453

454454
it("seeds a thread from the first live hydration without playing a cue", () => {

‎packages/client-runtime/src/interactionSounds.ts‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,16 @@ export function observeThreadSoundState(
134134
},
135135
): ThreadSoundObservation {
136136
const current = [thread];
137-
if (!options.environmentPreviouslyLive) {
137+
if (previous === null || !options.environmentPreviouslyLive) {
138138
return { state: captureThreadSoundState(current), cues: [] };
139139
}
140-
const baseline =
141-
previous ??
142-
new Map([
143-
[
144-
threadKey(thread),
145-
{
146-
completedTurn: null,
147-
userInitiatedTurn: null,
148-
hasPendingUserInput: false,
149-
hasPendingApprovals: false,
150-
},
151-
],
152-
]);
153140

154141
if (!options.environmentLive || !options.settingsHydrated) {
155-
return { state: baseline, cues: [] };
142+
return { state: previous, cues: [] };
156143
}
157144

158145
return {
159146
state: captureThreadSoundState(current),
160-
cues: deriveInteractionSoundCues(baseline, current),
147+
cues: deriveInteractionSoundCues(previous, current),
161148
};
162149
}

0 commit comments

Comments
 (0)