Skip to content

The open-source app everyone uses to manage agents at work

Fix issue detail inbox archive shortcut

dottae21e44203321
diff --git a/ui/src/lib/keyboardShortcuts.test.ts b/ui/src/lib/keyboardShortcuts.test.ts
index f284a53ce7..f885dfc970 100644
--- a/ui/src/lib/keyboardShortcuts.test.ts
+++ b/ui/src/lib/keyboardShortcuts.test.ts
@@ -55,7 +55,7 @@ describe("keyboardShortcuts helpers", () => {
})).toBe("archive");
});
- it("disarms on the first non-y keypress", () => {
+ it("ignores non-y keypresses", () => {
const button = document.createElement("button");
expect(resolveInboxQuickArchiveKeyAction({
@@ -67,7 +67,7 @@ describe("keyboardShortcuts helpers", () => {
altKey: false,
target: button,
hasOpenDialog: false,
- })).toBe("disarm");
+ })).toBe("ignore");
});
it("stays inert for modifier combos before a real keypress", () => {
@@ -96,7 +96,7 @@ describe("keyboardShortcuts helpers", () => {
})).toBe("ignore");
});
- it("disarms instead of archiving when typing into an editor", () => {
+ it("ignores input typing instead of archiving", () => {
const input = document.createElement("input");
expect(resolveInboxQuickArchiveKeyAction({
@@ -108,7 +108,7 @@ describe("keyboardShortcuts helpers", () => {
altKey: false,
target: input,
hasOpenDialog: false,
- })).toBe("disarm");
+ })).toBe("ignore");
});
it("arms go-to-inbox on a clean g press", () => {
diff --git a/ui/src/lib/keyboardShortcuts.ts b/ui/src/lib/keyboardShortcuts.ts
index ab4cbd7335..7e549c391f 100644
--- a/ui/src/lib/keyboardShortcuts.ts
+++ b/ui/src/lib/keyboardShortcuts.ts
@@ -47,11 +47,11 @@ export function resolveInboxQuickArchiveKeyAction({
hasOpenDialog: boolean;
}): InboxQuickArchiveKeyAction {
if (!armed) return "ignore";
- if (defaultPrevented) return "disarm";
+ if (defaultPrevented) return "ignore";
if (metaKey || ctrlKey || altKey || isModifierOnlyKey(key)) return "ignore";
- if (hasOpenDialog || isKeyboardShortcutTextInputTarget(target)) return "disarm";
- if (key === "y") return "archive";
- return "disarm";
+ if (hasOpenDialog || isKeyboardShortcutTextInputTarget(target)) return "ignore";
+ if (key.toLowerCase() === "y") return "archive";
+ return "ignore";
}
export function resolveGoToInboxKeyAction({
diff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsx
index 3719b3a92f..76fd06eb25 100644
--- a/ui/src/pages/IssueDetail.tsx
+++ b/ui/src/pages/IssueDetail.tsx
@@ -24,7 +24,6 @@ import {
readIssueDetailLocationState,
readIssueDetailBreadcrumb,
rememberIssueDetailLocationState,
- shouldArmIssueDetailInboxQuickArchive,
} from "../lib/issueDetailBreadcrumb";
import {
hasBlockingShortcutDialog,
@@ -1235,46 +1234,17 @@ export function IssueDetail() {
return () => closePanel();
}, [closePanel, handleIssuePropertiesUpdate, issuePanelKey, openNewSubIssue, openPanel]);
- const inboxQuickArchiveArmedRef = useRef(false);
const goToInboxShortcutArmedRef = useRef(false);
const goToInboxShortcutTimeoutRef = useRef<number | null>(null);
const canQuickArchiveFromInbox =
keyboardShortcutsEnabled &&
- !issue?.hiddenAt &&
- sourceBreadcrumb.href.startsWith("/inbox") &&
- shouldArmIssueDetailInboxQuickArchive(location.state);
+ !issue?.hiddenAt;
useEffect(() => {
- if (!issue?.id || !canQuickArchiveFromInbox) {
- inboxQuickArchiveArmedRef.current = false;
- return;
- }
-
- inboxQuickArchiveArmedRef.current = true;
-
- const disarm = () => {
- inboxQuickArchiveArmedRef.current = false;
- };
-
- const handlePointerDown = () => {
- disarm();
- };
-
- const handleFocusIn = (event: FocusEvent) => {
- if (event.target instanceof HTMLElement && event.target !== document.body) {
- disarm();
- }
- };
-
- const handleSelectionChange = () => {
- const selection = window.getSelection();
- if (!selection || selection.isCollapsed || selection.toString().trim().length === 0) return;
- disarm();
- };
-
+ if (!issue?.id || !canQuickArchiveFromInbox) return;
const handleKeyDown = (event: KeyboardEvent) => {
const action = resolveInboxQuickArchiveKeyAction({
- armed: inboxQuickArchiveArmedRef.current,
+ armed: canQuickArchiveFromInbox,
defaultPrevented: event.defaultPrevented,
key: event.key,
metaKey: event.metaKey,
@@ -1284,9 +1254,6 @@ export function IssueDetail() {
hasOpenDialog: hasBlockingShortcutDialog(document),
});
- if (action === "ignore") return;
-
- disarm();
if (action !== "archive") return;
event.preventDefault();
@@ -1295,14 +1262,8 @@ export function IssueDetail() {
}
};
- document.addEventListener("pointerdown", handlePointerDown, true);
- document.addEventListener("focusin", handleFocusIn, true);
- document.addEventListener("selectionchange", handleSelectionChange);
document.addEventListener("keydown", handleKeyDown, true);
return () => {
- document.removeEventListener("pointerdown", handlePointerDown, true);
- document.removeEventListener("focusin", handleFocusIn, true);
- document.removeEventListener("selectionchange", handleSelectionChange);
document.removeEventListener("keydown", handleKeyDown, true);
};
}, [archiveFromInbox, canQuickArchiveFromInbox, issue?.id]);