From 3af32c8c7c331154f152e50e31011bcf71dd0469 Mon Sep 17 00:00:00 2001 From: Zhiming Ma Date: Tue, 12 Sep 2023 13:25:20 +0800 Subject: [PATCH] fix: hotfix vscode extension 0.4.1. update document links, fix data.json migration, and update anonymous usage tracking client properties. (#434) --- clients/intellij/package.json | 2 +- clients/tabby-agent/package.json | 2 +- clients/tabby-agent/src/Agent.ts | 1 + clients/tabby-agent/src/TabbyAgent.ts | 18 ++++++++++++------ clients/tabby-agent/src/dataStore.ts | 13 +++++++++++++ clients/tabby-agent/src/logger.ts | 2 ++ clients/vim/package.json | 2 +- clients/vscode/CHANGELOG.md | 7 +++++++ clients/vscode/README.md | 4 ++-- .../assets/walkthroughs/codeCompletion.md | 2 +- clients/vscode/assets/walkthroughs/server.md | 2 +- clients/vscode/package.json | 6 +++--- clients/vscode/src/agent.ts | 10 ++++++++++ 13 files changed, 55 insertions(+), 16 deletions(-) diff --git a/clients/intellij/package.json b/clients/intellij/package.json index 0c70b7a1e9a3..afa8df42acd7 100644 --- a/clients/intellij/package.json +++ b/clients/intellij/package.json @@ -10,6 +10,6 @@ "devDependencies": { "cpy-cli": "^4.2.0", "rimraf": "^5.0.1", - "tabby-agent": "0.1.0" + "tabby-agent": "0.1.1" } } diff --git a/clients/tabby-agent/package.json b/clients/tabby-agent/package.json index 918333b74497..e77f558440b7 100644 --- a/clients/tabby-agent/package.json +++ b/clients/tabby-agent/package.json @@ -1,6 +1,6 @@ { "name": "tabby-agent", - "version": "0.1.0", + "version": "0.1.1", "description": "Generic client agent for Tabby AI coding assistant IDE extensions.", "repository": "https://github.com/TabbyML/tabby", "main": "./dist/index.js", diff --git a/clients/tabby-agent/src/Agent.ts b/clients/tabby-agent/src/Agent.ts index ad6310f80274..843686ab5c53 100644 --- a/clients/tabby-agent/src/Agent.ts +++ b/clients/tabby-agent/src/Agent.ts @@ -10,6 +10,7 @@ import { AgentConfig, PartialAgentConfig } from "./AgentConfig"; export type AgentInitOptions = Partial<{ config: PartialAgentConfig; client: string; + clientProperties: Record; }>; export type ServerHealthState = HealthState; diff --git a/clients/tabby-agent/src/TabbyAgent.ts b/clients/tabby-agent/src/TabbyAgent.ts index 41c55eee5a62..8262b4e13eac 100644 --- a/clients/tabby-agent/src/TabbyAgent.ts +++ b/clients/tabby-agent/src/TabbyAgent.ts @@ -253,9 +253,15 @@ export class TabbyAgent extends EventEmitter implements Agent { private healthCheck(): Promise { return this.callApi(this.api.v1.health, {}) .then((healthState) => { - this.serverHealthState = healthState; - if (this.status === "ready") { - this.anonymousUsageLogger.uniqueEvent("AgentConnected", healthState); + if ( + typeof healthState === "object" && + healthState["model"] !== undefined && + healthState["device"] !== undefined + ) { + this.serverHealthState = healthState; + if (this.status === "ready") { + this.anonymousUsageLogger.uniqueEvent("AgentConnected", healthState); + } } }) .catch(() => {}); @@ -276,11 +282,11 @@ export class TabbyAgent extends EventEmitter implements Agent { } public async initialize(options: AgentInitOptions): Promise { - if (options.client) { + if (options.client || options.clientProperties) { // Client info is only used in logging for now // `pino.Logger.setBindings` is not present in the browser - allLoggers.forEach((logger) => logger.setBindings?.({ client: options.client })); - this.anonymousUsageLogger.addProperties({ client: options.client }); + allLoggers.forEach((logger) => logger.setBindings?.({ client: options.client, ...options.clientProperties })); + this.anonymousUsageLogger.addProperties({ client: options.client, ...options.clientProperties }); } if (userAgentConfig) { await userAgentConfig.load(); diff --git a/clients/tabby-agent/src/dataStore.ts b/clients/tabby-agent/src/dataStore.ts index edb4be2cbc9f..2c4bc44c0c7d 100644 --- a/clients/tabby-agent/src/dataStore.ts +++ b/clients/tabby-agent/src/dataStore.ts @@ -19,10 +19,23 @@ export const dataStore: DataStore = isBrowser return { data: {}, load: async function () { + await this.migrateFrom_0_3_0(); this.data = (await fs.readJson(dataFile, { throws: false })) || {}; }, save: async function () { await fs.outputJson(dataFile, this.data); }, + migrateFrom_0_3_0: async function () { + const dataFile_0_3_0 = require("path").join(require("os").homedir(), ".tabby", "agent", "data.json"); + const migratedFlag = require("path").join(require("os").homedir(), ".tabby", "agent", ".data_json_migrated"); + if ( + (await fs.pathExists(dataFile_0_3_0)) && + !(await fs.pathExists(migratedFlag)) + ) { + const data = await fs.readJson(dataFile_0_3_0); + await fs.outputJson(dataFile, data); + await fs.outputFile(migratedFlag, ""); + } + }, }; })(); diff --git a/clients/tabby-agent/src/logger.ts b/clients/tabby-agent/src/logger.ts index e873bdcb9d25..ef988ab3c078 100644 --- a/clients/tabby-agent/src/logger.ts +++ b/clients/tabby-agent/src/logger.ts @@ -19,6 +19,8 @@ const stream = export const rootLogger = !!stream ? pino(stream) : pino(); if (isTest && testLogDebug) { rootLogger.level = "debug"; +} else { + rootLogger.level = "silent"; } export const allLoggers = [rootLogger]; diff --git a/clients/vim/package.json b/clients/vim/package.json index 9bf5ac926f9d..cf56665ed973 100644 --- a/clients/vim/package.json +++ b/clients/vim/package.json @@ -10,6 +10,6 @@ "devDependencies": { "cpy-cli": "^4.2.0", "rimraf": "^5.0.1", - "tabby-agent": "0.1.0" + "tabby-agent": "0.1.1" } } diff --git a/clients/vscode/CHANGELOG.md b/clients/vscode/CHANGELOG.md index 9c7dd4129bd9..e447c6b54d8f 100644 --- a/clients/vscode/CHANGELOG.md +++ b/clients/vscode/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.4.1 + +Fixes: + +- Updated expired links in the documentation. +- Migrated Tabby cloud authorization tokens and anonymous usage tracking id from the old data directory to the new one. + ## 0.4.0 Features: diff --git a/clients/vscode/README.md b/clients/vscode/README.md index a1eeecb5db5d..ed04ce14ccb5 100644 --- a/clients/vscode/README.md +++ b/clients/vscode/README.md @@ -14,9 +14,9 @@ If you encounter any problem or have any suggestion, please [open an issue](http ## Demo -Try our online demo [here](https://tabbyml.github.io/tabby/playground). +Try our online demo [here](https://tabby.tabbyml.com/playground). -![Demo](https://tabbyml.github.io/tabby/img/demo.gif) +![Demo](https://tabby.tabbyml.com/img/demo.gif) ## Get Started diff --git a/clients/vscode/assets/walkthroughs/codeCompletion.md b/clients/vscode/assets/walkthroughs/codeCompletion.md index 2ded6c1c9c0b..781730e73be4 100644 --- a/clients/vscode/assets/walkthroughs/codeCompletion.md +++ b/clients/vscode/assets/walkthroughs/codeCompletion.md @@ -4,7 +4,7 @@ Tabby will show inline suggestions when you stop typing, and you can accept suggestions by just pressing the `Tab` key. -![Demo](https://tabbyml.github.io/tabby/img/demo.gif) +![Demo](https://tabby.tabbyml.com/img/demo.gif) ## Cycling Through Choices diff --git a/clients/vscode/assets/walkthroughs/server.md b/clients/vscode/assets/walkthroughs/server.md index c91a8f8381ee..3d0b6b0b7823 100644 --- a/clients/vscode/assets/walkthroughs/server.md +++ b/clients/vscode/assets/walkthroughs/server.md @@ -9,4 +9,4 @@ You can get a Tabby Cloud account [here](https://app.tabbyml.com). Once you crea ## Self-Hosting -Tabby is an open-source project and supports self-hosting. For more details, please refer to our [self-hosting guide](https://tabbyml.github.io/tabby/docs/self-hosting/) and visit our [Github repository](https://github.com/tabbyml/tabby). +Tabby is an open-source project and supports self-hosting. For more details, please refer to our [self-hosting guide](https://tabby.tabbyml.com/docs/installation/) and visit our [Github repository](https://github.com/tabbyml/tabby). diff --git a/clients/vscode/package.json b/clients/vscode/package.json index af68169387bb..6acf73f7829c 100644 --- a/clients/vscode/package.json +++ b/clients/vscode/package.json @@ -3,11 +3,11 @@ "publisher": "TabbyML", "displayName": "Tabby", "description": "Tabby is a self-hosted AI coding assistant that can suggest multi-line code or full functions in real-time.", - "homepage": "https://tabbyml.github.io/tabby", + "homepage": "https://tabby.tabbyml.com/", "repository": "https://github.com/TabbyML/tabby", "bugs": "https://github.com/TabbyML/tabby/issues", "license": "Apache-2.0", - "version": "0.4.0", + "version": "0.4.1", "keywords": [ "ai", "autocomplete", @@ -197,6 +197,6 @@ }, "dependencies": { "@xstate/fsm": "^2.0.1", - "tabby-agent": "0.1.0" + "tabby-agent": "0.1.1" } } diff --git a/clients/vscode/src/agent.ts b/clients/vscode/src/agent.ts index b0cfbbe76fcb..41f6131b6d86 100644 --- a/clients/vscode/src/agent.ts +++ b/clients/vscode/src/agent.ts @@ -41,6 +41,16 @@ export async function createAgentInstance(context: ExtensionContext): Promise { await initPromise;