Refine mine inbox shortcut behavior

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-03-28 16:45:44 -05:00
parent 7d81e4cb2a
commit 403aeff7f6
5 changed files with 39 additions and 19 deletions

View file

@ -105,13 +105,24 @@ export function isMineInboxTab(tab: InboxTab): boolean {
export function resolveInboxSelectionIndex(
previousIndex: number,
itemCount: number,
canSelectItems: boolean,
): number {
if (itemCount === 0) return -1;
if (previousIndex < 0) return canSelectItems ? 0 : -1;
if (previousIndex < 0) return -1;
return Math.min(previousIndex, itemCount - 1);
}
export function getInboxKeyboardSelectionIndex(
previousIndex: number,
itemCount: number,
direction: "next" | "previous",
): number {
if (itemCount === 0) return -1;
if (previousIndex < 0) return 0;
return direction === "next"
? Math.min(previousIndex + 1, itemCount - 1)
: Math.max(previousIndex - 1, 0);
}
export function getLatestFailedRunsByAgent(runs: HeartbeatRun[]): HeartbeatRun[] {
const sorted = [...runs].sort(
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),