diff --git a/clients/tabby-agent/src/http/tabbyApiClient.ts b/clients/tabby-agent/src/http/tabbyApiClient.ts index df064ffbcc34..72797eaa530c 100644 --- a/clients/tabby-agent/src/http/tabbyApiClient.ts +++ b/clients/tabby-agent/src/http/tabbyApiClient.ts @@ -49,7 +49,7 @@ export class TabbyApiClient extends EventEmitter { private readonly completionRequestStats = new RequestStats(); private completionResponseIssue: "highTimeoutRate" | "slowResponseTime" | undefined = undefined; - private rateLimited: boolean = false; + private rateLimitExceeded: boolean = false; private connectionErrorMessage: string | undefined = undefined; private serverHealth: TabbyApiComponents["schemas"]["HealthState"] | undefined = undefined; @@ -178,11 +178,11 @@ export class TabbyApiClient extends EventEmitter { } } - private updateIsRateLimited(isRateLimited: boolean) { - if (this.rateLimited != isRateLimited) { - this.logger.debug(`updateIsRateLimited: ${isRateLimited}`); - this.rateLimited = isRateLimited; - this.emit("isRateLimitedUpdated", isRateLimited); + private updateIsRateLimitExceeded(isRateLimitExceeded: boolean) { + if (this.rateLimitExceeded != isRateLimitExceeded) { + this.logger.debug(`updateIsRateLimitExceeded: ${isRateLimitExceeded}`); + this.rateLimitExceeded = isRateLimitExceeded; + this.emit("isRateLimitExceededUpdated", isRateLimitExceeded); } } @@ -224,8 +224,8 @@ export class TabbyApiClient extends EventEmitter { return !!this.completionResponseIssue; } - isRateLimited(): boolean { - return this.rateLimited; + isRateLimitExceeded(): boolean { + return this.rateLimitExceeded; } getServerHealth(): TabbyApiComponents["schemas"]["HealthState"] | undefined { @@ -384,7 +384,7 @@ export class TabbyApiClient extends EventEmitter { } this.logger.trace(`Completion response data: [${requestId}]`, response.data); statsData.latency = performance.now() - requestStartedAt; - this.updateIsRateLimited(false); + this.updateIsRateLimitExceeded(false); return response.data; } catch (error) { this.updateIsFetchingCompletion(false); @@ -397,16 +397,16 @@ export class TabbyApiClient extends EventEmitter { } else if (isUnauthorizedError(error)) { this.logger.debug(`Completion request failed due to unauthorized. [${requestId}]`); statsData.notAvailable = true; - this.updateIsRateLimited(false); + this.updateIsRateLimitExceeded(false); this.connect(); // schedule a reconnection } else if (isRateLimitedError(error)) { this.logger.debug(`Completion request failed due to rate limiting. [${requestId}]`); statsData.notAvailable = true; - this.updateIsRateLimited(true); + this.updateIsRateLimitExceeded(true); } else { this.logger.error(`Completion request failed. [${requestId}]`, error); statsData.notAvailable = true; - this.updateIsRateLimited(false); + this.updateIsRateLimitExceeded(false); this.connect(); // schedule a reconnection } throw error; // rethrow error diff --git a/clients/tabby-agent/src/status.ts b/clients/tabby-agent/src/status.ts index 27d824f8c959..1be6493bfc0e 100644 --- a/clients/tabby-agent/src/status.ts +++ b/clients/tabby-agent/src/status.ts @@ -70,7 +70,7 @@ export class StatusProvider extends EventEmitter implements Feature { this.tabbyApiClient.on("hasCompletionResponseTimeIssueUpdated", async () => { this.notify(); }); - this.tabbyApiClient.on("isRateLimitedUpdated", async () => { + this.tabbyApiClient.on("isRateLimitExceededUpdated", async () => { this.notify(); }); @@ -206,12 +206,9 @@ export class StatusProvider extends EventEmitter implements Feature { case "ready": { const ignored = this.dataStore.data.statusIgnoredIssues ?? []; - if (this.tabbyApiClient.isRateLimited()) { - statusInfo = { status: "rateLimited" }; - } else if ( - this.tabbyApiClient.hasCompletionResponseTimeIssue() && - !ignored.includes("completionResponseSlow") - ) { + if (this.tabbyApiClient.isRateLimitExceeded()) { + statusInfo = { status: "rateLimitExceeded" }; + } else if (this.tabbyApiClient.hasCompletionResponseTimeIssue() && !ignored.includes("completionResponseSlow")) { statusInfo = { status: "completionResponseSlow" }; } else if (this.tabbyApiClient.isFetchingCompletion()) { statusInfo = { status: "fetching" }; @@ -272,7 +269,7 @@ export class StatusProvider extends EventEmitter implements Feature { case "completionResponseSlow": statusInfo.tooltip = "Tabby: Slow Completion Response Detected"; break; - case "rateLimited": + case "rateLimitExceeded": statusInfo.tooltip = "Tabby: Too Many Requests"; break; default: diff --git a/clients/vscode/src/StatusBarItem.ts b/clients/vscode/src/StatusBarItem.ts index 751df388e942..8a0fc7c98bd0 100644 --- a/clients/vscode/src/StatusBarItem.ts +++ b/clients/vscode/src/StatusBarItem.ts @@ -94,7 +94,7 @@ export class StatusBarItem { break; } case "completionResponseSlow": - case "rateLimited": { + case "rateLimitExceeded": { this.setColorWarning(); this.setIcon(iconWarning); this.setTooltip(statusInfo.tooltip); diff --git a/clients/vscode/src/commands/commandPalette.ts b/clients/vscode/src/commands/commandPalette.ts index 934e99973bba..83f2e7692869 100644 --- a/clients/vscode/src/commands/commandPalette.ts +++ b/clients/vscode/src/commands/commandPalette.ts @@ -209,7 +209,7 @@ export class CommandPalette { }, }; } - case "rateLimited": { + case 'rateLimitExceeded': { return { label: `${STATUS_PREFIX}Too Many Requests`, description: "Request limit exceeded",