Skip to content

Commit 7754818

Browse files
fix(server): read a copy key's result before the next key
The copy recorder in each frame holds one result, so reading it after the key had left the input queue let a second copy or cut key clear the first one's text before it was read. Read it inside the queue again, as before; the busy-frame wait before the key stays gone. AI-assisted; verified with the tests and tools listed above.
1 parent b6e0b78 commit 7754818

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

‎apps/server/src/preview/ServerBrowser.ts‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,12 +2464,10 @@ const make = Effect.gen(function* () {
24642464
),
24652465
});
24662466
viewer.pressedKeys.set(code || key, { key, code });
2467-
// Read outside the input queue: a busy frame answers late and must not hold later input.
2468-
if (copying)
2469-
return async () => {
2470-
const copied = await takeCopiedText(tab, since);
2471-
if (copied) viewer.push({ _tag: "clipboard", text: copied });
2472-
};
2467+
if (copying) {
2468+
const copied = await takeCopiedText(tab, since);
2469+
if (copied) viewer.push({ _tag: "clipboard", text: copied });
2470+
}
24732471
return;
24742472
}
24752473
case "text":
@@ -2726,9 +2724,8 @@ const make = Effect.gen(function* () {
27262724
: {}),
27272725
});
27282726
} else {
2729-
const dispatch = async (input: Record<string, unknown>) => {
2730-
await dispatchViewerInput(tab, session, viewer, input);
2731-
};
2727+
const dispatch = (input: Record<string, unknown>) =>
2728+
dispatchViewerInput(tab, session, viewer, input);
27322729
if (
27332730
message.type === "mouse" &&
27342731
message.action === "move" &&
@@ -2755,10 +2752,7 @@ const make = Effect.gen(function* () {
27552752
}),
27562753
);
27572754
} else {
2758-
const readCopy = await tab.control.human(viewer.id, () =>
2759-
dispatchViewerInput(tab, session, viewer, message),
2760-
);
2761-
await readCopy?.();
2755+
await tab.control.human(viewer.id, () => dispatch(message));
27622756
}
27632757
}
27642758
} catch {

0 commit comments

Comments
 (0)