Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions clients/vscode/src/StatusBarItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
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";

Check failure on line 6 in clients/vscode/src/StatusBarItem.ts

View workflow job for this annotation

GitHub Actions / autofix

'getLogger' is defined but never used

Check failure on line 6 in clients/vscode/src/StatusBarItem.ts

View workflow job for this annotation

GitHub Actions / tests

'getLogger' is defined but never used

const label = "Tabby";
const iconAutomatic = "$(check)";
Expand All @@ -11,6 +13,7 @@
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");
Expand Down Expand Up @@ -72,15 +75,22 @@
}
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);
}
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);
Expand All @@ -106,6 +116,20 @@
}
}

/**
* 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;
Expand Down
Loading