feat: Implement a history-based active recall quiz feature. - #34
feat: Implement a history-based active recall quiz feature.#34ajilisiwei wants to merge 1 commit into
Conversation
🧪 AI Test SuggestionsTest Suggestions for Changed Code1.
|
Code Review: PR #34Critical IssuesFILE:src/repl.js:1 | CRITICAL | Syntax error - Markdown code fence inside JavaScript file FILE:src/repl.js:498-500 | CRITICAL | Incomplete function - FILE:src/utils/quiz.js:1-206 | CRITICAL | React component rendered outside of Ink App context FILE:src/utils/quiz.js:1-206 | CRITICAL | Missing required dependencies Major IssuesFILE:src/repl.js:142 | MAJOR | Comment removal loses important context FILE:src/repl.js:463 | MAJOR | Comment removal loses important implementation detail FILE:src/repl.js:493-506 | MAJOR | TextInput props changed - removed focus and placeholder logic FILE:src/utils/quiz.js:1 | MAJOR | Missing JSDoc for exported function parameters FILE:src/utils/quiz.js:206 | MAJOR | Minor IssuesFILE:src/repl.js:282 | MINOR | Inconsistent error handling pattern FILE:src/utils/quiz.js:60 | MINOR | Empty catch blocks hide errors FILE:src/utils/quiz.js:100 | MINOR | Fisher-Yates shuffle could be optimized FILE:src/utils/quiz.js:130 | MINOR | Hardcoded language in quiz prompt FILE:src/utils/quiz.js:200 | MINOR | Console.log instead of appendMessage Suggestions
|
🧪 AI Test SuggestionsTest Suggestions for Changed Code1.
|
|
I'll review the PR #34 changes for the t-cli project. Critical IssuesFILE: src/repl.js:1 | CRITICAL | Syntax error - stray backtick and code fence markerThe diff shows a stray ```javascript at line 1 which would cause a syntax error. This appears to be a diff artifact, but if present in the actual file, it will break the module. SUGGESTION: Remove the stray ```javascript line from the actual file. FILE: src/repl.js:496 | CRITICAL | Truncated code - incomplete JSX expressionThe diff ends abruptly with SUGGESTION: Ensure the complete FILE: src/utils/quiz.js:1-192 | CRITICAL | No export for
|
🧪 AI Test SuggestionsTest Suggestions for Changed Code1.
|
|
Here is my code review for PR #34. Critical IssuesFILE: FILE: FILE: FILE: FILE: FILE: FILE: Major IssuesFILE: FILE: FILE: FILE: FILE: Minor IssuesFILE: FILE: FILE: FILE: FILE: FILE: Code Style / ConsistencyFILE: FILE: FILE: SummaryThis PR introduces a promising feature (active recall quiz) but has several critical issues that prevent it from working:
Recommendation: Do not merge until all critical and major issues are resolved. The most important fix is to integrate the quiz properly into the Ink TUI rather than using raw terminal I/O. |
🧪 AI Test SuggestionsTest Suggestions for Changed Code1.
|
|
Here is my code review for PR #34: Critical IssuesFILE:src/repl.js:1 | CRITICAL | Syntax error - Markdown code fence inside JavaScript file FILE:src/repl.js:505 | CRITICAL | Truncated file - missing closing JSX and function definitions Major IssuesFILE:src/utils/quiz.js:1 | MAJOR | Missing imports for readHistory and readGeneratedNote FILE:src/utils/quiz.js:60-70 | MAJOR | readline.createInterface conflicts with Ink's TUI FILE:src/utils/quiz.js:96 | MAJOR | Unpredictable shuffle using Math.random() FILE:src/repl.js:322-323 | MAJOR | parseInt without radix validation Minor IssuesFILE:src/utils/quiz.js:38-39 | MINOR | Inefficient date filtering FILE:src/utils/quiz.js:93 | MINOR | Magic number 0.5 in shuffle FILE:src/repl.js:349 | MINOR | Inconsistent error message format FILE:src/repl.js:443 | MINOR | Redundant condition check Code Style IssuesFILE:src/repl.js:322-335 | MINOR | Complex argument parsing could be extracted FILE:src/utils/quiz.js:1-129 | MINOR | Missing JSDoc for callback parameters SummaryThis PR introduces a useful quiz feature but has critical issues that would prevent the application from running:
The feature should be restructured to work within Ink's component model rather than using raw stdin/stdout. |
|
Here is my code review for PR #34: Critical IssuesFILE:src/repl.js:1 | CRITICAL | Syntax error - stray backtick breaks moduleThe diff shows a stray backtick and FILE:src/repl.js:496 | CRITICAL | Truncated file - missing closing brackets and exportsThe diff ends abruptly mid-expression at line 496, cutting off the FILE:src/utils/quiz.js:1-161 | CRITICAL | Missing required parameters in function signatureThe export async function runQuiz(daysBack = 7, count = 5, options = {}) {Then use FILE:src/utils/quiz.js:93-161 | CRITICAL | Uses console.log instead of provided appendMessageThe quiz module uses FILE:src/utils/quiz.js:131-137 | CRITICAL | Blocking stdin read blocks the entire REPLUsing Major IssuesFILE:src/utils/quiz.js:93 | MAJOR | Missing JSDoc for options parameterThe function signature doesn't document the FILE:src/utils/quiz.js:131-137 | MAJOR | No timeout or cancellation mechanism for user inputThe stdin read has no timeout, so if the user doesn't provide input, the quiz hangs indefinitely. FILE:src/utils/quiz.js:143-155 | MAJOR | Hardcoded language and mode for scoring promptThe scoring prompt uses hardcoded const checkPrompt = getCheckPrompt(options.currentLang || 'en', options.isSimpleMode || false);Minor IssuesFILE:src/repl.js:284-285 | MINOR | Magic numbers for default valuesThe default values FILE:src/utils/quiz.js:96-97 | MINOR | Redundant validationThe function validates FILE:src/utils/quiz.js:108-112 | MINOR | Redundant empty checksThe FILE:src/utils/quiz.js:1 | MINOR | Missing newline at end of fileThe file ends without a trailing newline. SummaryThis PR has critical issues that prevent it from working at all:
The PR should be rejected until these issues are resolved. The quiz feature needs to be redesigned to work within the REPL's event-driven input model rather than using blocking stdin reads. |
🧪 AI Test SuggestionsTest Suggestions for Changed Code1.
|
🧪 AI Test SuggestionsTest Suggestions for Changed Code1.
|
|
I'll analyze the PR diff for issues: Critical IssuesFILE:src/repl.js:1 | CRITICAL | Malformed diff - added backtick fence inside JavaScript file | The diff shows a stray ```javascript backtick fence being added at line 1 of FILE:src/repl.js:502 | CRITICAL | Entire FILE:src/utils/quiz.js:1-194 | CRITICAL | Missing required options in Major IssuesFILE:src/utils/quiz.js:30-40 | MAJOR | FILE:src/utils/quiz.js:60-62 | MAJOR | FILE:src/utils/quiz.js:87-97 | MAJOR | Silent error swallowing in FILE:src/utils/quiz.js:150-152 | MAJOR | No input validation for user answer | The user's answer is accepted as-is without any sanitization or length limits. A malicious user could paste extremely long content, potentially causing memory issues or injection risks when passed to the AI. Minor IssuesFILE:src/utils/quiz.js:1 | MINOR | Missing FILE:src/utils/quiz.js:155-158 | MINOR | Inconsistent error handling for empty answers | When user provides empty answer, the code FILE:src/utils/quiz.js:170-175 | MINOR | Hardcoded language parameter | FILE:src/repl.js:284-285 | MINOR | Magic numbers for default quiz parameters | Default values FILE:src/utils/quiz.js:190-192 | MINOR | Summary output could be more informative | The summary only shows counts. Consider showing which questions were answered correctly vs incorrectly, or providing a score. Code Style IssuesFILE:src/utils/quiz.js:60-62 | MINOR | Inefficient shuffle implementation | FILE:src/utils/quiz.js:87-97 | MINOR | Redundant try-catch blocks | Two separate try-catch blocks for history and notes could be combined into a helper function to reduce code duplication. FILE:src/utils/quiz.js:1-194 | MINOR | Missing JSDoc for some parameters | The SummaryThe most critical issues are:
These need to be fixed before this PR can be merged. |
🧪 AI Test SuggestionsTest Suggestions for Changed Code1.
|
|
Here is my code review for PR #34. Critical IssuesFILE: The
SUGGESTION: Either update the function signature to accept and use all parameters, or refactor the caller to match the current signature. Given the UI dependency, the function should accept FILE: The
SUGGESTION: Do not manipulate stdin directly. Instead, use Ink's built-in components (e.g., FILE: The file imports SUGGESTION: Remove unused imports. If the quiz is intended to use Ink components, refactor the output to use them (e.g., Major IssuesFILE:
SUGGESTION: Wrap the call in a try-catch or validate the return value before splitting. FILE: The code assumes these functions return arrays of date strings. If they return SUGGESTION: Add defensive checks: const historyDates = Array.isArray(listHistory()) ? listHistory() : [];
const noteDates = Array.isArray(listGeneratedNotes()) ? listGeneratedNotes() : [];FILE: If the user cancels (returns SUGGESTION: Add a strict null check after if (userAnswer === null || userAnswer === undefined) {
console.log('Quiz cancelled.');
return;
}FILE: The call SUGGESTION: Accept these as parameters and pass them through. Minor IssuesFILE: The validation SUGGESTION: Update the error message for clarity. FILE: The shuffle implementation is correct but unnecessarily verbose. The standard Fisher-Yates can be written more concisely. SUGGESTION: Consider using a simpler approach or extracting to a utility function. FILE: The variable SUGGESTION: Remove the variable or use it (e.g., for logging or returning the score). FILE: The code checks SUGGESTION: Use a regex or trim the input before checking: if (/^\/quiz(\s|$)/.test(lowerInput)) {SummaryThe PR introduces a useful feature but has critical architectural issues: the quiz module bypasses Ink's rendering and input system, which will break the application's UI. The function signature mismatch means the quiz ignores key parameters and callbacks. These issues must be resolved before merging. |
🧪 AI Test SuggestionsTest Suggestions for Changed Code1.
|
|
Here is my code review for PR #34: Critical Issues1. FILE: src/repl.js:291 | CRITICAL | Logic error:
|
AI-Generated Implementation
Implements Implement a history-based active recall quiz feature.
Issue
Closes #32
Approach
Create src/utils/quiz.js with pure logic: export
getQuizEntries(daysBack)that reads history files viareadHistory()andlistHistory(), filters entries with translation content (not checks), picks random entries; exportbuildQuizPrompt(entries)that constructs a system prompt asking DeepSeek to present each entry as a fill-in-the-blank quiz and score user answers; exportparseQuizResponse(raw)to extract score/corrections. In src/repl.js, add a/quiz [days]command handler that: (1) callsgetQuizEntries()to select entries, (2) sets React state{ quizMode: true, quizEntries, quizIndex, quizScore }, (3) on each user submission routes to a state machine that callscallDeepSeekStream()withbuildQuizPrompt()for the current entry, streams the quiz question viastreamAndRender(), then awaits user answer and sends it back to DeepSeek for scoring, (4) displays final score when done. Reuse existingappendMessage,streamAndRender,callDeepSeekStream,readHistory,listHistory.Verification
Files Changed
🤖 Generated by @coder — please review before merging