feat: add tab-local AIChat toggle and per-tab chat buffer reuse#203
feat: add tab-local AIChat toggle and per-tab chat buffer reuse#203Konfekt wants to merge 4 commits intomadox2:mainfrom
Conversation
|
Hi, could you explain in more detail what is this feature doing? It looks like it is something that should work - opening and focusing last chat within the current window. If you look at this line: https://github.com/madox2/vim-ai/blob/main/autoload/vim_ai.vim#L253 it says it is trying to re-use the chat in the active window. However it doesn't seem to work, it only checks It is a bug but the fix should not be that complicated like the code in this PR, but maybe I am missing something. |
|
Maybe there's a confusion between tab and window. A tab is a window container in Vim. Now there's exactly one AIChat window per tab that can be toggled by |
|
Maybe clearer would be to bind one |
|
I see now. But the code still looks quite complicated. Isn't enough to set tab variable and if exist use it over |
Avoid toggling chat buffers through a separate entry point and fix tab-local chat reuse when buffers are hidden or visible elsewhere. Reuse or create chat windows in one code path, track tab chat buffers consistently, and open escaped scratch buffer names safely. - Removed the unused `force_new` parameter from `s:OpenChatWindow()`. - Removed the forwarding-only `vim_ai#AIChatToggleRun()`. - Removed the duplicate `settabvar()` from `vim_ai#AIChatRun()`. - Added `abort` to `s:ReuseOrCreateChatWindow()`. - Kept tab ownership based on `bufnr`, not scratch names. - Escaped scratch names with `fnameescape()` when calling `:file`. - Inlined trivial one-use window visibility logic into `s:ReuseOrCreateChatWindow()`.
|
|
There was a problem hiding this comment.
Pull request overview
This PR updates vim-ai’s chat UX so :AIChat reuses a dedicated chat buffer per tab (instead of reusing “last scratch buffer” across the whole session), and adds a buffer-local :AI command inside aichat buffers to continue the conversation.
Changes:
- Implement tab-local chat buffer tracking/reuse via tab variables in chat window creation logic.
- Add a buffer-local
:AIcommand inaichatbuffers to continue chat completion. - Update user-facing docs/help text to describe the new tab-local chat behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
autoload/vim_ai.vim |
Reworks chat window reuse/creation to be tab-local and removes the old “last scratch buffer name” reuse logic. |
ftplugin/aichat.vim |
Adds a buffer-local :AI command in aichat buffers that routes to chat continuation. |
doc/vim-ai.txt |
Updates :AI/:AIChat documentation to reflect the new tab-local semantics. |
README.md |
Updates :AIChat description and usage notes to reflect the new behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I am sorry for having overread the bug report above. In any event, #207 seems now the way forward |
|
Reopening to address #207 not working with dirty configurations, including |
|
Should be working, if it is not, please create an issue. Please explain what "dirty configuration" is in your case and provide steps to reproduce |
Let's one toggle one AIchat window per tab