A command for passing a prompt to the chat

Feature request for product/service

Chat

Describe the request

I’m developing an extension (React Compiler Marker ✨ - Visual Studio Marketplace) and I would like to send text to the chat. For VSCode I do:

vscode.commands.executeCommand('workbench.action.chat.open', prompt);

This command is not supported in Cursor and there are no alternatives, could you add support for it? Or at least allow cursor.startComposerPrompt command to take a prompt argument.

Anyone from the Cursor team can look into it?

Yeah this would be great. Basically the “Add to chat” command but with the option to pass a custom prompt/wrapper.

1 Like

Btw - I found a workaround by opening the chat using composer.newAgentChat and using clipboard manipulation to paste the text

Example:

import * as vscode from "vscode";
import { PROMPT_TEMPLATE } from "./prompt-template";

async function sendTextToChat(prompt: string): Promise<void> {
  // write prompt to clipboard
  await vscode.env.clipboard.writeText(prompt);

  // open cursor chat
  await vscode.commands.executeCommand("composer.newAgentChat");

  // timeout to wait for UI
  await new Promise((resolve) => setTimeout(resolve, 100));]

  // paste clipboard to chat
  await vscode.commands.executeCommand("editor.action.clipboardPasteAction");
}

// Usage example:
export function activate(context: vscode.ExtensionContext) {
  const cmd = vscode.commands.registerCommand(
    "your-extension.sendToChat",
    async () => {
      const editor = vscode.window.activeTextEditor;
      const selectedText = editor.document.getText(editor.selection);
      const prompt = PROMPT_TEMPLATE.replace("{{INPUT_TEXT}}", text);
      await sendTextToChat(prompt);
    }
  );
  context.subscriptions.push(cmd);
}

this is just a workaround - a native command that accepts a prompt argument would be cleaner imo. I built a Cursor Rule Extension yesterday that uses this implementation and it seems to be working so far.

here is the code if you wanna see more details

Nice workaround! This is so stupid Cursor doesn’t allow it with one simple command :man_facepalming:

Looking into this

Just did it will have it out in the next 10 days, just needed a reminder!

1 Like

Awesome, thank you!

Really excited for this, were you able to get it in yet?

Yes, it’s in Cursor 2.3!

13m

Sorry if this was obvious but I didn’t see which specific command works, is it vscode.commands.executeCommand('workbench.action.chat.open', prompt);

or cursor.startComposerPrompt