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
2 changes: 2 additions & 0 deletions backend/src/routes/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface DueCardPreview {
id: string;
question: string;
next_review: string;
card_file: string;
}

/**
Expand Down Expand Up @@ -113,6 +114,7 @@ cardRoutes.get("/due", async (c) => {
id: card.metadata.id,
question: card.content.question,
next_review: card.metadata.next_review,
card_file: `${vault.metadataPath}/cards/${card.metadata.id}.md`,
}));

const response: DueCardsResponse = {
Expand Down
28 changes: 25 additions & 3 deletions frontend/src/components/home/SpacedRepetitionWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,25 @@ export function SpacedRepetitionWidget({
);

/**
* Handle Open action: navigate to source file in Recall tab.
* Handle Open Source action: navigate to source file in Recall tab.
* Used in revealed phase to view the original note.
*/
const handleOpenCard = useCallback(() => {
const handleOpenSource = useCallback(() => {
if (!state.cardDetail?.source_file) return;
setCurrentPath(state.cardDetail.source_file);
setMode("browse");
}, [state.cardDetail?.source_file, setCurrentPath, setMode]);

/**
* Handle Open Card action: navigate to card file in Recall tab.
* Used in question phase to edit the card (e.g., fix the question).
*/
const handleOpenCard = useCallback(() => {
if (!state.currentCard?.card_file) return;
setCurrentPath(state.currentCard.card_file);
setMode("browse");
}, [state.currentCard?.card_file, setCurrentPath, setMode]);

/**
* Handle keyboard shortcuts for assessment (1/2/3/4 keys).
* Must be defined after handleAssessment to avoid reference error.
Expand Down Expand Up @@ -417,6 +428,17 @@ export function SpacedRepetitionWidget({
>
Forget
</button>
{state.currentCard?.card_file && (
<button
type="button"
className="spaced-repetition-widget__btn spaced-repetition-widget__btn--open"
onClick={handleOpenCard}
disabled={isLoading}
aria-label="Open card file in Recall tab"
>
Open
</button>
)}
<button
type="button"
className="spaced-repetition-widget__btn spaced-repetition-widget__btn--reveal"
Expand Down Expand Up @@ -469,7 +491,7 @@ export function SpacedRepetitionWidget({
<button
type="button"
className="spaced-repetition-widget__btn spaced-repetition-widget__btn--open"
onClick={handleOpenCard}
onClick={handleOpenSource}
aria-label="Open source file in Recall tab"
>
Open
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ function renderWithSession(ui: React.ReactElement) {

const mockDueCardsResponse: DueCardsResponse = {
cards: [
{ id: "card-1", question: "What is TypeScript?", next_review: "2026-01-23" },
{ id: "card-2", question: "What is React?", next_review: "2026-01-23" },
{ id: "card-3", question: "What is Bun?", next_review: "2026-01-23" },
{ id: "card-1", question: "What is TypeScript?", next_review: "2026-01-23", card_file: "06_Metadata/memory-loop/cards/card-1.md" },
{ id: "card-2", question: "What is React?", next_review: "2026-01-23", card_file: "06_Metadata/memory-loop/cards/card-2.md" },
{ id: "card-3", question: "What is Bun?", next_review: "2026-01-23", card_file: "06_Metadata/memory-loop/cards/card-3.md" },
],
count: 3,
};
Expand Down Expand Up @@ -523,7 +523,7 @@ describe("SpacedRepetitionWidget", () => {
it("shows completion message when all cards reviewed", async () => {
// Start with a single card
const singleCardResponse: DueCardsResponse = {
cards: [{ id: "card-1", question: "What is TypeScript?", next_review: "2026-01-23" }],
cards: [{ id: "card-1", question: "What is TypeScript?", next_review: "2026-01-23", card_file: "06_Metadata/memory-loop/cards/card-1.md" }],
count: 1,
};

Expand All @@ -550,7 +550,7 @@ describe("SpacedRepetitionWidget", () => {

it("shows checkmark icon in completion state", async () => {
const singleCardResponse: DueCardsResponse = {
cards: [{ id: "card-1", question: "What is TypeScript?", next_review: "2026-01-23" }],
cards: [{ id: "card-1", question: "What is TypeScript?", next_review: "2026-01-23", card_file: "06_Metadata/memory-loop/cards/card-1.md" }],
count: 1,
};

Expand Down
1 change: 1 addition & 0 deletions frontend/src/hooks/__tests__/useCards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const mockDueCard: DueCard = {
id: "550e8400-e29b-41d4-a716-446655440001",
question: "What is the capital of France?",
next_review: "2026-01-23",
card_file: "06_Metadata/memory-loop/cards/550e8400-e29b-41d4-a716-446655440001.md",
};

const mockCardDetail: CardDetail = {
Expand Down
2 changes: 2 additions & 0 deletions shared/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ export const DueCardSchema = z.object({
question: z.string().min(1, "Question is required"),
/** ISO 8601 date when card is due for review */
next_review: z.string(),
/** Path to the card file (relative to vault, e.g., 06_Metadata/memory-loop/cards/{id}.md) */
card_file: z.string(),
});

/**
Expand Down