Skip to content
Closed
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: 1 addition & 1 deletion examples/calculator/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function safeEval(expr: string): string {
if (tokens.length === 0) return '0';

// Handle initial negative number
if (tokens[0] === '-' && tokens.length > 1 && !isNaN(Number(tokens[1]))) {
if (tokens[0] === '-' && tokens.length > 1 && !Number.isNaN(Number(tokens[1]))) {
tokens.splice(0, 2, '-' + tokens[1]);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/forms-and-validation/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class FormsExampleApp extends Widget {
return false; // Quit
}

if (event.key === 'c' && event.ctrl === false) {
if (event.key === 'c' && event.ctrl !) {
this.modal.show();
return true;
Comment on lines +125 to 127

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Mark the widget dirty after showing the modal.

This branch changes widget state and returns without calling this.markDirty(). Add the call after this.modal.show().

As per coding guidelines: Every state-mutating method on a widget calls this.markDirty().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/forms-and-validation/src/index.tsx` around lines 125 - 127, Update
the Ctrl+C branch in the widget’s key-event handler to call this.markDirty()
immediately after this.modal.show() and before returning, ensuring this
state-mutating path follows the widget dirty-state guideline.

Source: Coding guidelines


🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Handle Ctrl+C before the quit branch.

Line 121 returns false for Ctrl+C, so execution never reaches this modal branch. Plain c then falls through and is inserted into the active field.

Move the clear-form check before the quit check, and reserve the quit check for q.

Proposed fix
-        if (event.key === 'q' || (event.ctrl && event.key === 'c')) {
-            return false;
-        }
-
-        if (event.key === 'c' && event.ctrl !) {
+        if (event.key === 'c' && event.ctrl) {
             this.modal.show();
             return true;
         }
+
+        if (event.key === 'q') {
+            return false;
+        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/forms-and-validation/src/index.tsx` around lines 125 - 127, Reorder
the key handling in the event handler so the clear-form Ctrl+C condition
executes before the quit branch, and update the quit condition to respond only
to q. Preserve the modal display and handled-event return behavior for Ctrl+C,
while ensuring plain c is not treated as clear-form input.

}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function promptText(options: TextPromptOptions): Promise<string> {
async function promptConfirm(options: ConfirmPromptOptions): Promise<boolean> {
if (!process.stdin.isTTY) throw new NonInteractiveError();

const hint = options.default === true ? 'Y/n' : options.default === false ? 'y/N' : 'y/n';
const hint = options.default ? 'Y/n' : options.default === false ? 'y/N' : 'y/n';

return new Promise((resolve) => {
const rl = readline.createInterface({
Expand Down
Loading