Skip to content

Commit 94dfc01

Browse files
authored
fix(chat): reinsert stickies before prompt processing (#1472)
This change ensures that sticky messages are properly reinserted before processing the prompt, preserving their context in the chat flow. The previous logic for removing sticky prefixes was removed, and stickies are now stored correctly after resolution. Closes #1471 Signed-off-by: Tomas Slusny <[email protected]>
1 parent bd8b48e commit 94dfc01

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

lua/CopilotChat/init.lua

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ function M.ask(prompt, config)
404404
-- Resolve prompt after window is opened
405405
prompt = process_sticky(prompt, config)
406406
prompt = vim.trim(prompt)
407+
prompt = table.concat(M.chat:get_sticky(), '\n') .. '\n\n' .. prompt
407408

408409
-- After opening window we need to schedule to next cycle so everything properly resolves
409410
schedule(function()
@@ -420,15 +421,7 @@ function M.ask(prompt, config)
420421
local resolved_resources, resolved_tools, resolved_stickies, prompt = prompts.resolve_functions(prompt, config)
421422
local selected_model, prompt = prompts.resolve_model(prompt, config)
422423

423-
-- Remove sticky prefix
424-
prompt = table.concat(
425-
vim.tbl_map(function(l)
426-
return l:gsub('^>%s+', '')
427-
end, vim.split(prompt, '\n')),
428-
'\n'
429-
)
430-
431-
-- Add resolved stickies to chat
424+
-- Store resolved stickies to chat
432425
local current_sticky = M.chat:get_sticky()
433426
for _, sticky in ipairs(resolved_stickies) do
434427
table.insert(current_sticky, sticky)

0 commit comments

Comments
 (0)