continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
19.59k stars 1.71k forks source link

Error: Expected signal to be an instanceof AbortSignal or EventTarget on running custom config slash commands #3052

Open lakshits11 opened 4 days ago

lakshits11 commented 4 days ago

Before submitting your bug report

Relevant environment info

- OS: Windows 11
- Continue version: 0.8.58
- IDE version: VS Code Latest
- Model: Mistral API
config.slashCommands?.push({
    name: "refactor",
    description: "Analyze and provide detailed refactoring suggestions for the selected code",
    run: async function* (sdk) {
      const input = await sdk.input;

      const systemMessage = `
        You are an expert code refactoring assistant. Analyze the provided code and suggest comprehensive refactoring improvements. Follow these steps:

        1. Code Analysis:
        - Identify code smells and anti-patterns
        - Analyze complexity and maintainability issues
        - Review naming conventions and code structure
        - Check for potential performance bottlenecks

        2. Refactoring Suggestions:
        - Provide specific, actionable refactoring recommendations
        - Explain the benefits of each suggested change
        - Include before/after code examples
        - Prioritize suggestions by impact and implementation effort

        3. Implementation Guide:
        - Provide step-by-step refactoring instructions
        - Include refactored code with detailed comments
        - Highlight potential risks and how to mitigate them
        - Suggest tests to verify refactoring changes

        Here is the code to refactor:
        ${input}

        Organize your response in clear sections and provide practical, production-ready solutions.
        `;

      // Send the system message to the LLM
      for await (const message of sdk.llm.streamComplete(systemMessage, {
        // temperature: 0.7,
        maxTokens: 4096,
        // topP: 0.9,
      })) {
        yield message;
      }
    },
  });

Description

As mentioned above, I have added this command and when trying to run this, I get the error. Normally running anything without the custom slash command does not result in an error.

To reproduce

  1. Add the custom slash command I gave above
  2. Select a code and use that command
  3. See the error

Log output

[Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "23b691a9-8d04-4a5e-8cea-37f2cef0ac80",
    "messageType": "command/run",
    "data": {
      "input": "/refactor \n\n src/pages/PackageDetail.tsx (213-222)\n      {/* WhatsApp Contact Button */}\n      <a\n        href=\"https://wa.me/1234567890\"\n        target=\"_blank\"\n        rel=\"noopener noreferrer\"\n        className=\"fixed bottom-8 right-8 bg-green-500 text-white p-4 rounded-full shadow-lg hover:bg-green-600 transition-colors z-40\"\n      >\n        <Phone className=\"h-6 w-6\" />\n      </a>\n    </div>\n```",
      "history": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "/refactor \n\n```tsx src/pages/PackageDetail.tsx (213-222)\n      {/* WhatsApp Contact Button */}\n      <a\n        href=\"https://wa.me/1234567890\"\n        target=\"_blank\"\n        rel=\"noopener noreferrer\"\n        className=\"fixed bottom-8 right-8 bg-green-500 text-white p-4 rounded-full shadow-lg hover:bg-green-600 transition-colors z-40\"\n      >\n        <Phone className=\"h-6 w-6\" />\n      </a>\n    </div>\n```"
            }
          ]
        }
      ],
      "modelTitle": "Mistral Large",
      "slashCommandName": "refactor",
      "contextItems": [],
      "historyIndex": 0,
      "selectedCode": [
        {
          "filepath": "src/pages/PackageDetail.tsx (213-222)",
          "range": {
            "start": {
              "line": 212,
              "character": 0
            },
            "end": {
              "line": 221,
              "character": 0
            }
          }
        }
      ]
    }
  }
}

Error: Expected signal to be an instanceof AbortSignal or EventTarget
tomasz-stefaniak commented 1 day ago

@lakshits11 we've recently introduced the abort signal in some new places, there was a large PR for this last week and it's possible that some bugs have inadvertently been introduced.

For your reference:

Also a heads-up: we will most likely be de-emphasizing slash commands in the future, maybe not straight out deprecating them but at least seriously rethinking them.

lakshits11 commented 1 day ago

Hy can you link a discussion if available on why slash commands are de-emphasized? I just want to read the arguments. Thanks.

tomasz-stefaniak commented 17 hours ago

@lakshits11 this is a discussion we've mostly been having internally but it's related to a couple things: