Skip to content

Commit bef1a4a

Browse files
committed
add descriptions to all commands, fixup duplicate edit messages
1 parent 8e74a67 commit bef1a4a

File tree

5 files changed

+14
-58
lines changed

5 files changed

+14
-58
lines changed

README.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ TLDR:
4343
- `<leader>mp` is for `:Magenta paste-selection`. In visual mode it will take the current selection and paste it into the input buffer.
4444
- `<leader>mc` is for `:Magenta context-files` with your _current_ file. It will pin the current file to your context.
4545
- `<leader>mf` is for `:Magenta context-files` it allows you to select files via fzf-lua, and will pin those files to your context. This requires that fzf-lua is installed.
46-
47-
In the input buffer or the display buffer:
48-
49-
- `<leader>a` is for `:Magenta abort`, which will abort the current in-flight request.
50-
- `<leader>c` is for `:Magenta clear`, which will clear the current chat.
46+
- `<leader>mc` is for `:Magenta clear`, which will clear the current chat.
47+
- `<leader>ma` is for `:Magenta abort`, which will abort the current in-flight request.
5148

5249
The display buffer is not modifiable, however you can interact with some parts of the display buffer by pressing `<CR>`. For example, you can expand the tool request and responses to see their details, and you can trigger a diff to appear on file edits.
5350

bun/chat/chat.ts

-20
Original file line numberDiff line numberDiff line change
@@ -563,26 +563,6 @@ ${msg.error.stack}`,
563563
}
564564
}
565565

566-
for (const filePath in msg.edits) {
567-
for (const requestId of msg.edits[filePath].requestIds) {
568-
const toolWrapper = model.toolManager.toolWrappers[requestId];
569-
if (!toolWrapper) {
570-
throw new Error(
571-
`Expected to find tool use with requestId ${requestId}`,
572-
);
573-
}
574-
575-
messageContent.push({
576-
type: "tool_use",
577-
request: toolWrapper.model.request,
578-
});
579-
580-
toolResponseContent.push(
581-
toolManagerModel.getToolResult(toolWrapper.model),
582-
);
583-
}
584-
}
585-
586566
const out: ProviderMessage[] = [
587567
{
588568
role: msg.role,

bun/sidebar.ts

-26
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ export class Sidebar {
7373
const displayHeight = Math.floor((totalHeight - cmdHeight) * 0.8);
7474
const inputHeight = totalHeight - displayHeight - 2;
7575

76-
// await nvim.command("clearjumps");
77-
7876
let displayBuffer: NvimBuffer;
7977
if (existingDisplayBuffer) {
8078
displayBuffer = existingDisplayBuffer;
@@ -84,18 +82,6 @@ export class Sidebar {
8482
await displayBuffer.setOption("buftype", "nofile");
8583
await displayBuffer.setOption("swapfile", false);
8684
await displayBuffer.setOption("filetype", "markdown");
87-
await displayBuffer.setKeymap({
88-
mode: "n",
89-
lhs: "<leader>c",
90-
rhs: ":Magenta clear<CR>",
91-
opts: { silent: true, noremap: true },
92-
});
93-
await displayBuffer.setKeymap({
94-
mode: "n",
95-
lhs: "<leader>a",
96-
rhs: ":Magenta abort<CR>",
97-
opts: { silent: true, noremap: true },
98-
});
9985
}
10086
const displayWindowId = (await this.nvim.call("nvim_open_win", [
10187
displayBuffer.id,
@@ -125,18 +111,6 @@ export class Sidebar {
125111
rhs: ":Magenta send<CR>",
126112
opts: { silent: true, noremap: true },
127113
});
128-
await inputBuffer.setKeymap({
129-
mode: "n",
130-
lhs: "<leader>c",
131-
rhs: ":Magenta clear<CR>",
132-
opts: { silent: true, noremap: true },
133-
});
134-
await inputBuffer.setKeymap({
135-
mode: "n",
136-
lhs: "<leader>a",
137-
rhs: ":Magenta abort<CR>",
138-
opts: { silent: true, noremap: true },
139-
});
140114
}
141115

142116
const inputWindowId = (await this.nvim.call("nvim_open_win", [

bun/tools/toolManager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export function init({ nvim, lsp }: { nvim: Nvim; lsp: Lsp }) {
186186
}
187187
}
188188

189-
function displayRequest(model: ToolModel): string {
189+
function displayRequestInput(model: ToolModel): string {
190190
switch (model.type) {
191191
case "get_file":
192192
return GetFile.displayInput(model.request.input);
@@ -231,7 +231,7 @@ ${result.result.value}
231231
) {
232232
return withBindings(
233233
d`${renderToolContents(model.model, dispatch)}${
234-
model.showRequest ? d`\n${displayRequest(model.model)}` : ""
234+
model.showRequest ? d`\nid: ${model.model.request.id}\n${displayRequestInput(model.model)}` : ""
235235
}${model.showResult ? displayResult(model.model) : ""}`,
236236
{
237237
"<CR>": () =>

lua/magenta/init.lua

+10-5
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ M.setup = function(opts)
1515
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
1616

1717
M.start(true)
18-
vim.api.nvim_set_keymap("n", "<leader>mt", ":Magenta toggle<CR>", {silent = true, noremap = true})
19-
vim.api.nvim_set_keymap("v", "<leader>mp", ":Magenta paste-selection<CR>", {silent = true, noremap = true})
18+
vim.api.nvim_set_keymap("n", "<leader>mc", ":Magenta clear<CR>", {silent = true, noremap = true, desc = "Clear Magenta state"})
19+
vim.api.nvim_set_keymap("n", "<leader>ma", ":Magenta abort<CR>", {silent = true, noremap = true, desc = "Abort current Magenta operation"})
20+
vim.api.nvim_set_keymap("n", "<leader>mt", ":Magenta toggle<CR>", {silent = true, noremap = true, desc = "Toggle Magenta window"})
21+
vim.api.nvim_set_keymap("v", "<leader>mp", ":Magenta paste-selection<CR>", {silent = true, noremap = true, desc = "Send selection to Magenta"})
2022
vim.api.nvim_set_keymap(
2123
"n",
22-
"<leader>mc", -- like "magenta current"?
24+
"<leader>mb", -- like "magenta buffer"?
2325
"",
2426
{
2527
noremap = true,
2628
silent = true,
29+
desc = "Add current buffer to Magenta context",
2730
callback = function()
2831
local current_file = vim.fn.expand("%:p")
2932
vim.cmd("Magenta context-files " .. vim.fn.shellescape(current_file))
@@ -38,6 +41,7 @@ M.setup = function(opts)
3841
{
3942
noremap = true,
4043
silent = true,
44+
desc = "Select files to add to Magenta context",
4145
callback = function()
4246
local success, fzf = pcall(require, "fzf-lua")
4347
if not success then
@@ -65,7 +69,7 @@ end
6569

6670
M.testSetup = function()
6771
-- do not start. The test runner will start the process for us.
68-
vim.api.nvim_set_keymap("n", "<leader>m", ":Magenta toggle<CR>", {silent = true, noremap = true})
72+
vim.api.nvim_set_keymap("n", "<leader>m", ":Magenta toggle<CR>", {silent = true, noremap = true, desc = "Toggle Magenta window"})
6973
end
7074

7175
M.start = function(silent)
@@ -108,7 +112,8 @@ M.bridge = function(channelId)
108112
end,
109113
{
110114
nargs = "+",
111-
range = true
115+
range = true,
116+
desc = "Execute Magenta command"
112117
}
113118
)
114119

0 commit comments

Comments
 (0)