refactor: VSCode Extension Settings cleanup. (#248)
* refactor: VSCode Extension Settings cleanup. * fix: vscode extension update settings naming.improve-workflow
parent
7f607f2f30
commit
7597ec6097
|
|
@ -2,7 +2,7 @@
|
|||
"name": "vscode-tabby",
|
||||
"publisher": "TabbyML",
|
||||
"displayName": "Tabby",
|
||||
"description": "Get completions from Tabby server",
|
||||
"description": "Tabby is a self-hosted AI coding assistant that can suggest multi-line code or full functions in real-time.",
|
||||
"repository": "https://github.com/TabbyML/tabby",
|
||||
"version": "0.0.6",
|
||||
"keywords": [
|
||||
|
|
@ -30,12 +30,8 @@
|
|||
"title": "Tabby: Toggle Code Suggestion On/Off"
|
||||
},
|
||||
{
|
||||
"command": "tabby.setServerUrl",
|
||||
"title": "Tabby: Set URL of Tabby Server"
|
||||
},
|
||||
{
|
||||
"command": "tabby.setSuggestionDelay",
|
||||
"title": "Tabby: Set suggestion delay"
|
||||
"command": "tabby.setApiEndpoint",
|
||||
"title": "Tabby: Specify API Endpoint of Tabby"
|
||||
},
|
||||
{
|
||||
"command": "tabby.openSettings",
|
||||
|
|
@ -45,30 +41,33 @@
|
|||
"configuration": {
|
||||
"title": "Tabby",
|
||||
"properties": {
|
||||
"tabby.enabled": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Enable Tabby code suggestion or not."
|
||||
},
|
||||
"tabby.serverUrl": {
|
||||
"tabby.api.endpoint": {
|
||||
"type": "string",
|
||||
"default": "http://127.0.0.1:8080",
|
||||
"default": "http://localhost:8080",
|
||||
"format": "uri",
|
||||
"pattern": "^https?:\\/\\/[^\\s]+$",
|
||||
"patternErrorMessage": "Please enter a validate http or https URL.",
|
||||
"markdownDescription": "Specifies the url of [Tabby Server](https://github.com/TabbyML/tabby)."
|
||||
"description": "Specify API Endpoint of Tabby."
|
||||
},
|
||||
"tabby.disableAnonymousUsageTracking": {
|
||||
"tabby.codeCompletion": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Disable anonymous usage tracking."
|
||||
"default": true,
|
||||
"description": "Enable Tabby code completion or not."
|
||||
},
|
||||
"tabby.suggestionDelay": {
|
||||
"tabby.developerOptions": {
|
||||
"type": "object",
|
||||
"description": "Developer options for Tabby.",
|
||||
"properties": {
|
||||
"suggestionDelay": {
|
||||
"type": "number",
|
||||
"default": 150,
|
||||
"minimum": 0,
|
||||
"description": "Specifies the delay in milliseconds after which the request is sent to the tabby."
|
||||
},
|
||||
"tabby.agentLogs": {
|
||||
"agent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"logs": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"debug",
|
||||
|
|
@ -76,7 +75,16 @@
|
|||
"silent"
|
||||
],
|
||||
"default": "error",
|
||||
"markdownDescription": "Specifies the log level of tabby-agent for debugging purpose. \n * If VSCode is running as desktop application, you can find log files in `$HOME/.tabby/agent-logs/`. It's recommend using `tail -f ~/.tabby/agent-logs/tabby-agent.log | npx pino-pretty` to monitor logs. \n * If VSCode is running in browser, you can find logs in debug console. "
|
||||
"markdownDescription": "Specifies the log level for tabby-agent."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tabby.usage.anonymousUsageTracking": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Disable anonymous usage tracking."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ export class TabbyCompletionProvider implements InlineCompletionItemProvider {
|
|||
|
||||
private updateConfiguration() {
|
||||
const configuration = workspace.getConfiguration("tabby");
|
||||
this.enabled = configuration.get("enabled", true);
|
||||
this.suggestionDelay = configuration.get("suggestionDelay", 150);
|
||||
this.enabled = configuration.get("codeCompletion", true);
|
||||
this.suggestionDelay = configuration.get("developerOptions.suggestionDelay", 150);
|
||||
}
|
||||
|
||||
private toInlineCompletions(tabbyCompletion: CompletionResponse | null, range: Range): InlineCompletionItem[] {
|
||||
|
|
|
|||
|
|
@ -4,21 +4,21 @@ import { TabbyAgent, AgentConfig, DataStore } from "tabby-agent";
|
|||
function getWorkspaceConfiguration(): Partial<AgentConfig> {
|
||||
const configuration = workspace.getConfiguration("tabby");
|
||||
const config: Partial<AgentConfig> = {};
|
||||
const serverUrl = configuration.get<string>("serverUrl");
|
||||
if (serverUrl) {
|
||||
const endpoint = configuration.get<string>("api.endpoint");
|
||||
if (endpoint) {
|
||||
config.server = {
|
||||
endpoint: serverUrl,
|
||||
endpoint,
|
||||
};
|
||||
}
|
||||
const agentLogs = configuration.get<"debug" | "error" | "silent">("agentLogs");
|
||||
const agentLogs = configuration.get<"debug" | "error" | "silent">("developerOptions.agent.logs");
|
||||
if (agentLogs) {
|
||||
config.logs = {
|
||||
level: agentLogs,
|
||||
};
|
||||
}
|
||||
const disableAnonymousUsageTracking = configuration.get<boolean>("disableAnonymousUsageTracking", false);
|
||||
const anonymousUsageTrackingDisabled = configuration.get<boolean>("usage.anonymousUsageTracking", false);
|
||||
config.anonymousUsageTracking = {
|
||||
disable: disableAnonymousUsageTracking,
|
||||
disable: anonymousUsageTrackingDisabled,
|
||||
};
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ const toggleEnabled: Command = {
|
|||
command: "tabby.toggleEnabled",
|
||||
callback: () => {
|
||||
const configuration = workspace.getConfiguration("tabby");
|
||||
const enabled = configuration.get("enabled", true);
|
||||
const enabled = configuration.get("codeCompletion", true);
|
||||
console.debug(`Toggle Enabled: ${enabled} -> ${!enabled}.`);
|
||||
configuration.update("enabled", !enabled, configTarget, false);
|
||||
configuration.update("codeCompletion", !enabled, configTarget, false);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ const setSuggestionDelay: Command = {
|
|||
command: "tabby.setSuggestionDelay",
|
||||
callback: () => {
|
||||
const configuration = workspace.getConfiguration("tabby");
|
||||
const current = configuration.get("suggestionDelay", 150);
|
||||
const current = configuration.get("developerOptions.suggestionDelay", 150);
|
||||
const items = {
|
||||
Immediately: 0, // ms
|
||||
Default: 150,
|
||||
|
|
@ -87,20 +87,20 @@ const setSuggestionDelay: Command = {
|
|||
quickPick.hide();
|
||||
const delay = new Duration(quickPick.selectedItems[0].label).offset;
|
||||
console.debug("Set suggestion delay: ", delay);
|
||||
configuration.update("suggestionDelay", delay, configTarget, false);
|
||||
configuration.update("developerOptions.suggestionDelay", delay, configTarget, false);
|
||||
});
|
||||
quickPick.show();
|
||||
},
|
||||
};
|
||||
|
||||
const setServerUrl: Command = {
|
||||
command: "tabby.setServerUrl",
|
||||
const setApiEndpoint: Command = {
|
||||
command: "tabby.setApiEndpoint",
|
||||
callback: () => {
|
||||
const configuration = workspace.getConfiguration("tabby");
|
||||
window
|
||||
.showInputBox({
|
||||
prompt: "Enter the URL of your Tabby Server",
|
||||
value: configuration.get("serverUrl", ""),
|
||||
value: configuration.get("api.endpoint", ""),
|
||||
validateInput: (input: string) => {
|
||||
try {
|
||||
let url = new URL(input);
|
||||
|
|
@ -117,7 +117,7 @@ const setServerUrl: Command = {
|
|||
.then((url) => {
|
||||
if (url) {
|
||||
console.debug("Set Tabby Server URL: ", url);
|
||||
configuration.update("serverUrl", url, configTarget, false);
|
||||
configuration.update("api.endpoint", url, configTarget, false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
@ -126,7 +126,7 @@ const setServerUrl: Command = {
|
|||
const openSettings: Command = {
|
||||
command: "tabby.openSettings",
|
||||
callback: () => {
|
||||
commands.executeCommand("workbench.action.openSettings", "tabby");
|
||||
commands.executeCommand("workbench.action.openSettings", "@ext:TabbyML.vscode-tabby");
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -178,6 +178,6 @@ const statusBarItemClicked: Command = {
|
|||
};
|
||||
|
||||
export const tabbyCommands = () =>
|
||||
[toggleEnabled, setServerUrl, setSuggestionDelay, openSettings, emitEvent, openAuthPage, statusBarItemClicked].map(
|
||||
[toggleEnabled, setApiEndpoint, setSuggestionDelay, openSettings, emitEvent, openAuthPage, statusBarItemClicked].map(
|
||||
(command) => commands.registerCommand(command.command, command.callback, command.thisArg)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ function toDisabled() {
|
|||
}
|
||||
|
||||
function updateStatusBarItem() {
|
||||
const enabled = workspace.getConfiguration("tabby").get("enabled", true);
|
||||
const enabled = workspace.getConfiguration("tabby").get("codeCompletion", true);
|
||||
if (!enabled) {
|
||||
fsmService.send("disabled");
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue