Skip to content

Conversation

@ryanjoachim
Copy link

@ryanjoachim ryanjoachim commented Jan 16, 2025

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Adds maxApiRetries setting to disable API retries in Cline, with UI and state management updates.

  • Behavior:
    • Introduces maxApiRetries setting in Cline to allow disabling API retries by setting it to 0.
    • Updates retry logic in Cline to respect maxApiRetries setting.
  • State Management:
    • Adds maxApiRetries to ExtensionState in ExtensionStateContext.tsx.
    • Updates ClineProvider to handle maxApiRetries in state and webview messages.
  • UI:
    • Adds maxApiRetries slider to SettingsView.tsx for user configuration.
    • Updates SettingsView.test.tsx to test new maxApiRetries functionality.
  • Tests:
    • Adds tests for maxApiRetries behavior in Cline.test.ts and ClineProvider.test.ts.

This description was created by Ellipsis for e7599ea. It will automatically update as commits are pushed.

Modified the maxApiRetries slider in settings to accept 0 as minimum value, allowing users to completely disable automatic API retry attempts. Updated the aria-label to clarify that 0 means no limit will be applied.
@changeset-bot
Copy link

changeset-bot bot commented Jan 16, 2025

⚠️ No Changeset found

Latest commit: fcb4c18

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

@ryanjoachim
Copy link
Author

#355 (comment)
(original context for the PR)

Let's just say things happened and I broke the other PR.
On the bright side, this is fleshed out more now and is in working order as far as I can see.

@ryanjoachim ryanjoachim marked this pull request as ready for review January 17, 2025 05:35
Comment on lines 852 to 871
// note that this api_req_failed ask is unique in that we only present this option if the api hasn't streamed any content yet (ie it fails on the first chunk due), as it would allow them to hit a retry button. However if the api failed mid-stream, it could be in any arbitrary state where some tools may have executed, so that error is handled differently and requires cancelling the task entirely.
if (alwaysApproveResubmit) {
const { maxApiRetries } = await this.providerRef.deref()?.getState() ?? {}
const currentRetryCount = (this.apiRetryCount || 0) + 1
this.apiRetryCount = currentRetryCount

if (maxApiRetries !== undefined && maxApiRetries !== 0 && currentRetryCount > maxApiRetries) {
const errorMsg = `Maximum retry attempts (${maxApiRetries}) reached. ${error.message ?? "Unknown error"}`
await this.say("error", errorMsg)
throw error
}

const errorMsg = error.message ?? "Unknown error"
const requestDelay = requestDelaySeconds || 5
// Automatically retry with delay
// Show countdown timer in error color
for (let i = requestDelay; i > 0; i--) {
await this.say("api_req_retry_delayed", `${errorMsg}\n\nRetrying in ${i} seconds...`, undefined, true)
await this.say("api_req_retry_delayed", `${errorMsg}\n\nRetrying in ${i} seconds...${maxApiRetries !== undefined && maxApiRetries > 0 ? ` (Attempt ${currentRetryCount} of ${maxApiRetries})` : ''}`, undefined, true)
await delay(1000)
}
Copy link
Author

Choose a reason for hiding this comment

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

This is the part I'd be the most careful about when reviewing. If it's wrong/it should be done a different way, I'd love to know!

@mrubens
Copy link
Collaborator

mrubens commented Jan 17, 2025

Heads up that I ran prettier on the whole codebase in #404, and it will run automatically in a pre-commit hook going forward.

In order to bring this PR up to date on formatting you'll need to run npx prettier './**/*.{js,jsx,ts,tsx,json,css,md}' --write. Sorry for any hassle with this, and let me know if you get stuck!

@ryanjoachim ryanjoachim deleted the max-api-retry branch January 22, 2025 21:46
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