Skip to content

add maxApproval support to enter yield action#27

Open
dnehl wants to merge 4 commits intomainfrom
eng-1901-support-maxapproval-flag-on-action-creation
Open

add maxApproval support to enter yield action#27
dnehl wants to merge 4 commits intomainfrom
eng-1901-support-maxapproval-flag-on-action-creation

Conversation

@dnehl
Copy link
Copy Markdown

@dnehl dnehl commented Mar 26, 2026

Summary by CodeRabbit

  • New Features

    • Quick-test mode to run a specific yield directly via an environment variable.
    • Confirmation prompt asking whether to use maximum (unlimited) token approval when entering a yield.
  • Chores

    • Added the new environment variable placeholder to the example configuration template.

Copilot AI review requested due to automatic review settings March 26, 2026 13:07
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

Adds a commented YIELD_ID placeholder to .env.example and a new getYield(yieldId) API method in the yields recipe. The recipe gains a quick-test mode that, when YIELD_ID is set, fetches that yield and runs an "enter" action flow; the "enter" action now prompts for max token approval if not provided.

Changes

Cohort / File(s) Summary
Environment Configuration
\.env.example
Added commented placeholder #YIELD_ID= optional quick test mode.
Yields Recipe & API
recipes/yields.ts
Added YieldsApiClient.getYield(yieldId); added quick-test mode in main() using process.env.YIELD_ID to fetch and execute a yield immediately; updated executeAction() to prompt (via Enquirer) for max token approval when performing enter if args.maxApproval is absent; minor console output formatting changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Script as main()
    participant Client as YieldsApiClient
    participant API as /v1/yields
    participant Action as executeAction()
    participant Prompt as Enquirer

    User->>Script: Run script (env var set)
    Script->>Script: Check process.env.YIELD_ID
    alt YIELD_ID set (quick-test)
        Script->>Client: getYield(yieldId)
        Client->>API: GET /v1/yields/{yieldId}
        API-->>Client: YieldOpportunity
        Client-->>Script: YieldOpportunity
        Script->>Action: executeAction("enter", yield, args)
        Action->>Prompt: Confirm max approval?
        Prompt-->>Action: User response
        Action->>Action: Set args.maxApproval
        Action-->>Script: Create/confirm action
        Script->>Script: Exit early
    else Normal flow
        Script->>User: Show selection flow
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I sniff the env for a secret ID,
Hop straight to a yield, quick-test and free—
A prompt for approval before I enter the door,
Then off I bounce, last hop and encore! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is completely empty; no content was provided by the author despite a template being available. Add a description using the provided template covering: (1) new functionality like quick-test mode and getYield API method, and (2) changes to executeAction for maxApproval prompting.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title focuses on maxApproval support for enter yield action, which is a key feature added in executeAction. However, the PR also adds a new getYield API method and implements quick-test mode via YIELD_ID environment variable, making the title partially rather than fully descriptive of all major changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch eng-1901-support-maxapproval-flag-on-action-creation

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds convenience and action-creation options to the Yields recipe CLI, enabling quick yield execution via env var and prompting for unlimited token approval when entering a yield.

Changes:

  • Add getYield(yieldId) endpoint helper to fetch a single yield opportunity.
  • Add YIELD_ID “quick-test mode” to skip browsing and immediately run an enter action.
  • Prompt for maxApproval on enter actions and pass it through in action arguments.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
recipes/yields.ts Adds single-yield fetch, quick-test flow via YIELD_ID, and maxApproval prompt for enter actions.
.env.example Documents the optional YIELD_ID env var for quick-test mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.env.example:
- Line 8: The file ends without a trailing newline which triggers dotenv-linter;
open the .env.example and add a single newline character after the last line
(the comment containing "YIELD_ID") so the file ends with a blank line — ensure
the final line is terminated to satisfy the linter.

In `@recipes/yields.ts`:
- Around line 222-224: The getYield method currently interpolates raw yieldId
into the request path, which can break the URL if yieldId contains reserved
characters; update getYield to encode the id (e.g., via encodeURIComponent)
before composing the path passed to makeRequest so the call becomes GET to
`/v1/yields/${encodedYieldId}` ensuring a valid URL.
- Around line 829-837: When handling the "enter" prompt in recipes/yields.ts,
avoid always assigning args.maxApproval from Enquirer.prompt which can override
an existing value from promptForArguments; instead, check if args.maxApproval is
undefined (or not already set) before calling Enquirer.prompt and only assign
args.maxApproval when absent. Locate the block that checks if (type === "enter")
and references Enquirer.prompt and args.maxApproval, add a guard around the
prompt/assignment so existing schema-provided values are preserved.
- Around line 547-553: The quick-test branch unconditionally forces an "enter"
via executeAction after fetching a yield (quickYieldId -> apiClient.getYield ->
executeAction) which can fail if the yield's status.enter is false; update the
branch to check the fetched yield's status.enter (e.g., inspect
yieldInfo.status.enter) and only call executeAction(..., "enter") when true,
otherwise log or throw a clear message indicating enter is not allowed for that
yield so the failure is guarded and the error is explicit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 48685e91-bd96-485e-9c5e-f94f4531c10c

📥 Commits

Reviewing files that changed from the base of the PR and between 36b0249 and 7e15e5e.

📒 Files selected for processing (2)
  • .env.example
  • recipes/yields.ts

@dnehl dnehl requested review from Philippoes and jdomingos March 26, 2026 13:20
@dnehl dnehl changed the title Eng 1901 support maxapproval flag on action creation add maxApproval support to enter yield action Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants