Skip to content
Open
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
4 changes: 3 additions & 1 deletion recipes/borrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ async function promptFromSchema(
type: "input",
name: "value",
message,
initial: (prop.placeholder || prop.default) as string,
...(isRequired && (prop.placeholder || prop.default)
? { initial: (prop.placeholder || prop.default) as string }
: {}),
Comment on lines +454 to +456
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Required defaults like 0 are skipped by the truthy check.

At Line 454, (prop.placeholder || prop.default) filters out valid required defaults such as 0, so initial is not set for those fields. Use explicit null/empty checks instead of truthiness.

Suggested fix
+      const initialValue = prop.placeholder || prop.default;
       const response: any = await Enquirer.prompt({
         type: "input",
         name: "value",
         message,
-        ...(isRequired && (prop.placeholder || prop.default)
-          ? { initial: (prop.placeholder || prop.default) as string }
+        ...(isRequired && initialValue !== undefined && initialValue !== null && initialValue !== ""
+          ? { initial: String(initialValue) }
           : {}),
         validate: (input: string) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
...(isRequired && (prop.placeholder || prop.default)
? { initial: (prop.placeholder || prop.default) as string }
: {}),
const initialValue = prop.placeholder || prop.default;
const response: any = await Enquirer.prompt({
type: "input",
name: "value",
message,
...(isRequired && initialValue !== undefined && initialValue !== null && initialValue !== ""
? { initial: String(initialValue) }
: {}),
validate: (input: string) => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@recipes/borrow.ts` around lines 454 - 456, The current truthy check
(prop.placeholder || prop.default) skips valid values like 0; change it to
explicitly test for null/undefined/empty-string and use the nullish coalescing
result when present. Replace the expression with something like: compute const
value = prop.placeholder ?? prop.default; then if isRequired && value !==
undefined && value !== null && value !== '' include { initial: String(value) }
so numeric defaults (0) are preserved; reference variables: prop, isRequired,
initial, placeholder, default.

validate: (input: string) => {
if (!isRequired && input === "") return true;
if (isRequired && input === "") return `${prop.label || name} is required`;
Expand Down
4 changes: 4 additions & 0 deletions recipes/perps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,10 @@ async function executeTrade(
return false;
}

if (!ACTION_LABELS[actionType]) {
return false;
}

return !POSITION_ONLY_ACTIONS.includes(actionType) || !!existingPosition;
}) as PerpActionTypes[];

Expand Down
Loading