Skip to content

Conversation

andrewheard
Copy link
Contributor

Added an appendHistory method to the Chat class and replaced all direct calls to history.append with appendHistory. The append call on the history array is mutating and it was occurring outside the lock.

Note: Chat still isn't completely thread-safe since parallel sendMessage or sendMessageStream calls could update the history in an arbitrary order.

#no-changelog

This commit introduces a new `appendHistory` method to the `Chat` class to provide a thread-safe way of appending to the chat history.

The following changes were made:
- A new `appendHistory` method was added to the `Chat` class.
- All direct calls to `history.append` were replaced with calls to the new `appendHistory` method.

This ensures that all modifications to the chat history are protected by a lock, preventing potential race conditions.
Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

@andrewheard andrewheard marked this pull request as ready for review July 15, 2025 21:40
@andrewheard andrewheard requested a review from paulb777 July 15, 2025 21:41
@andrewheard andrewheard merged commit 6f12583 into main Jul 15, 2025
47 checks passed
@andrewheard andrewheard deleted the add-thread-safety-to-chat-history branch July 15, 2025 21:53
@firebase firebase locked and limited conversation to collaborators Aug 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants