Skip to content

Commit 61c5917

Browse files
committed
fix: correct history storage in client
The commit fixes two issues: - Updates direct access to history table to use self.history in the client module, removing redundant reassignment - Adds a display for memory content in the chat overlay when available This improves both correctness and usability of the Copilot Chat plugin.
1 parent 908b53d commit 61c5917

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

lua/CopilotChat/client.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,18 +696,15 @@ function Client:ask(prompt, opts)
696696
log.debug('Last message: ', last_message)
697697

698698
if opts.store_history then
699-
table.insert(history, {
699+
table.insert(self.history, {
700700
content = prompt,
701701
role = 'user',
702702
})
703703

704-
table.insert(history, {
704+
table.insert(self.history, {
705705
content = full_response,
706706
role = 'assistant',
707707
})
708-
709-
self.history = history
710-
log.debug('History size increased to: ', #history)
711708
end
712709

713710
return full_response,

lua/CopilotChat/config/mappings.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local async = require('plenary.async')
22
local copilot = require('CopilotChat')
3+
local client = require('CopilotChat.client')
34
local utils = require('CopilotChat.utils')
45

56
---@class CopilotChat.config.mappings.diff
@@ -475,6 +476,16 @@ return {
475476
table.insert(lines, '')
476477
end
477478

479+
if client.memory then
480+
table.insert(lines, '**Memory**')
481+
table.insert(lines, '```')
482+
for _, line in ipairs(vim.split(vim.trim(client.memory.content), '\n')) do
483+
table.insert(lines, line)
484+
end
485+
table.insert(lines, '```')
486+
table.insert(lines, '')
487+
end
488+
478489
copilot.chat:overlay({
479490
text = vim.trim(table.concat(lines, '\n')) .. '\n',
480491
})

0 commit comments

Comments
 (0)