-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(agent): deprecate
tabby/agent/*
methods and intro `tabby/c…
…onfig/*` and `tabby/stastus/*`. (#2895)
- Loading branch information
Showing
8 changed files
with
631 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { EventEmitter } from "events"; | ||
import { Connection } from "vscode-languageserver"; | ||
import { ClientCapabilities, ServerCapabilities, Config, ConfigRequest, ConfigDidChangeNotification } from "./protocol"; | ||
import type { Feature } from "./feature"; | ||
import { TabbyAgent } from "../TabbyAgent"; | ||
|
||
export class ConfigProvider extends EventEmitter implements Feature { | ||
constructor(private readonly agent: TabbyAgent) { | ||
super(); | ||
this.agent.on("configUpdated", async () => { | ||
this.update(); | ||
}); | ||
} | ||
|
||
private async update() { | ||
const status = await this.getConfig(); | ||
this.emit("updated", status); | ||
} | ||
|
||
setup(connection: Connection, clientCapabilities: ClientCapabilities): ServerCapabilities { | ||
connection.onRequest(ConfigRequest.type, async () => { | ||
return this.getConfig(); | ||
}); | ||
if (clientCapabilities.tabby?.configDidChangeListener) { | ||
this.on("updated", (config: Config) => { | ||
connection.sendNotification(ConfigDidChangeNotification.type, config); | ||
}); | ||
} | ||
return {}; | ||
} | ||
|
||
async getConfig(): Promise<Config> { | ||
const agentConfig = this.agent.getConfig(); | ||
return { | ||
server: agentConfig.server, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.