Skip to content

feat(ui):Add max cost auto-approval setting similar to max requests #1271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hassoncs
Copy link
Contributor

No description provided.

Chris Hasson added 6 commits July 11, 2025 10:49
The `MaxRequestsInput` component was extracted from `AutoApproveMenu.tsx` into its own file (`MaxRequestsInput.tsx`) to improve reusability and maintainability. This component is now used in both `AutoApproveMenu.tsx` and `AutoApproveSettings.tsx` to manage the auto-approve API request limit.

Previously this option was only available in the Chat Approval popup menu
…tsx` into its own file (`MaxRequestsInput.tsx`) to improve reusability and maintainability. This component is now used in both `AutoApproveMenu.tsx` and `AutoApproveSettings.tsx` to manage the auto-approve API request limit.

Previously this option was only available in the Chat Approval popup menu
- Add FormattedInput<T> component with InputFormatter interface
- Include pre-built formatters: integer, currency, unlimited integer, positive integer
- Add specialized CostInput and NumericInput components
- Refactor MaxRequestsInput to use new FormattedInput system
- Add comprehensive test suite with 16 tests covering all formatters
- Reduce MaxRequestsInput from 51 to 33 lines by removing custom parsing logic
Introduces a new setting, `allowedMaxCost`, allowing users to define a maximum API cost before requiring approval to continue a task. This enhances cost control for AI interactions.

- **packages/types**: Added `allowedMaxCost` to `globalSettingsSchema`.
- **src/core/task/Task.ts**: Implemented logic to track and enforce the `allowedMaxCost` within tasks.
- **src/core/webview**: Integrated `allowedMaxCost` into `ClineProvider` and `webviewMessageHandler` for state management and communication.
- **src/shared**: Updated `ExtensionMessage` and `WebviewMessage` types to include `allowedMaxCost`.
- **webview-ui**:
    - Added `MaxCostInput` component for UI input.
    - Integrated `MaxCostInput` into `AutoApproveMenu` and `AutoApproveSettings`.
    - Updated `ExtensionStateContext` to manage the new setting.
    - Added internationalization (i18n) strings for `apiCostLimit` across all supported languages.
Removed `positiveIntegerFormatter` as `integerFormatter` can serve the same purpose with appropriate usage.
Cleaned up comments in `FormattedInput.tsx` and `MaxCostInput.tsx` for better readability.
Copy link

changeset-bot bot commented Jul 11, 2025

⚠️ No Changeset found

Latest commit: 2e4784a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@hassoncs hassoncs force-pushed the add-max-costs-to-approval-settings branch from 5188ed1 to f59c0d7 Compare July 11, 2025 23:34
Base automatically changed from add-max-costs-to-approval-settings to main July 12, 2025 00:20
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.

1 participant