Skip to content

Sticky parameters #910

Closed
@v3ceban

Description

@v3ceban

What's going on

Adding context or an agent to any of the api functions makes them sticky.

-- used in a mapping to open a chat with currently opened buffers
CopilotChat.open {
  selection = CopilotSelection.buffer,
  context = "buffers", -- results in >#buffers being added to chat before my prompt
}
 -- used in a mapping to ask perplexity with no attachement to the codebase
CopilotChat.ask(input, {
  agent = "perplexityai", -- results in >@preplexity being added
  selection = false,
  context = false,
})
  -- part of my config
Dockerfile = {
  prompt = "/COPILOT_INSTRUCTIONS\n\nGenerate a Dockerfile for this application.",
  agent = "docker",
  context = "files:full", -- adds both >@docker and >#files:full
  selection = false,
},

What I tried

Adding the new sticky param to nil or {} didn't help.

The fix for now is to disable agent/context and pass them as the part of the prompt like this

Dockerfile = {
  prompt = "/COPILOT_INSTRUCTIONS\n@docker\n@#files:full\n\nGenerate a Dockerfile for this application.",
  -- agent = "docker",
  -- context = "files:full",
  selection = false,
}
CopilotChat.ask("@perplexityai\n\n" .. input, {
  selection = false,
  context = false,
})

... but it feels a little weird not using the proper params.

Reasoning/background

It is very inconvenient to run these as standalone commands because you have to manually delete the sticky prompts they set when opening a new chat window or executing a new command. I manually set sticky to {} for all default prompts that use it. Before #855, I was rewriting the action prompts without the > before the instructions to remove these side effects, but now they appear when I set agents and context.

Proposed solution

It would be nice to have a way to disable/delete all sticky prompts after chat window is closed.

Deleting the whole chat history is an overkill, plus it's buggy when calling prompt_actions telescope integration in visual mode (it resets the visual selection and acts as if it was called in normal mode).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions