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

Code before:
            if (gitRemoteUrl) {
              infoList.push({
                url: gitRemoteUrl,
              });
            }
          }
        }

        const workspaceFolder = workspace.workspaceFolders ?? [];
        for (const folder of workspaceFolder) {
          const repo = this.gitProvider.getRepository(folder.uri);
          if (repo) {
            const gitRemoteUrl = this.gitProvider.getDefaultRemoteUrl(repo);
            if (gitRemoteUrl && gitRemoteUrl !== activeGitUrl) {
              infoList.push({
                url: gitRemoteUrl,
              });
            }
          }
        }
        return infoList;
      },

      getActiveEditorSelection: async (): Promise<EditorFileContext | null> => {
        const editor = window.activeTextEditor;
        if (!editor) {
          return null;
        }

        const fileContext = await getFileContextFromSelection(editor, this.gitProvider);
        return fileContext;
      },
    });
  }

  private checkStatusAndLoadContent() {
    const statusInfo = this.lspClient.status.current;
    const error = this.checkStatusInfo(statusInfo);
    if (error) {
      this.currentConfig = undefined;
      this.loadErrorPage(error);
      return;
    }
    const config = this.lspClient.agentConfig.current;
    if (!config) {
      this.currentConfig = undefined;
      this.loadErrorPage("Cannot get the server configuration.");
      return;
    }
    if (this.currentConfig?.endpoint !== config.server.endpoint || this.currentConfig?.token !== config.server.token) {
      this.currentConfig = config.server;

Review comment (suggestion):
```suggestion
        if (!editor || !isValidForSyncActiveEditorSelection(editor)) {
```

Code after:
                url: gitRemoteUrl,
              });
            }
          }
        }

        const workspaceFolder = workspace.workspaceFolders ?? [];
        for (const folder of workspaceFolder) {
          const repo = this.gitProvider.getRepository(folder.uri);
          if (repo) {
            const gitRemoteUrl = this.gitProvider.getDefaultRemoteUrl(repo);
            if (gitRemoteUrl && gitRemoteUrl !== activeGitUrl) {
              infoList.push({
                url: gitRemoteUrl,
              });
            }
          }
        }
        return infoList;
      },

      getActiveEditorSelection: async (): Promise<EditorFileContext | null> => {
        const editor = window.activeTextEditor;
        if (!editor || !isValidForSyncActiveEditorSelection(editor)) {
          return null;
        }

        const fileContext = await getFileContextFromSelection(editor, this.gitProvider);
        return fileContext;
      },
    });
  }

  private checkStatusAndLoadContent() {
    const statusInfo = this.lspClient.status.current;
    const error = this.checkStatusInfo(statusInfo);
    if (error) {
      this.currentConfig = undefined;
      this.loadErrorPage(error);
      return;
    }
    const config = this.lspClient.agentConfig.current;
    if (!config) {
      this.currentConfig = undefined;
      this.loadErrorPage("Cannot get the server configuration.");
      return;
    }
    if (this.currentConfig?.endpoint !== config.server.endpoint || this.currentConfig?.token !== config.server.token) {
      this.currentConfig = config.server;
      this.loadChatPanel();
    }