Skip to content

Commit 6864530

Browse files
committed
fix(context): don't resend current_file if mentioned
1 parent 9783dd7 commit 6864530

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/opencode/context.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ function M.add_selection(selection)
9292
end
9393

9494
function M.add_file(file)
95+
--- TODO: probably need a way to remove a file once it's been added?
96+
--- maybe a keymap like clear all context?
97+
9598
if not M.context.mentioned_files then
9699
M.context.mentioned_files = {}
97100
end
@@ -318,7 +321,10 @@ function M.format_message(prompt, opts)
318321
local parts = { { type = 'text', text = prompt } }
319322

320323
for _, path in ipairs(context.mentioned_files or {}) do
321-
table.insert(parts, format_file_part(path, prompt))
324+
-- don't resend current file if it's also mentioned
325+
if not context.current_file or path ~= context.current_file.path then
326+
table.insert(parts, format_file_part(path, prompt))
327+
end
322328
end
323329

324330
for _, agent in ipairs(context.mentioned_subagents or {}) do

0 commit comments

Comments
 (0)