Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): keep artifact comments open while typing (#83070)

Shy Alterf2a5ade4d159
diff --git a/products/desktop/packages/ui/src/features/sessions/components/selectionCommentAction.test.ts b/products/desktop/packages/ui/src/features/sessions/components/selectionCommentAction.test.ts
index 7fb8a26b6a51..f02247a08e5e 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/selectionCommentAction.test.ts
+++ b/products/desktop/packages/ui/src/features/sessions/components/selectionCommentAction.test.ts
@@ -109,6 +109,34 @@ describe("selectionCommentAction", () => {
overlay.remove();
});
+ it.each(["Shift", "ArrowLeft", "Home", "End", "PageUp", "PageDown"])(
+ "ignores the %s selection key while focus is inside the comment UI",
+ (key) => {
+ const callbacks = {
+ onGestureStart: vi.fn(),
+ onSelectionSettled: vi.fn(),
+ } satisfies SelectionSettleGateCallbacks;
+ const remove = installSelectionSettleGate(document, callbacks);
+ const overlay = document.createElement("div");
+ overlay.setAttribute("data-selection-comment-overlay", "");
+ const textarea = document.createElement("textarea");
+ overlay.appendChild(textarea);
+ document.body.appendChild(overlay);
+
+ textarea.dispatchEvent(
+ new KeyboardEvent("keydown", { key, bubbles: true }),
+ );
+ textarea.dispatchEvent(
+ new KeyboardEvent("keyup", { key, bubbles: true }),
+ );
+ expect(callbacks.onGestureStart).not.toHaveBeenCalled();
+ expect(callbacks.onSelectionSettled).not.toHaveBeenCalled();
+
+ remove();
+ overlay.remove();
+ },
+ );
+
it("ignores secondary buttons, which open menus instead of selecting", () => {
const callbacks = { onGestureStart: vi.fn() };
const remove = installSelectionSettleGate(document, callbacks);
@@ -180,6 +208,27 @@ describe("selectionCommentAction", () => {
remove();
});
+ it("still treats Shift outside the comment UI as a selection gesture", async () => {
+ const callbacks = {
+ onGestureStart: vi.fn(),
+ onSelectionSettled: vi.fn(),
+ } satisfies SelectionSettleGateCallbacks;
+ const remove = installSelectionSettleGate(document, callbacks);
+ const target = eventTarget();
+
+ target.dispatchEvent(
+ new KeyboardEvent("keydown", { key: "Shift", bubbles: true }),
+ );
+ expect(callbacks.onGestureStart).toHaveBeenCalledTimes(1);
+
+ target.dispatchEvent(
+ new KeyboardEvent("keyup", { key: "Shift", bubbles: true }),
+ );
+ await settleFrames();
+ expect(callbacks.onSelectionSettled).toHaveBeenCalledTimes(1);
+ remove();
+ });
+
it("distinguishes typing from select-all and settles after the modifier is released", async () => {
const callbacks = {
onGestureStart: vi.fn(),
diff --git a/products/desktop/packages/ui/src/features/sessions/components/selectionCommentAction.ts b/products/desktop/packages/ui/src/features/sessions/components/selectionCommentAction.ts
index d6354cf0a391..27ef8f41b0d2 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/selectionCommentAction.ts
+++ b/products/desktop/packages/ui/src/features/sessions/components/selectionCommentAction.ts
@@ -276,7 +276,7 @@ export function installSelectionSettleGate(
settle();
};
const onKeyDown = (event: KeyboardEvent) => {
- if (!isSelectionKey(event)) {
+ if (inActionUi(event.target) || !isSelectionKey(event)) {
return;
}
keyGesture = true;