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
18.35k stars 1.5k forks source link

Slash command /so throws an error. #2426

Open FurtherAI opened 3 weeks ago

FurtherAI commented 3 weeks ago

Before submitting your bug report

Relevant environment info

- OS: ubuntu 22.04
- Continue: v0.8.52
- IDE: vscode 1.93.1
- Model: local OpenAI compatible
- config.json:

{
  "models": [
    {
      "model": "claude-3-5-sonnet-20240620",
      "provider": "anthropic",
      "apiKey": "",
      "title": "Claude 3.5 Sonnet"
    },
    {
      "model": "hermes3-70b-awq",
      "provider": "openai",
      "apiBase": "http://localhost:2242/v1",
      "apiKey": "EMPTY",
      "title": "hermes3"
    }
  ],
  // "tabAutocompleteModel": {
  //   "title": "Codestral",
  //   "provider": "mistral",
  //   "model": "codestral-latest",
  //   "apiKey": ""
  // },
  "customCommands": [
    {
      "name": "test",
      "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
      "description": "Write unit tests for highlighted code"
    }
  ],
  "contextProviders": [
    {
      "name": "code",
      "params": {}
    },
    {
      "name": "docs",
      "params": {}
    },
    {
      "name": "diff",
      "params": {}
    },
    {
      "name": "terminal",
      "params": {}
    },
    {
      "name": "problems",
      "params": {}
    },
    {
      "name": "folder",
      "params": {}
    },
    {
      "name": "codebase",
      "params": {}
    },
    { 
      "name": "search"
    },
    {
      "name": "repo-map"
    }
  ],
  "slashCommands": [
    {
      "name": "edit",
      "description": "Edit selected code"
    },
    {
      "name": "comment",
      "description": "Write comments for the selected code"
    },
    {
      "name": "share",
      "description": "Export the current chat session to markdown"
    },
    {
      "name": "cmd",
      "description": "Generate a shell command"
    },
    {
      "name": "commit",
      "description": "Generate a git commit message"
    },
    {
      "name": "so",
      "description": "Reference StackOverflow to answer the question"
    },
    {
      "name": "onboard",
      "description": "Familiarize yourself with the codebase"
    }
  ]
}

Description

Using the slash command /so to search stack overflow gives an error: TypeError: Cannot read properties of undefined (reading 'map').

To reproduce

Try running the /so command and if it isn't reproducible, we can track down what is wrong on my end.

Log output

notificationsAlerts.ts:42 Cannot read properties of undefined (reading 'map')
c @ notificationsAlerts.ts:42
(anonymous) @ notificationsAlerts.ts:28
B @ event.ts:1242
C @ event.ts:1253
fire @ event.ts:1277
addNotification @ notifications.ts:228
notify @ notificationService.ts:253
(anonymous) @ mainThreadMessageService.ts:86
f @ mainThreadMessageService.ts:51
$showMessage @ mainThreadMessageService.ts:45
S @ rpcProtocol.ts:458
Q @ rpcProtocol.ts:443
M @ rpcProtocol.ts:373
L @ rpcProtocol.ts:299
(anonymous) @ rpcProtocol.ts:161
B @ event.ts:1242
fire @ event.ts:1273
fire @ ipc.net.ts:652
K.onmessage @ localProcessExtensionHost.ts:378

log.ts:439   ERR [Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "2ff0c22d-fb28-4b78-94c0-122fac4250c6",
    "messageType": "command/run",
    "data": {
      "input": "/so python",
      "history": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "/so python"
            }
          ]
        }
      ],
      "modelTitle": "hermes3",
      "slashCommandName": "so",
      "contextItems": [],
      "historyIndex": 0,
      "selectedCode": []
    }
  }
}

TypeError: Cannot read properties of undefined (reading 'map')
sestinj commented 1 week ago

Thanks for pointing this out. We intend to replace the /so command with an improved "web" context provider, so I'm going to leave this open but note that it's not something that we'll directly fix other than removing the slash command entirely. I'll let you know when web is ready!

FurtherAI commented 1 week ago

Sounds good

RomneyDa commented 8 hours ago

PR Open to remove stack overflow provider

@FurtherAI WebContextProvider is now available in prerelease

To use, add it to your config.json like:

{
    ...,
    "contextProviders": [
        ...,
        {
            "name": "web",
            "params": {}
        },
     ]

Then, you can type @web followed by a search query

See code: https://github.com/continuedev/continue/blob/dev/core/context/providers/WebContextProvider.ts

If you want to keep the more specific Stack Overflow context provider, you can refactor it as a custom context provider