Skip to content

Commit

Permalink
fix(agent): fix datastore init in vscode web extension. (#3307)
Browse files Browse the repository at this point in the history
  • Loading branch information
icycodes authored Oct 23, 2024
1 parent b38d997 commit e5274d2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions clients/tabby-agent/src/dataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ export class DataStore extends EventEmitter implements Feature {
if (clientCapabilities.tabby?.dataStore) {
this.lspConnection = connection;

const params: DataStoreGetParams = { key: "data" };
const data = await connection.sendRequest(DataStoreGetRequest.type, params);
if (!deepEqual(data, this.data)) {
const old = this.data;
this.data = data;
this.emit("updated", data, old);
try {
// FIXME(@icycodes): This try-catch block avoids the initialization error in current version.
// As the lsp client has not be initialized, the request will always throws errors,
// the dataStore data should be initialized by initializationOptions, and be synced by notifications.
const params: DataStoreGetParams = { key: "data" };
const data = await connection.sendRequest(DataStoreGetRequest.type, params);
if (!deepEqual(data, this.data)) {
const old = this.data;
this.data = data;
this.emit("updated", data, old);
}
} catch (error) {
// ignore
}
}
return {};
Expand Down

0 comments on commit e5274d2

Please sign in to comment.