diff --git a/clients/vscode/src/StatusBarItem.ts b/clients/vscode/src/StatusBarItem.ts index 8f1a1aded7ad..909aee65ac18 100644 --- a/clients/vscode/src/StatusBarItem.ts +++ b/clients/vscode/src/StatusBarItem.ts @@ -2,6 +2,8 @@ import { commands, window, ExtensionContext, StatusBarAlignment, ThemeColor } fr import { State as LanguageClientState } from "vscode-languageclient"; import { Client } from "./lsp/client"; import { Config } from "./Config"; +import { StatusInfo } from "tabby-agent"; +import { getLogger } from "./logger"; const label = "Tabby"; const iconAutomatic = "$(check)"; @@ -11,6 +13,7 @@ const iconLoading = "$(loading~spin)"; const iconDisconnected = "$(debug-disconnect)"; const iconUnauthorized = "$(key)"; const iconWarning = "$(warning)"; +const iconCodeModelNotFound = "$(close)"; const colorNormal = new ThemeColor("statusBar.foreground"); const colorWarning = new ThemeColor("statusBarItem.warningForeground"); const backgroundColorNormal = new ThemeColor("statusBar.background"); @@ -72,7 +75,11 @@ export class StatusBarItem { } case "ready": case "readyForAutoTrigger": { - if (this.checkIfVSCodeInlineCompletionEnabled()) { + // TODO(Sma1lboy): implement this status in tabby-agent in the future when need to generalize to other IDEs + if (!this.checkIfVSCodeInlineCompletionAvailable(statusInfo)) { + return; + } + if (statusInfo.status === "readyForAutoTrigger" && this.checkIfVSCodeInlineCompletionEnabled()) { this.setColorNormal(); this.setIcon(iconAutomatic); this.setTooltip(statusInfo.tooltip); @@ -80,7 +87,10 @@ export class StatusBarItem { break; } case "readyForManualTrigger": { - if (this.checkIfVSCodeInlineCompletionEnabled()) { + if (!this.checkIfVSCodeInlineCompletionAvailable(statusInfo)) { + return; + } + if (statusInfo.status === "readyForManualTrigger" && this.checkIfVSCodeInlineCompletionEnabled()) { this.setColorNormal(); this.setIcon(iconManual); this.setTooltip(statusInfo.tooltip); @@ -106,6 +116,20 @@ export class StatusBarItem { } } + /** + * Check Availability of Inline Completion from remote server + */ + private checkIfVSCodeInlineCompletionAvailable(status: StatusInfo) { + const codeModel = status.serverHealth?.["model"]; + if (!codeModel) { + this.setColorNormal(); + this.setIcon(iconCodeModelNotFound); + this.setTooltip("Tabby: Code Completion Model Unavailable"); + return false; + } + return true; + } + private checkIfVSCodeInlineCompletionEnabled() { if (this.config.vscodeInlineSuggestEnabled) { return true;