From e7a6074b61a7554682d1f2495c9e2e5f32cb9ecd Mon Sep 17 00:00:00 2001 From: Zhe Yu Date: Sat, 28 Jun 2025 15:50:23 +0800 Subject: [PATCH] refactor(nvim): disable deduplication for summary mode --- .../integrations/codecompanion/query_tool.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/vectorcode/integrations/codecompanion/query_tool.lua b/lua/vectorcode/integrations/codecompanion/query_tool.lua index b63510c3..6f9300ee 100644 --- a/lua/vectorcode/integrations/codecompanion/query_tool.lua +++ b/lua/vectorcode/integrations/codecompanion/query_tool.lua @@ -269,9 +269,17 @@ return check_cli_wrap(function(opts) job_runner.run_async(args, function(result, error) if vim.islist(result) and #result > 0 and result[1].path ~= nil then ---@cast result VectorCode.QueryResult[] - if opts.no_duplicate then + local summary_opts = vim.deepcopy(opts.summarise) or {} + if type(summary_opts.enabled) == "function" then + summary_opts.enabled = summary_opts.enabled(agent.chat, result) --[[@as boolean]] + end + + if opts.no_duplicate and not summary_opts.enabled then + -- NOTE: deduplication in summary mode prevents the model from requesting + -- the same content without summarysation. result = filter_results(result, agent.chat) end + local max_result = #result if opts.max_num > 0 then max_result = math.min(tonumber(opts.max_num) or 1, max_result) @@ -279,10 +287,6 @@ return check_cli_wrap(function(opts) while #result > max_result do table.remove(result) end - local summary_opts = vim.deepcopy(opts.summarise) or {} - if type(summary_opts.enabled) == "function" then - summary_opts.enabled = summary_opts.enabled(agent.chat, result) - end generate_summary(result, summary_opts, action, function(s) cb({ status = "success",