Do not re-use the same chatId forever#51
Merged
joaopluigi merged 3 commits intomainfrom Oct 11, 2025
Merged
Conversation
Add a focused test suite validating that: - mediator/state track and expose the current chat-id - chat/prompt requests omit chatId before one is assigned and include it afterwards - reopening Neovim starts with no chat-id and uses a new one once provided by the server This safeguards the change to use a new chat-id when reopening Neovim and prevents regressions. 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca <noreply@eca.dev>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where chat context persists between Neovim sessions by implementing dynamic chat ID management. Instead of using a hardcoded chat ID, the system now starts with nil and updates to use the server-provided chat ID.
- Replaces hardcoded chat ID with dynamic ID from server responses
- Adds state management for tracking current chat ID
- Ensures fresh chat sessions when reopening Neovim
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_chat_id.lua | Comprehensive test suite covering chat ID lifecycle scenarios |
| lua/eca/state.lua | Adds id field and logic to update chat ID from server responses |
| lua/eca/sidebar.lua | Changes to use mediator's dynamic chat ID instead of hardcoded value |
| lua/eca/mediator.lua | Adds id() method to retrieve current chat ID from state |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| end | ||
|
|
||
| function mediator:id() | ||
| return (self.state and self.state.id) |
There was a problem hiding this comment.
[nitpick] The parentheses around the return expression are unnecessary and don't add clarity. Consider removing them for cleaner code.
Suggested change
| return (self.state and self.state.id) | |
| return self.state and self.state.id |
chatId forever
ericdallo
approved these changes
Oct 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Chat keeps context even when nvim is closed and re-opened because the
chatIdsent to the server is always1. This makes the context become huge; consequently, paying more tokens that it was supposed to.Example:

Solution
Sends
chatIdasniland them use the value the server send back as thechatId, saving it to the state