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

Code before:
      this.sendMessageToChatPanel("Explain the selected code:");
    },
    "chat.addRelevantContext": async () => {
      this.addRelevantContext();
    },
    "chat.addFileContext": () => {
      const editor = window.activeTextEditor;
      if (editor) {
        commands.executeCommand("tabby.chatView.focus").then(() => {
          const fileContext = ChatViewProvider.getFileContextFromEditor({ editor, gitProvider: this.gitProvider });
          this.chatViewProvider.addRelevantContext(fileContext);
        });
      } else {
        window.showInformationMessage("No active editor");
      }
    },
    "chat.fixCodeBlock": async () => {
      this.sendMessageToChatPanel("Identify and fix potential bugs in the selected code:");
    },
    "chat.generateCodeBlockDoc": async () => {
      this.sendMessageToChatPanel("Generate documentation for the selected code:");
    },
    "chat.generateCodeBlockTest": async () => {
      this.sendMessageToChatPanel("Generate a unit test for the selected code:");
    },
    "chat.edit.start": async (args?: { errorContext: string }) => {
      const editor = window.activeTextEditor;
      if (!editor) {
        return;
      }

      const editLocation = {
        uri: editor.document.uri.toString(),
        range: {
          start: { line: editor.selection.start.line, character: 0 },
          end: {
            line: editor.selection.end.character === 0 ? editor.selection.end.line : editor.selection.end.line + 1,
            character: 0,
          },
        },
      };

      const inlineEditController = new InlineEditController(
        this.client,
        this.config,
        this.contextVariables,
        editor,
        editLocation,
        args,
      );
      inlineEditController.start();

Review comment (suggestion):
```suggestion
    "chat.edit.start": async (userCommand?: string) => {
```

When `userCommand` is set, the command shall be executed but not added to recentlyEditCommand

Code after:
      this.sendMessageToChatPanel("Explain the selected code:");
    },
    "chat.addRelevantContext": async () => {
      this.addRelevantContext();
    },
    "chat.addFileContext": () => {
      const editor = window.activeTextEditor;
      if (editor) {
        commands.executeCommand("tabby.chatView.focus").then(() => {
          const fileContext = ChatViewProvider.getFileContextFromEditor({ editor, gitProvider: this.gitProvider });
          this.chatViewProvider.addRelevantContext(fileContext);
        });
      } else {
        window.showInformationMessage("No active editor");
      }
    },
    "chat.fixCodeBlock": async () => {
      this.sendMessageToChatPanel("Identify and fix potential bugs in the selected code:");
    },
    "chat.generateCodeBlockDoc": async () => {
      this.sendMessageToChatPanel("Generate documentation for the selected code:");
    },
    "chat.generateCodeBlockTest": async () => {
      this.sendMessageToChatPanel("Generate a unit test for the selected code:");
    },
    "chat.edit.start": async (userCommand?: string) => {
      const editor = window.activeTextEditor;
      if (!editor) {
        return;
      }

      const editLocation = {
        uri: editor.document.uri.toString(),
        range: {
          start: { line: editor.selection.start.line, character: 0 },
          end: {
            line: editor.selection.end.character === 0 ? editor.selection.end.line : editor.selection.end.line + 1,
            character: 0,
          },
        },
      };

      const inlineEditController = new InlineEditController(
        this.client,
        this.config,
        this.contextVariables,
        editor,
        editLocation,
        userCommand,
      );
      inlineEditController.start();