Skip to content

feat(chat): per-tab chats#3097

Merged
olimorris merged 3 commits into
olimorris:mainfrom
georgeharker:feat/pertab-chat-windows
May 10, 2026
Merged

feat(chat): per-tab chats#3097
olimorris merged 3 commits into
olimorris:mainfrom
georgeharker:feat/pertab-chat-windows

Conversation

@georgeharker
Copy link
Copy Markdown
Contributor

Description

For a long time i've wanted to be able to open a new chat window in a different tab without closing the first. I often work in multiple tabs at once and whilst you can cycle chats in the chat window it hasn't been possible to have more than one open at a time.

This PR adds display.chat.window.pertab for tab-local chats

When enabled, chat buffers visible in another tab are not hidden when opening or cycling chats in the current tab. Cycling via { / } is scoped to chats that are either visible in the current tab or not currently visible in any tab, so chats opened in other tabs are never stolen.

The Toggle command jumps to the existing tab when the chat is open elsewhere (with a notify) instead of moving the chat. The close keymap prefers a chat that's already in or available to the current tab when auto-opening a sibling chat after close. Chats survive tab closure and fall back into the hidden pool, where they remain cycle-eligible from any tab. Ie. if a tab is closed, the same behavior as currently without per-tab chats happens, and the cycling in a separate window will cycle through the now closed chat window's tabs.

pertab is mutually exclusive with sticky; if both are enabled, the sticky autocmd's callback no-ops (a warning is logged at setup) so the chat does not follow tab switches under pertab semantics.

AI Usage

Drafted in part with claude to figure out the right interception points, design mine,

Related Issue(s)

N/a

Screenshots

N/a

Checklist

  • I've read the contributing guidelines and have adhered to them in this PR
  • I confirm that this PR has been majority created by me, and not AI (unless stated in the "AI Usage" section above)
  • I've run make all to ensure docs are generated, tests pass and StyLua has formatted the code
  • (optional) I've added test coverage for this fix/feature
  • (optional) I've updated the README and/or relevant docs pages

When enabled, chat buffers visible in another tab are not hidden when
opening or cycling chats in the current tab. Cycling via { / } is
scoped to chats that are either visible in the current tab or not
currently visible in any tab, so chats opened in other tabs are never
stolen.

The Toggle command jumps to the existing tab when the chat is open
elsewhere (with a notify) instead of moving the chat. The close keymap
prefers a chat that's already in or available to the current tab when
auto-opening a sibling chat after close. Chats survive tab closure and
fall back into the hidden pool, where they remain cycle-eligible from
any tab.

pertab is mutually exclusive with sticky; if both are enabled, the
sticky autocmd's callback no-ops (a warning is logged at setup) so
the chat does not follow tab switches under pertab semantics.

Includes the bufnr_available_to_current_tab helper to share the
hidden-or-current-tab availability check between cycling and the
close keymap, and extends registry.move with an optional filter so
the chat keymaps can scope cycling to current-tab + hidden entries
without changing CLI cycling behaviour.

Adds tests for:
- chat in another tab survives opening a new chat in the current tab
- close_last_chat skips chats visible in other tabs
- sticky+pertab logs a warning and chat does not follow tab switch
- closing a tab leaves its chat in the hidden pool with registry intact
@georgeharker georgeharker force-pushed the feat/pertab-chat-windows branch from 9c7b938 to 65ce47f Compare May 5, 2026 21:56
@georgeharker georgeharker changed the title per-tab chats feat(chat): per-tab chats May 5, 2026
Comment thread lua/codecompanion/interactions/chat/keymaps/init.lua Outdated
Copy link
Copy Markdown
Owner

@olimorris olimorris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally up for this PR and a great suggestion. Some minor nitpicks around how Claude has inserted verbose comments. I do wonder if we can use a faster Lua function in place of vimscript though.

Comment thread lua/codecompanion/interactions/chat/keymaps/init.lua Outdated
Comment thread lua/codecompanion/interactions/chat/keymaps/init.lua Outdated
Comment thread lua/codecompanion/init.lua Outdated
Comment thread lua/codecompanion/init.lua Outdated
Comment thread lua/codecompanion/config.lua Outdated
@olimorris
Copy link
Copy Markdown
Owner

Note to self: Still need to try this out

@georgeharker
Copy link
Copy Markdown
Contributor Author

Addressed comments

@georgeharker
Copy link
Copy Markdown
Contributor Author

Let me know if you give it a try and find anything. I've been running with this for a few days and it seems to behave well - allows me to have multiple chats open at once as I multiplex different aspects of work.

@olimorris olimorris merged commit 2f315d2 into olimorris:main May 10, 2026
6 checks passed
@olimorris
Copy link
Copy Markdown
Owner

Great PR, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants