Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ui/hooks/useAppKeyboardShortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRef } from "react";
import type { LayoutMode } from "../../core/types";
import type { MenuId } from "../components/chrome/menu";
import {
isCreateReviewNoteKey,
isEscapeKey,
isHalfPageDownKey,
isHalfPageUpKey,
Expand Down Expand Up @@ -355,7 +356,7 @@ export function useAppKeyboardShortcuts({
return;
}

if (key.name?.toLowerCase() === "c" || key.sequence?.toLowerCase() === "c") {
if (isCreateReviewNoteKey(key)) {
runAndCloseMenu(startUserNote);
return;
}
Expand Down
11 changes: 11 additions & 0 deletions src/ui/lib/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ export function isSaveDraftNoteKey(key: KeyEvent) {
);
}

/** Match the unmodified review-note shortcut without stealing terminal copy chords. */
export function isCreateReviewNoteKey(key: KeyEvent) {
return (
(key.name === "c" || key.sequence === "c") &&
!key.ctrl &&
!key.meta &&
!key.option &&
!key.shift
);
}

/** Match any key alias that should scroll forward by a full viewport. */
export function isPageDownKey(key: KeyEvent) {
return (
Expand Down
10 changes: 10 additions & 0 deletions src/ui/lib/ui-lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { buildAgentPopoverContent, resolveAgentPopoverPlacement, wrapText } from "./agentPopover";
import { buildAppMenus } from "./appMenus";
import {
isCreateReviewNoteKey,
isEscapeKey,
isHalfPageDownKey,
isHalfPageUpKey,
Expand Down Expand Up @@ -280,6 +281,15 @@ describe("ui helpers", () => {
expect(isShiftSpacePageUpKey(createKeyEvent({ name: "space", shift: false }))).toBe(false);
});

test("review note shortcut only matches unmodified c", () => {
expect(isCreateReviewNoteKey(createKeyEvent({ name: "c" }))).toBe(true);
expect(isCreateReviewNoteKey(createKeyEvent({ sequence: "c" }))).toBe(true);
expect(isCreateReviewNoteKey(createKeyEvent({ name: "C", shift: true }))).toBe(false);
expect(isCreateReviewNoteKey(createKeyEvent({ name: "c", ctrl: true }))).toBe(false);
expect(isCreateReviewNoteKey(createKeyEvent({ name: "c", meta: true }))).toBe(false);
expect(isCreateReviewNoteKey(createKeyEvent({ name: "c", option: true }))).toBe(false);
});

test("fitText and padText clamp using the terminal fallback marker", () => {
expect(fitText("hello", 0)).toBe("");
expect(fitText("hello", 1)).toBe(".");
Expand Down
Loading