Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(web): release claimed voice materials when a turn is rejected early

shoudi zheng106e894765d8
diff --git a/apps/web/src/features/rooms/chat/use-composer-voice.ts b/apps/web/src/features/rooms/chat/use-composer-voice.ts
index e788f9ca..a2ca97b8 100644
--- a/apps/web/src/features/rooms/chat/use-composer-voice.ts
+++ b/apps/web/src/features/rooms/chat/use-composer-voice.ts
@@ -132,18 +132,19 @@ export function useComposerVoiceTurn({
};
let snapshot: MessageComposition | undefined;
return async (voiceLiveTurn?: TeamHubVoiceLiveTurnMarker) => {
- if (references.pendingAvailability)
- throw new Error(
- "Message references are still loading. Exit to review the draft.",
- );
- if (references.unavailableMentions.length)
- throw new Error(
- unavailableMentionsError(
- references.unavailableMentions,
- () => "Exit to review the draft.",
- ),
- );
try {
+ // Inside the try so a rejected turn releases its claimed materials.
+ if (references.pendingAvailability)
+ throw new Error(
+ "Message references are still loading. Exit to review the draft.",
+ );
+ if (references.unavailableMentions.length)
+ throw new Error(
+ unavailableMentionsError(
+ references.unavailableMentions,
+ () => "Exit to review the draft.",
+ ),
+ );
snapshot ??= withVoiceMaterials(
{
...value,
diff --git a/apps/web/src/features/rooms/chat/voice-mode/voice-materials-composer.test.tsx b/apps/web/src/features/rooms/chat/voice-mode/voice-materials-composer.test.tsx
index 25294ed2..2439a0a8 100644
--- a/apps/web/src/features/rooms/chat/voice-mode/voice-materials-composer.test.tsx
+++ b/apps/web/src/features/rooms/chat/voice-mode/voice-materials-composer.test.tsx
@@ -267,6 +267,7 @@ describe("voice material composer", () => {
initialMentions: [staleActor],
initialValue: "@Retired Agent",
});
+ fireEvent.click(screen.getByText("Select document paragraph"));
act(() =>
voice.binding!.onChange({
entered: true,
@@ -280,6 +281,33 @@ describe("voice material composer", () => {
"@Retired Agent is not available in this Room. Exit to review the draft.",
);
expect(f.onSend).not.toHaveBeenCalled();
+
+ // After removing the mention, the next turn still carries the material.
+ act(() =>
+ voice.binding!.onChange({
+ entered: false,
+ text: "",
+ sourceId: "source-1",
+ }),
+ );
+ fireEvent.change(screen.getByLabelText("Message Room"), {
+ target: { value: "" },
+ });
+ act(() =>
+ voice.binding!.onChange({
+ entered: true,
+ text: "Explain this",
+ sourceId: "source-2",
+ }),
+ );
+ await act(async () =>
+ voice.binding!.prepareSend("Explain this", "turn-after-removal")(),
+ );
+ expect(f.onSend).toHaveBeenCalledWith(
+ expect.objectContaining({
+ body: expect.stringContaining(selection.quote),
+ }),
+ );
});
it("offers only Send once the draft addresses someone", async () => {