From 5cd32eb7c00b507837a3f82ee1d8df15f94b38d1 Mon Sep 17 00:00:00 2001 From: Zhiming Ma Date: Thu, 19 Oct 2023 11:12:14 +0800 Subject: [PATCH] refactor(agent): remove deprecated agent options. (#585) * refactor(agent): remove deprecated agent options. * fix: overwrite old template if user has not modified it. * fix: also remove debounce options. --- clients/tabby-agent/src/AgentConfig.ts | 39 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/clients/tabby-agent/src/AgentConfig.ts b/clients/tabby-agent/src/AgentConfig.ts index 339f14b..b227b75 100644 --- a/clients/tabby-agent/src/AgentConfig.ts +++ b/clients/tabby-agent/src/AgentConfig.ts @@ -53,9 +53,10 @@ export const defaultAgentConfig: AgentConfig = { mode: "adaptive", interval: 250, // ms }, + // Deprecated: There is a timeout of 3s on the server side since v0.3.0. timeout: { - auto: 5000, // 5s - manually: 30000, // 30s + auto: 4000, // 4s + manually: 4000, // 4s }, }, logs: { @@ -66,7 +67,7 @@ export const defaultAgentConfig: AgentConfig = { }, }; -const configTomlTemplate = `## Tabby agent configuration file +const oldConfigTomlTemplate = `## Tabby agent configuration file ## You can uncomment any block to enable settings. ## Configurations in this file has lower priority than in IDE settings. @@ -109,6 +110,32 @@ const configTomlTemplate = `## Tabby agent configuration file `; +const configTomlTemplate = `## Tabby agent configuration file + +## You can uncomment any block to enable settings. +## Configurations in this file has lower priority than in IDE settings. + +## Server +## You can set the server endpoint here. +# [server] +# endpoint = "http://localhost:8080" # http or https URL + +## You can add custom request headers, e.g. for authentication. +# [server.requestHeaders] +# Authorization = "Bearer eyJhbGciOiJ..........." + +## Logs +## You can set the log level here. The log file is located at ~/.tabby-client/agent/logs/. +# [logs] +# level = "silent" # or "error" or "debug" + +## Anonymous usage tracking +## You can disable anonymous usage tracking here. +# [anonymousUsageTracking] +# disable = false # set to true to disable + +`; + export const userAgentConfig = isBrowser ? null : (() => { @@ -135,6 +162,12 @@ export const userAgentConfig = isBrowser async load() { try { const fileContent = await fs.readFile(this.filepath, "utf8"); + // If the config file is the old template, and user has not modified it, + // Overwrite it with the new template. + if (fileContent.trim() === oldConfigTomlTemplate.trim()) { + await this.createTemplate(); + return await this.load(); + } this.data = toml.parse(fileContent); super.emit("updated", this.data); } catch (error) {