Repository: TabbyML/tabby
File: clients/vscode/src/chat/WebviewHelper.ts (TypeScript)

Code before:
                <p>Tabby</p>
              </div>
              <h4 class='title'>Welcome to Tabby Chat!</h4>
              <p>To start chatting, please set up your Tabby server. Ensure that your Tabby server is properly configured and connected.</p>
            </main>
          </body>
        </html>
      `;
    }
  }

  public sendMessageToChatPanel(message: ChatMessage) {
    this.logger.info(`Sending message to chat panel: ${JSON.stringify(message)}`);
    this.client?.sendMessage(message);
  }

  public async syncActiveSelectionToChatPanel(context: Context | null) {
    try {
      await this.client?.updateActiveSelection(context);
    } catch {
      this.logger.logEveryN(
        "sync-active-selection-failed",
        100,
        "warn",
        "Active selection sync failed. Please update your Tabby server to the latest version.",
      );
    }
  }

  public addRelevantContext(context: Context) {
    if (!this.client) {
      this.pendingRelevantContexts.push(context);
    } else {
      this.client?.addRelevantContext(context);
    }
  }

  public async refreshChatPage() {
    const agentStatus = this.agent.status;
    const serverInfo = await this.agent.fetchServerInfo();

    if (agentStatus === "unauthorized") {
      return this.client?.showError({
        content:
          "Before you can start chatting, please take a moment to set up your credentials to connect to the Tabby server.",
      });
    }

    const error = this.checkChatPanel(serverInfo);
    if (error) {
      this.client?.showError({ content: error });

Review comment (bug):
```suggestion
      this.logger.logEveryN({
        key: "sync-active-selection-failed",
        log_every_n: 100,
        level: "warn",
        message: "Active selection sync failed. Please update your Tabby server to the latest version.",
      });
```

Provide reasonble default in function, so user can input only key, every, and message if needed

Code after:
                <p>Tabby</p>
              </div>
              <h4 class='title'>Welcome to Tabby Chat!</h4>
              <p>To start chatting, please set up your Tabby server. Ensure that your Tabby server is properly configured and connected.</p>
            </main>
          </body>
        </html>
      `;
    }
  }

  public sendMessageToChatPanel(message: ChatMessage) {
    this.logger.info(`Sending message to chat panel: ${JSON.stringify(message)}`);
    this.client?.sendMessage(message);
  }

  public async syncActiveSelectionToChatPanel(context: Context | null) {
    try {
      await this.client?.updateActiveSelection(context);
    } catch {
      this.logger.log(
        {
          every: 100,
          level: "warn",
        },
        "Active selection sync failed. Please update your Tabby server to the latest version.",
      );
    }
  }

  public addRelevantContext(context: Context) {
    if (!this.client) {
      this.pendingRelevantContexts.push(context);
    } else {
      this.client?.addRelevantContext(context);
    }
  }

  public async refreshChatPage() {
    const agentStatus = this.agent.status;
    const serverInfo = await this.agent.fetchServerInfo();

    if (agentStatus === "unauthorized") {
      return this.client?.showError({
        content:
          "Before you can start chatting, please take a moment to set up your credentials to connect to the Tabby server.",
      });
    }

    const error = this.checkChatPanel(serverInfo);
    if (error) {