feat: add review shortcut confirmation setting

This commit is contained in:
Erik Kotsiuba
2026-04-29 02:40:29 +02:00
parent 2bf85b3f6f
commit 67891d147f
16 changed files with 385 additions and 54 deletions
+43
View File
@@ -0,0 +1,43 @@
import { SUBMIT_CHOICES } from "../constants/text.ts";
const REVIEW_SHORTCUT_DIGIT_MIN = 1;
const REVIEW_SHORTCUT_DIGIT_MAX = 3;
export interface ReviewShortcutResolution {
actionIndex?: number;
confirmed: boolean;
pendingActionIndex?: number;
}
export function resolveReviewShortcutDoublePress(
digit: number,
pendingActionIndex?: number
): ReviewShortcutResolution {
if (digit < REVIEW_SHORTCUT_DIGIT_MIN || digit > REVIEW_SHORTCUT_DIGIT_MAX) {
return { confirmed: false };
}
const actionIndex = digit - 1;
if (pendingActionIndex === actionIndex) {
return { actionIndex, confirmed: true };
}
return {
actionIndex,
confirmed: false,
pendingActionIndex: actionIndex,
};
}
export function getReviewShortcutHint(pendingActionIndex?: number): string {
if (pendingActionIndex === undefined) {
return "Press 1, 2, or 3 twice to confirm a review action.";
}
const actionLabel = SUBMIT_CHOICES[pendingActionIndex];
if (!actionLabel) {
return "Press 1, 2, or 3 twice to confirm a review action.";
}
return `Press ${pendingActionIndex + 1} again to ${actionLabel}.`;
}