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 7 commits into
base: main
Choose a base branch
from

Conversation

hassoncs
Copy link
Contributor

@hassoncs hassoncs commented Jul 11, 2025

Add a new Max cost field similar to the 'max request count' field we already have.

image

Copy link

changeset-bot bot commented Jul 11, 2025

⚠️ No Changeset found

Latest commit: dd700ff

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
@hassoncs hassoncs force-pushed the add-max-cost-limit branch 5 times, most recently from ef2d4cc to 230a9e0 Compare July 22, 2025 18:27
@hassoncs hassoncs changed the base branch from main to storybook-theme-colors-again July 22, 2025 18:27
@hassoncs hassoncs force-pushed the add-max-cost-limit branch from 7e6ba04 to 22ebf4e Compare July 22, 2025 19:09
@hassoncs hassoncs changed the base branch from storybook-theme-colors-again to main July 22, 2025 19:12
@hassoncs hassoncs force-pushed the add-max-cost-limit branch 2 times, most recently from 9a86012 to f954f97 Compare July 24, 2025 20:14
@hassoncs hassoncs changed the base branch from main to storybook-theme-colors July 24, 2025 20:14
@hassoncs hassoncs force-pushed the storybook-theme-colors branch 2 times, most recently from ee1af7a to 4d44377 Compare July 24, 2025 20:37
@hassoncs hassoncs force-pushed the add-max-cost-limit branch from f954f97 to 0cb992b Compare July 24, 2025 20:37
@hassoncs hassoncs force-pushed the storybook-theme-colors branch from 4d44377 to 978cccf Compare July 25, 2025 20:28
Base automatically changed from storybook-theme-colors to main July 25, 2025 22:00
Chris Hasson added 6 commits July 30, 2025 13:49
Introduces a new `DecoratedVSCodeTextField` component that wraps the standard VSCode text field and allows for the addition of left and right nodes (e.g., icons, currency symbols). This enhances the flexibility and visual presentation of text input fields within the UI.

The component includes:
- Support for `leftNodes` and `rightNodes` to display content inside the text field.
- Automatic padding adjustment based on the presence of nodes.
- Storybook stories demonstrating various use cases (price input, search input).
- Unit tests to ensure proper rendering and functionality of the component with and without nodes.
This commit introduces a new auto-approval setting that allows users to define a maximum API cost. The system will automatically approve requests up to this cost limit before prompting the user for approval to continue the task.

Key changes include:
- Added `allowedMaxCost` to `globalSettingsSchema` in `@packages/types`.
- Implemented cost tracking and limit enforcement in `Task.ts`.
- Integrated `allowedMaxCost` into `ClineProvider` and `webviewMessageHandler` for state management.
- Created new UI components `CostInput`, `FormattedTextField`, and `MaxLimitInputs` in `webview-ui` to handle cost input and formatting.
- Updated `AutoApproveMenu` and `AutoApproveSettings` to include the new cost limit input.
- Added new Storybook stories for `AutoApproveMenu` and `AutoApproveSettings`.
- Included new test files for `FormattedTextField` and `MaxCostInput`.
- Updated i18n localization files across all supported languages to include new strings for the API cost limit setting.
Refactors `DecoratedVSCodeTextField` to extend `ComponentProps<typeof VSCodeTextField>`,
removing redundant prop definitions and simplifying its interface. This change
improves maintainability and ensures consistency with the underlying VSCode
text field component. Also adjusts `FormattedTextField` to correctly forward
refs with the updated prop types.
Removed redundant description props from MaxCostInput and MaxRequestsInput components. The common description for both API limits is now handled in MaxLimitInputs, improving consistency and reducing duplication across i18n files.
This commit enhances the auto-approval warning system to distinguish between reaching the request limit and the cost limit.

- **`src/core/task/Task.ts`**: Modified to pass a `type` parameter (`"requests"` or `"cost"`) to the `ask` method when the auto-approval limit is reached.
- **`webview-ui/src/components/chat/AutoApprovedRequestLimitWarning.tsx`**: Updated to use the new `type` parameter to dynamically select appropriate i18n keys for title, description, and button text, providing clearer messages to the user.
- **`webview-ui/src/components/settings/MaxCostInput.tsx`**: Refactored to use a new `FormattedTextField` component, simplifying input handling and validation for the max cost setting. This change removes redundant state management and event handlers.
- **`webview-ui/src/components/settings/__tests__/MaxCostInput.spec.tsx`**: Updated tests to reflect the changes in `MaxCostInput`, specifically removing tests related to blur/enter events and focusing on direct value changes.
- **`webview-ui/src/i18n/locales/*/chat.json`**: Added new translation keys (`autoApprovedCostLimitReached.title`, `description`, `button`) across all supported languages to support the cost limit warning.

This change improves user clarity and experience by providing specific feedback when either the request count or the monetary cost limit for auto-approved actions is reached.
@hassoncs hassoncs force-pushed the add-max-cost-limit branch 2 times, most recently from 06ea770 to aa58ea4 Compare July 30, 2025 13:35
Introduces the `allowedMaxCost` setting to control the maximum cost allowed for auto-approved requests.

This change includes:
- Adding `allowedMaxCost` to `GlobalSettingsSchema`, `ExtensionState`, and `WebviewMessage` types.
- Updating `Task.ts` to track `consecutiveAutoApprovedCost`.
- Modifying `ClineProvider.ts` to handle `allowedMaxCost` in state management.
- Updating `webviewMessageHandler.ts` to process `allowedMaxCost` messages.
- Creating new UI components `MaxCostInput.tsx` and `MaxLimitInputs.tsx` for the setting.
- Enhancing `FormattedTextField.tsx` with `unlimitedDecimalFormatter` for cost input.
- Updating `AutoApproveMenu.tsx` and `SettingsView.tsx` to integrate the new cost limit input.
- Adjusting `AutoApprovedRequestLimitWarning.tsx` to differentiate between request and cost limits.
- Adding `kilocode_change` markers where necessary for upstream compatibility.
@hassoncs hassoncs force-pushed the add-max-cost-limit branch from aa58ea4 to dd700ff Compare July 30, 2025 13:42
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