Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored May 31, 2024
1 parent 6fb8cfd commit 7fa9766
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions clients/vscode/src/chat/ChatViewProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtensionContext, WebviewViewProvider, WebviewView, workspace, Uri, env } from "vscode";
import { ExtensionContext, WebviewViewProvider, WebviewView, workspace, Uri, env, LogOutputChannel } from "vscode";
import type { ServerApi, ChatMessage, Context } from "tabby-chat-panel";
import hashObject from "object-hash";
import * as semver from "semver";
Expand All @@ -16,6 +16,7 @@ export class ChatViewProvider implements WebviewViewProvider {
constructor(
private readonly context: ExtensionContext,
private readonly agent: Agent,
private readonly logger: LogOutputChannel,
) {}

public async resolveWebviewView(webviewView: WebviewView) {
Expand All @@ -38,9 +39,9 @@ export class ChatViewProvider implements WebviewViewProvider {
navigate: async (context: Context) => {
if (context?.filepath && context?.git_url) {
const serverInfo = await this.agent.fetchServerInfo();
const filePathQuery = `redirect_filepath=${context.filepath}`
const gitUrlQuery = `redirect_git_url=${context.git_url}`
const lineQuery = `line=${context.range.start}`
const filePathQuery = `redirect_filepath=${context.filepath}`;
const gitUrlQuery = `redirect_git_url=${context.git_url}`;
const lineQuery = `line=${context.range.start}`;
const url = `${serverInfo.config.endpoint}/files?${filePathQuery}&${gitUrlQuery}&${lineQuery}`;
await env.openExternal(Uri.parse(url));
}
Expand Down Expand Up @@ -118,7 +119,7 @@ export class ChatViewProvider implements WebviewViewProvider {

private async initChatPage() {
this.webview?.webview.postMessage({ action: "sync-theme" });
this.pendingMessages.forEach((message) => this.client?.sendMessage(message));
this.pendingMessages.forEach((message) => this.sendMessageToChatPanel(message));
const serverInfo = await this.agent.fetchServerInfo();
if (serverInfo.config.token) {
this.client?.init({
Expand Down Expand Up @@ -244,7 +245,12 @@ export class ChatViewProvider implements WebviewViewProvider {
if (!this.client) {
this.pendingMessages.push(message);
} else {
this.client.sendMessage(message);
this.sendMessageToChatPanel(message);
}
}

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

0 comments on commit 7fa9766

Please sign in to comment.