Skip to content

Commit

Permalink
fix: hotfix vscode extension 0.4.1. update document links, fix data.j…
Browse files Browse the repository at this point in the history
…son migration, and update anonymous usage tracking client properties. (#434)
  • Loading branch information
icycodes authored Sep 12, 2023
1 parent 682c21e commit 3af32c8
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 16 deletions.
2 changes: 1 addition & 1 deletion clients/intellij/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"devDependencies": {
"cpy-cli": "^4.2.0",
"rimraf": "^5.0.1",
"tabby-agent": "0.1.0"
"tabby-agent": "0.1.1"
}
}
2 changes: 1 addition & 1 deletion clients/tabby-agent/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions clients/tabby-agent/src/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AgentConfig, PartialAgentConfig } from "./AgentConfig";
export type AgentInitOptions = Partial<{
config: PartialAgentConfig;
client: string;
clientProperties: Record<string, any>;
}>;

export type ServerHealthState = HealthState;
Expand Down
18 changes: 12 additions & 6 deletions clients/tabby-agent/src/TabbyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,15 @@ export class TabbyAgent extends EventEmitter implements Agent {
private healthCheck(): Promise<any> {
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(() => {});
Expand All @@ -276,11 +282,11 @@ export class TabbyAgent extends EventEmitter implements Agent {
}

public async initialize(options: AgentInitOptions): Promise<boolean> {
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();
Expand Down
13 changes: 13 additions & 0 deletions clients/tabby-agent/src/dataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
}
},
};
})();
2 changes: 2 additions & 0 deletions clients/tabby-agent/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion clients/vim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"devDependencies": {
"cpy-cli": "^4.2.0",
"rimraf": "^5.0.1",
"tabby-agent": "0.1.0"
"tabby-agent": "0.1.1"
}
}
7 changes: 7 additions & 0 deletions clients/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions clients/vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion clients/vscode/assets/walkthroughs/codeCompletion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion clients/vscode/assets/walkthroughs/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
6 changes: 3 additions & 3 deletions clients/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -197,6 +197,6 @@
},
"dependencies": {
"@xstate/fsm": "^2.0.1",
"tabby-agent": "0.1.0"
"tabby-agent": "0.1.1"
}
}
10 changes: 10 additions & 0 deletions clients/vscode/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ export async function createAgentInstance(context: ExtensionContext): Promise<Ta
const initPromise = agent.initialize({
config: getWorkspaceConfiguration(),
client: `${env.appName} ${env.appHost} ${version}, ${context.extension.id} ${context.extension.packageJSON.version}`,
clientProperties: {
ide: {
name: `${env.appName} ${env.appHost}`,
version: version,
},
tabby_plugin: {
name: context.extension.id,
version: context.extension.packageJSON.version,
},
},
});
workspace.onDidChangeConfiguration(async (event) => {
await initPromise;
Expand Down

0 comments on commit 3af32c8

Please sign in to comment.