Skip to content

Chat history "persistence"#59

Open
tamercuba wants to merge 5 commits intoeditor-code-assistant:mainfrom
tamercuba:feature/chat-history+clear-chat
Open

Chat history "persistence"#59
tamercuba wants to merge 5 commits intoeditor-code-assistant:mainfrom
tamercuba:feature/chat-history+clear-chat

Conversation

@tamercuba
Copy link

Problem

Closing or toggling the sidebar to reclaim screen space for code, a REPL buffer, or any other window would wipe the ongoing conversation. Reopening the sidebar always started fresh, which made the toggle gesture impractical during an active session.

Solution

When behavior.preserve_chat_history = true, closing the sidebar only closes the windows. The underlying chat buffer is kept alive and reattached the next time the sidebar opens, so the conversation continues exactly where it was left off.

A new EcaChatClear command is provided to explicitly reset the chat when needed.

The flag defaults to false to preserve the existing behavior for anyone updating the plugin. If the maintainers prefers making persistence the default and dropping the flag, that change is straightforward.

Config

require("eca").setup({
  behavior = {
    preserve_chat_history = true,
  },
})

Before / After

Before After
before after

Copilot AI review requested due to automatic review settings March 13, 2026 20:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in mechanism to keep the chat buffer alive when closing/toggling the ECA sidebar, plus a new EcaChatClear command to explicitly reset the chat content.

Changes:

  • Introduces behavior.preserve_chat_history (default false) to preserve chat content across sidebar close/reopen.
  • Updates sidebar window/buffer lifecycle to reuse the existing chat buffer when preservation is enabled.
  • Adds :EcaChatClear and corresponding tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
lua/eca/config.lua Adds the preserve_chat_history config default.
lua/eca/sidebar.lua Implements window-only closing and chat buffer reuse; adjusts refresh behavior when preservation is enabled.
lua/eca/commands.lua Registers :EcaChatClear to clear the chat buffer and reset welcome flags.
tests/test_chat_clear.lua Adds test coverage for :EcaChatClear across open/closed sidebar states and preservation modes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ericdallo
Copy link
Member

FYI @joaopluigi

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in “preserve chat history” mode so toggling/closing the sidebar keeps the underlying chat buffer alive, and introduces an :EcaChatClear command to explicitly clear the chat.

Changes:

  • Add behavior.preserve_chat_history (default false) to optionally keep the chat buffer across sidebar close/open cycles.
  • Update sidebar close/open logic to retain and reuse the existing chat buffer when preservation is enabled.
  • Add :EcaChatClear plus a new MiniTest suite covering clear behavior and persistence/leak checks.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lua/eca/sidebar.lua Implements “windows-only” close behavior and chat-buffer reuse when preserve_chat_history is enabled.
lua/eca/config.lua Adds the preserve_chat_history default config flag.
lua/eca/commands.lua Registers :EcaChatClear to clear the chat buffer and adjust welcome flags.
tests/test_chat_clear.lua New tests for :EcaChatClear and buffer persistence across toggles.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in mechanism to keep the chat buffer alive across sidebar close/open cycles, preventing conversation loss when the sidebar is toggled for screen space, and introduces a command to explicitly clear the chat content.

Changes:

  • Add behavior.preserve_chat_history config option (default false) to preserve the chat buffer across sidebar toggles.
  • Update sidebar close/open container lifecycle to reuse an existing chat buffer when preservation is enabled.
  • Add :EcaChatClear command plus a new MiniTest suite covering clear/persistence behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lua/eca/sidebar.lua Implements window-only close for chat when preservation is enabled; reuses existing chat buffer on open; adds clear_chat() helper.
lua/eca/config.lua Adds preserve_chat_history default config flag.
lua/eca/commands.lua Registers new :EcaChatClear user command.
tests/test_chat_clear.lua New tests validating EcaChatClear behavior and preservation toggle behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ericdallo
Copy link
Member

@tamercuba let me know when this is ready, @joaopluigi is AFK for some time, but I can merge this when ready

@tamercuba
Copy link
Author

@ericdallo Im still figuring out the copilot comments. Specially the last "batch" of comments, still dont know exactly what to do. But ty for your attention

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds optional chat buffer persistence across sidebar close/open cycles, so toggling the UI doesn’t wipe an in-progress conversation when behavior.preserve_chat_history = true. Also introduces an explicit command to clear the chat buffer and accompanying MiniTest coverage.

Changes:

  • Add behavior.preserve_chat_history config flag (default false) to preserve the chat buffer across sidebar toggles.
  • Update sidebar close/open container lifecycle to reuse an existing chat buffer when preservation is enabled.
  • Add :EcaChatClear user command and a new test suite covering clear + preservation behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lua/eca/sidebar.lua Implements “windows-only” close for chat when preserving history; reuses preserved chat buffer on reopen; adds clear_chat() state reset + buffer wipe.
lua/eca/commands.lua Registers the new :EcaChatClear user command that calls sidebar:clear_chat().
lua/eca/config.lua Adds the preserve_chat_history config default under behavior.
tests/test_chat_clear.lua Adds MiniTest coverage for EcaChatClear behavior and the preserve toggle lifecycle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@tamercuba
Copy link
Author

@ericdallo seems that the rigorous chat jippidy is now satisfied with my new feature. Can you please run the CI pipeline? I think this is ready for a human review rn :D

ps: there is a lack of documentation about what I developed here, im aware. Idk if its better to wait to merge this PR and then i open another one just to update the docs, or if we should merge everything in thie PR. Let me know about your opinion about this :)

@ericdallo
Copy link
Member

@tamercuba no problem! We can open other PRs.

I'm looking for more people to help with eca-nvim so let me know if you have interest in improving it more

@tamercuba
Copy link
Author

@ericdallo thank you for the invitation, and thank you for continuing this and other projects; its really great work! But for now, Im not interested in contributing any further

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.

3 participants