From 34d1b4fc816401c9bad88b33f71ef943a7dd2396 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 4 Apr 2025 02:33:18 +0200 Subject: [PATCH 1/5] fix(client): update response_text after parsing response (#1093) The response_text variable was being captured before the response body was parsed. This commit ensures that response_text is updated after parsing is complete, which provides the correct final text for processing. Closes #1064 --- lua/CopilotChat/client.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/CopilotChat/client.lua b/lua/CopilotChat/client.lua index 5f17080d..dddd1b89 100644 --- a/lua/CopilotChat/client.lua +++ b/lua/CopilotChat/client.lua @@ -709,9 +709,6 @@ function Client:ask(prompt, opts) end local response_text = response_buffer:tostring() - log.trace('Response text:\n', response_text) - log.debug('Response message:\n', vim.inspect(last_message)) - if errored then error(response_text) return @@ -727,6 +724,7 @@ function Client:ask(prompt, opts) else parse_line(response.body) end + response_text = response_buffer:tostring() end if utils.empty(response_text) then From 0a1c4631242192704a8b49398dca8e12eb39a311 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 4 Apr 2025 00:33:38 +0000 Subject: [PATCH 2/5] chore(doc): auto generate docs --- doc/CopilotChat.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 38cec261..02304af7 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2025 April 01 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2025 April 04 ============================================================================== Table of Contents *CopilotChat-table-of-contents* @@ -884,7 +884,7 @@ See CONTRIBUTING.md for detailed guidelines. Thanks goes to these wonderful people (emoji key ): -gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖Katsuhiko Nishimra💻Erno Hopearuoho💻Shaun Garwood💻neutrinoA4💻 📖Jack Muratore💻Adriel Velazquez💻 📖Tomas Slusny💻 📖Nisal📖Tobias Gårdhus📖Petr Dlouhý📖Dylan Madisetti💻Aaron Weisberg💻 📖Jose Tlacuilo💻 📖Kevin Traver💻 📖dTry💻Arata Furukawa💻Ling💻Ivan Frolov💻Folke Lemaitre💻 📖GitMurf💻Dmitrii Lipin💻jinzhongjia📖guill💻Sjon-Paul Brown💻Renzo Mondragón💻 📖fjchen7💻Radosław Woźniak💻JakubPecenka💻thomastthai📖Tomáš Janoušek💻Toddneal Stallworth📖Sergey Alexandrov💻Léopold Mebazaa💻JunKi Jin💻abdennourzahaf📖Josiah💻Tony Fischer💻 📖Kohei Wada💻Sebastian Yaghoubi📖johncming💻Rokas Brazdžionis💻Sola📖 💻Mani Chandra💻Nischal Basuti📖Teo Ljungberg💻Joe Price💻This project follows the all-contributors +gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖Katsuhiko Nishimra💻Erno Hopearuoho💻Shaun Garwood💻neutrinoA4💻 📖Jack Muratore💻Adriel Velazquez💻 📖Tomas Slusny💻 📖Nisal📖Tobias Gårdhus📖Petr Dlouhý📖Dylan Madisetti💻Aaron Weisberg💻 📖Jose Tlacuilo💻 📖Kevin Traver💻 📖dTry💻Arata Furukawa💻Ling💻Ivan Frolov💻Folke Lemaitre💻 📖GitMurf💻Dmitrii Lipin💻jinzhongjia📖guill💻Sjon-Paul Brown💻Renzo Mondragón💻 📖fjchen7💻Radosław Woźniak💻JakubPecenka💻thomastthai📖Tomáš Janoušek💻Toddneal Stallworth📖Sergey Alexandrov💻Léopold Mebazaa💻JunKi Jin💻abdennourzahaf📖Josiah💻Tony Fischer💻 📖Kohei Wada💻Sebastian Yaghoubi📖johncming💻Rokas Brazdžionis💻Sola📖 💻Mani Chandra💻Nischal Basuti📖Teo Ljungberg💻Joe Price💻Yufan You📖 💻This project follows the all-contributors specification. Contributions of any kind are welcome! From 00bf27ed201b9509105afaac4d5bdcc46ce89f35 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 4 Apr 2025 02:47:59 +0200 Subject: [PATCH 3/5] fix: handle invalid context window size in GitHub models (#1094) Before the code was assuming that context window = input tokens, but its total. Also some models arent reporting the input and output correctly, so use default when result is 0 --- lua/CopilotChat/config/providers.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lua/CopilotChat/config/providers.lua b/lua/CopilotChat/config/providers.lua index 1ca335e3..c34a398b 100644 --- a/lua/CopilotChat/config/providers.lua +++ b/lua/CopilotChat/config/providers.lua @@ -322,12 +322,20 @@ M.github_models = { return vim.tbl_contains(model.inferenceTasks, 'chat-completion') end) :map(function(model) + local context_window = model.modelLimits.textLimits.inputContextWindow + local max_output_tokens = model.modelLimits.textLimits.maxOutputTokens + local max_input_tokens = context_window - max_output_tokens + if max_input_tokens <= 0 then + max_output_tokens = 4096 + max_input_tokens = context_window - max_output_tokens + end + return { id = model.name, name = model.displayName, tokenizer = 'o200k_base', - max_input_tokens = model.modelLimits.textLimits.inputContextWindow, - max_output_tokens = model.modelLimits.textLimits.maxOutputTokens, + max_input_tokens = max_input_tokens, + max_output_tokens = max_output_tokens, } end) :totable() From 81754ea35253c48459db5712ae60531ea2c5ef75 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 4 Apr 2025 03:07:51 +0200 Subject: [PATCH 4/5] fix(diff): normalize filename (#1095) Use utils.filename() to normalize the filename value in the diff object, ensuring consistent path handling. Signed-off-by: Tomas Slusny --- lua/CopilotChat/config/mappings.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/CopilotChat/config/mappings.lua b/lua/CopilotChat/config/mappings.lua index 79219549..c7a257b5 100644 --- a/lua/CopilotChat/config/mappings.lua +++ b/lua/CopilotChat/config/mappings.lua @@ -64,7 +64,7 @@ local function get_diff(block) change = block.content, reference = reference or '', filetype = filetype or '', - filename = filename, + filename = utils.filename(filename), start_line = start_line, end_line = end_line, bufnr = bufnr, @@ -240,7 +240,6 @@ return { local lines = vim.split(diff.change, '\n', { trimempty = false }) vim.api.nvim_buf_set_lines(diff.bufnr, diff.start_line - 1, diff.end_line, false, lines) - copilot.set_selection(diff.bufnr, diff.start_line, diff.start_line + #lines - 1) end, }, From e7cd79a2ac05a32a1ce0995a82bd630598619d0b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 01:08:49 +0000 Subject: [PATCH 5/5] chore(main): release 3.10.1 --- CHANGELOG.md | 9 +++++++++ version.txt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b10796e..aa7c2751 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [3.10.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v3.10.0...v3.10.1) (2025-04-04) + + +### Bug Fixes + +* **client:** update response_text after parsing response ([#1093](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/1093)) ([34d1b4f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/34d1b4fc816401c9bad88b33f71ef943a7dd2396)), closes [#1064](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/1064) +* **diff:** normalize filename ([#1095](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/1095)) ([81754ea](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/81754ea35253c48459db5712ae60531ea2c5ef75)) +* handle invalid context window size in GitHub models ([#1094](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/1094)) ([00bf27e](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/00bf27ed201b9509105afaac4d5bdcc46ce89f35)) + ## [1.9.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.8.0...v1.9.0) (2024-02-24) diff --git a/version.txt b/version.txt index f8e233b2..f870be23 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.9.0 +3.10.1