Commit Graph

369 Commits

Author SHA1 Message Date
yetone
57311d80ea fix: not enough room (#2525) 2025-07-24 14:33:16 +08:00
doodleEsc
faa3945428 feat: implement user-defined text shortcuts (#2512)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2025-07-23 11:54:59 +08:00
Dmitry Torokhov
6c9c4365a2 fix(sidebar): do not error when selecting text from help window (#2514) 2025-07-23 11:43:34 +08:00
Dmitry Torokhov
10c0a8d942 feat(sidebar): allow external users identify selected code buffer
External users such as, for example, lualine may want to identify and
add special handling for Avante buffers. This is easily done for Avante
result, input, selected files and todos buffers as they all set a unique
file type. However the selected code buffer inherits file type from the
buffer where the code came from (to have proper syntax highlighting),
and so filetype can not be used to identify it as Avante buffer.

One option would be to add a custom buffer variable, such as
vim.b.avante_buf_type and use it in plugins. Unfortunately lualine
triggers everything on file type, so that would not work.

Solve this by setting file type of the selected code buffer to
"AvanteSelectedCode" and manually activate treesitter parser with
language of the source buffer if treesitter is active there. If the
original code buffer uses legacy syntax highlighting then activate it.
This keeps syntax highlighting active for the code while allowing
external users identify Avante selected code buffer.
2025-07-22 17:50:23 +08:00
Dmitry Torokhov
c6d2783975 fix(sidebar): account for sidebar header on/off for selected code
Current implementation always says that first 5 lines of code is shown
when selected code does not fully fit into its window. This is not
correct as the window can be resized, may have a header occupying one
line, and the lines may not be the first ones. Also the wording is
awkward.

Correct these issues by checking current window height, accounting for
the potential header presence by checking sidebar.enabled config flag,
and updating the message format to be more concise:

" Selected Code (4/15 lines)"

While at it switch to using Utils.count_lines() which does not need
creating temporary tables.

Note that this does not deal with the header info being stale after
resizing sidebar windows.
2025-07-22 17:49:56 +08:00
Dmitry Torokhov
aa606b6147 refactor(history): change HistoryMessage:new() to accept role and item
Change the constructor to accept role and a single content item instead
of raw AvanteLLMMessage instance. This will help when we will start
changing message.content from being a string or a list of tables to just
a string or a single table.
2025-07-22 17:49:28 +08:00
Dmitry Torokhov
2d9f8fd252 refactor(sidebar): use helpers when working with history
Do not poke directly into avante.HistoryMessage instances, use
appropriate helpers instead.
2025-07-22 17:49:28 +08:00
yetone
db56901594 fix: result winid is nil (#2508) 2025-07-22 17:45:14 +08:00
Dmitry Torokhov
0fe0f219e4 fix(sidebar): correctly exit visual mode
Commit a9b01e7 ("chores: use stopinsert (#1745)") replaced uses of
vim.api.nvim_feedkeys(...) with proper commands to exit and enter insert
mode. However "stopinsert" does not help when editor is in visual mode.

Unfortunately there is no dedicated command to exit visual mode so we
have to go back to simulating keystrokes again.
2025-07-21 16:49:08 +08:00
Dmitry Torokhov
beeea5cb1c refactor(sidebar): get rid of winids table, use containers table
Now that we have a table listing all containers and can iterate over it
we no longer need a separate table with window IDs that we need to
maintain. Remove it.
2025-07-21 13:31:07 +08:00
Dmitry Torokhov
7d60b51324 refactor(sidebar): move sub-windows into a table
Maintaining secondary table of window IDs is cumbersome and is prone to
getting out of sync with the true state of the sidebar. In preparation
for removal of winids table move all containers (sub-windows of the
sidebar) into "containers" table.

The change is mostly mechanical rename with following exceptions:

 - Sidebar:reifresh_winids() and other places where the code scanned
   entire Sidebar object looking for tables with specific fields, such
   as "winid", or "mount" needed to be adjusted for the new structure

 - Sidebar:new() and Sidebar:reset() have been adjusted to make better
   use of the new sub-table.
2025-07-21 13:31:07 +08:00
Dmitry Torokhov
714084d2f5 refactor(sidebar): remove Sidebar:is_focused()
The method is not used anywhere, remove it.
2025-07-21 13:31:07 +08:00
Dmitry Torokhov
9ccf721435 refactor(sidebar): avoid temporary table in Sidebar:update_content()
Under the hood vim.list_extend() does the same loop over the source
table and uses table.insert() to append the values to the destination
table, so using a temporary table makes little sense.

Switch to directly inserting (appending) values into history_lines
table.
2025-07-19 13:58:11 +08:00
Dmitry Torokhov
2335ea3d15 refactor(history): reduce computational complexity when handling history
When updating chat history to be used in LLM request there are several
instances where we do O(n^2) operations: scanning all messages to locate
a tool "use" and for each use scan messages again to locate
corresponding "result".

Refactor the code to scan messages once collecting tool uses and results
together, and then do 2nd scan to drop incomplete tool invocations and
refresh "view" and "edit" results with the latest content.

Also reduce number of pre-scan loops (where we discard partially
generated messages or messages that are not interesting or too-old) by
combining them when possible.

This reduces time to scan initial 417 messages on my system (which
result in 576 final messages) from 0.32 to 0.12 seconds.
2025-07-18 22:36:21 -07:00
Dmitry Torokhov
966eef743b refactor(history): move message rendering into history module
Move code related to converting history messages into UI representation
from utils into history/render.lua for better code organization and
clean up the implementation.
2025-07-16 12:49:15 +08:00
Dmitry Torokhov
34907fc1cd refactor(history): start moving history-related code into avante/history
The utils module has grown too big and contains unrelated functionality.
Start moving code related to managing history messages comprising chat
history into lua/avante/history module to keep the code more manageable.
2025-07-16 12:49:15 +08:00
Avinash Thakur
31be8718a6 fix: layout being resized on every keystroke (#2452) 2025-07-16 11:34:46 +08:00
yetone
b8bb0fd969 refactor: llm tool parameters (#2449) 2025-07-15 16:40:25 +08:00
soulfy
c4ce24e3c0 fix: result_container takes the actual height of the editor (#2405) 2025-07-12 00:36:42 +08:00
yetone
6227d5c340 fix: close input hint when closing the sidebar (#2420) 2025-07-07 16:51:30 +08:00
Dmitry Torokhov
b051ce449a fix: slow typing in input window and other input hint optimizations (#2418) 2025-07-07 16:45:35 +08:00
Dmitry Torokhov
8346d9b005 fix: don't throw errors when closing code window (#2401) 2025-07-03 14:45:35 +08:00
yetone
46f3e77543 fix: refine init project prompts (#2398) 2025-07-02 18:56:56 +08:00
guanghechen
7aec52ff3e improve: support to customize the spinners (#2397) 2025-07-02 18:54:41 +08:00
yetone
8fde103734 fix: do not ignore failed edit tool calling (#2396) 2025-07-02 18:53:53 +08:00
yetone
203861bb71 feat: init project (#2395) 2025-07-02 18:44:30 +08:00
Peter Cardenas
6bfd792a64 fix: handle invalid code window id (#2390) 2025-07-02 12:17:30 +08:00
James Trew
d4f3224bf6 fix(sidebar): respect input height from config (#2391) 2025-07-02 12:15:40 +08:00
Peter Cardenas
7f25a33dbb feat(sidebar): add keymap to navigate between prompts (#2355) 2025-06-28 20:10:07 +08:00
Peter Cardenas
84ee9f91df fix: handle invalid todos container (#2346) 2025-06-27 15:27:56 +08:00
yetone
5b2a0e6118 fix: do not pick tool use messages when use ReAct (#2333) 2025-06-25 20:59:35 +08:00
Matthieu Coudron
c38abb907f feat: more compact and aligned display of date/model (#2325) 2025-06-25 17:53:56 +08:00
yetone
270c11da57 fix: tokens usage is nil (#2322) 2025-06-24 20:44:04 +08:00
yetone
c48808b4a8 fix: tool logs rendering (#2315) 2025-06-24 11:00:26 +08:00
yetone
e7113f1834 optimize: use cache to optimize the performance of streaming rendering (#2312) 2025-06-24 02:06:50 +08:00
yetone
6830f2d8b9 feat: tokens usage (#2300) 2025-06-23 03:13:37 +08:00
hamidi-dev
7daf169228 feat(prompt_logger): Save prompts to disk and add buffer navigation via keymaps (#2075) 2025-06-23 01:20:03 +08:00
yetone
3033556d5b fix: tool calling (#2297) 2025-06-22 21:50:26 +08:00
yetone
1e778e1c67 fix: limit tool use count (#2294) 2025-06-22 14:36:41 +08:00
yetone
fe4f7d836b fix: increase result height (#2282) 2025-06-21 02:11:37 +08:00
yetone
1063e3c45c fix: sidebar layout (#2281) 2025-06-21 01:53:13 +08:00
yetone
30fab46ca1 fix: compact memory (#2278) 2025-06-21 00:55:36 +08:00
Brewinski
8572a4832d fix: handle user-declined tool executions separately from errors (#2258) 2025-06-21 00:50:00 +08:00
guanghechen
c356fc7ce1 fix: when initialize the avante, dont mark the current buffer as selected if it's a directory path (#2254) 2025-06-18 13:35:37 +08:00
guanghechen
07319d1bd6 feat: show the count of selected files (#2250)
* feat: show the count of selected files

* fix spaces

* tweak title
2025-06-17 23:46:42 +08:00
Avinash Thakur
cf87220dff docs: fix doc types. Add lua type to opts in readme (#2200)
* docs: fix doc types. Add lua type to `opts` in readme

* [pre-commit.ci lite] apply automatic fixes

* chore: fix type error in sidebar.lua

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2025-06-17 16:09:12 +08:00
Avinash Thakur
b52a89cb08 fix: error when adding files where root != cwd (#2233) 2025-06-17 16:08:15 +08:00
Neo
fac38af934 feat(sidebar): improve auto-scroll to only trigger when user is at bottom (#2227) 2025-06-16 01:45:49 +08:00
yetone
ad05a802f9 feat: todos (#2184) 2025-06-15 15:10:07 +08:00
yetone
fdf4716ec0 fix: fuzzy match (#2221) 2025-06-13 16:46:55 +08:00