Skip to content

Commit e7645af

Browse files
cursoragentterryyin
andcommitted
Fix resume recalling button not showing when viewing last answered question
Bug: When recalling and viewing the previously answered question (which is the last memory tracker), the resume recalling button in the main menu doesn't show. Root cause: The condition for showing the Resume button was: (isPausedByCursor || isPausedByIndex) && toRepeatCount > 0 When viewing the last answered question after completing all recall items: - isRecallPaused (isPausedByCursor) is true - toRepeatCount = length - currentIndex = 0 The condition failed because toRepeatCount was 0. Fix: Changed the condition to: (isPausedByCursor && hasLoadedTrackers) || (isPausedByIndex && toRepeatCount > 0) This means: - If viewing a previously answered question (isPausedByCursor), show Resume button as long as there are memory trackers loaded (even if all answered) - If navigated away after answering (isPausedByIndex), show Resume button only if there are remaining items to recall Added unit test to cover the new scenario. Co-authored-by: terry <terry@odd-e.com>
1 parent 9f3a62c commit e7645af

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

frontend/src/composables/useNavigationItems.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ import { messageCenterConversations } from "@/store/messageStore"
1414
export function useNavigationItems() {
1515
const route = useRoute()
1616
const { dueCount } = useAssimilationCount()
17-
const { toRepeatCount, isRecallPaused, currentIndex, diligentMode } =
18-
useRecallData()
17+
const {
18+
toRepeatCount,
19+
toRepeat,
20+
isRecallPaused,
21+
currentIndex,
22+
diligentMode,
23+
} = useRecallData()
1924

2025
const upperNavItems = computed(() => {
2126
const baseItems = [
@@ -50,11 +55,15 @@ export function useNavigationItems() {
5055
// Recall is paused if:
5156
// 1. previousAnsweredQuestionCursor is set (viewing answered question), OR
5257
// 2. currentIndex > 0 (not at first memory tracker) AND not on recall page
53-
// Resume button should only show when there are memory trackers to recall (toRepeatCount > 0)
58+
// Resume button shows when:
59+
// - isPausedByCursor is true AND memory trackers are loaded (viewing previously answered question)
60+
// - isPausedByIndex is true AND there are memory trackers remaining to recall
61+
const hasLoadedTrackers = (toRepeat.value?.length ?? 0) > 0
5462
const isPausedByCursor = isRecallPaused.value
5563
const isPausedByIndex = currentIndex.value > 0 && route.name !== "recall"
5664
const shouldShowResume =
57-
(isPausedByCursor || isPausedByIndex) && toRepeatCount.value > 0
65+
(isPausedByCursor && hasLoadedTrackers) ||
66+
(isPausedByIndex && toRepeatCount.value > 0)
5867

5968
if (shouldShowResume) {
6069
return [

frontend/tests/toolbars/MainMenu.spec.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ describe("main menu", () => {
607607
},
608608
{
609609
description:
610-
"does not show resume recall menu item when toRepeatCount is 0 even if currentIndex > 0",
610+
"does not show resume recall menu item when toRepeatCount is 0 and not paused even if currentIndex > 0",
611611
routeName: "notebooks",
612612
isRecallPaused: false,
613613
currentIndex: 5,
@@ -617,6 +617,18 @@ describe("main menu", () => {
617617
}>,
618618
shouldShow: false,
619619
},
620+
{
621+
description:
622+
"shows resume recall menu item when viewing last answered question (isRecallPaused true) even if toRepeatCount is 0",
623+
routeName: "notebooks",
624+
isRecallPaused: true,
625+
currentIndex: 5,
626+
toRepeat: Array(5).fill({}) as Array<{
627+
memoryTrackerId?: number
628+
spelling?: boolean
629+
}>,
630+
shouldShow: true,
631+
},
620632
])("$description", async ({
621633
routeName,
622634
isRecallPaused,

0 commit comments

Comments
 (0)