Skip to content

Commit 6da52c7

Browse files
authored
chore(chat): fix lsp warnings (#2435)
Co-authored-by: Oli Morris <[email protected]>
1 parent 1217d5b commit 6da52c7

File tree

1 file changed

+11
-13
lines changed
  • lua/codecompanion/strategies/chat

1 file changed

+11
-13
lines changed

lua/codecompanion/strategies/chat/init.lua

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,11 +1226,12 @@ function Chat:done(output, reasoning, tools, meta, opts)
12261226
end
12271227

12281228
if content and content ~= "" then
1229-
self:add_message({
1229+
local message = {
12301230
role = config.constants.LLM_ROLE,
12311231
content = content,
12321232
reasoning = reasoning_content,
1233-
}, {
1233+
}
1234+
self:add_message(message, {
12341235
_meta = has_meta and meta or nil,
12351236
})
12361237
reasoning_content = nil
@@ -1246,12 +1247,13 @@ function Chat:done(output, reasoning, tools, meta, opts)
12461247
if has_tools then
12471248
tools = adapters.call_handler(self.adapter, "format_calls", tools)
12481249
if tools then
1249-
self:add_message({
1250+
local message = {
12501251
role = config.constants.LLM_ROLE,
12511252
reasoning = reasoning_content,
12521253
tool_calls = tools,
12531254
_meta = has_meta and meta or nil,
1254-
}, {
1255+
}
1256+
self:add_message(message, {
12551257
visible = false,
12561258
})
12571259
return self.tools:execute(self, tools)
@@ -1272,13 +1274,14 @@ end
12721274
function Chat:add_context(data, source, id, opts)
12731275
opts = vim.tbl_extend("force", { visible = false }, opts or {})
12741276

1275-
if not data.role then
1276-
data.role = config.constants.USER_ROLE
1277-
end
1277+
local message = {
1278+
role = data.role or config.constants.USER_ROLE,
1279+
content = data.content,
1280+
}
12781281

12791282
-- Context is created by adding it to the context class and linking it to a message on the chat buffer
12801283
self.context:add({ source = source, id = id, bufnr = opts.bufnr, path = opts.path, opts = opts.context_opts })
1281-
self:add_message(data, { visible = opts.visible, context = { id = id }, _meta = { tag = opts.tag or source } })
1284+
self:add_message(message, { visible = opts.visible, context = { id = id }, _meta = { tag = opts.tag or source } })
12821285
end
12831286

12841287
---TODO: Remove this method in v18.0.0
@@ -1543,11 +1546,6 @@ function Chat:add_buf_message(data, opts)
15431546
return self.builder:add_message(data, opts)
15441547
end
15451548

1546-
---Add a new header to the chat buffer
1547-
---@param role "user"|"llm"
1548-
---@param opts? table Options for the header
1549-
function Chat:add_new_header(role, opts) end
1550-
15511549
---Update a specific line in the chat buffer
15521550
---@param line_number number The line number to update (1-based)
15531551
---@param content string The new content for the line

0 commit comments

Comments
 (0)