Skip to content

feat(ui): add room message export/import#118

Open
LemonNekoGH wants to merge 1 commit intomainfrom
feat/roo-chat-export-import
Open

feat(ui): add room message export/import#118
LemonNekoGH wants to merge 1 commit intomainfrom
feat/roo-chat-export-import

Conversation

@LemonNekoGH
Copy link
Owner

Summary

  • add room message export/import actions and dialog
  • serialize/restore room messages with parent links
  • update tutorial copy

Testing

  • not run (not requested)

@netlify
Copy link

netlify bot commented Feb 1, 2026

Deploy Preview for flow-chat ready!

Name Link
🔨 Latest commit 83ad2a7
🔍 Latest deploy log https://app.netlify.com/projects/flow-chat/deploys/697edbf1064c040008e9c207
😎 Deploy Preview https://deploy-preview-118--flow-chat.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@gemini-code-assist
Copy link

Summary of Changes

Hello @LemonNekoGH, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the application's functionality by enabling users to export and import their chat room conversations. This feature provides a robust way to back up important discussions or transfer them between instances, ensuring the integrity of message hierarchies and associated metadata during the process. The changes include both the backend logic for serialization/deserialization and the frontend UI for user interaction.

Highlights

  • Message Export Functionality: Introduced the ability to export chat room messages, including their conversational structure and metadata, into a JSON file.
  • Message Import Functionality: Added the capability to import chat room messages from a previously exported JSON file, correctly restoring parent links and message content.
  • User Interface Integration: Integrated export and import actions into the RoomSelector component with dedicated buttons and a new dialog for the import process.
  • Tutorial Update: Updated the in-app tutorial to reflect the new message export/import features.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new functionality to export and import chat room messages. The changes include adding UI elements such as export and import buttons to the room selector, implementing an import dialog, and developing the core logic within the message store to handle the serialization and deserialization of chat data, including database interactions for creating and updating messages. Review comments suggest improving the robustness of the isExportedRoomMessages type guard by validating the structure of individual messages within the imported array, and optimizing the importRoomMessages function to enhance performance by batching database operations rather than executing sequential await calls within a loop.

Comment on lines +176 to +187
function isExportedRoomMessages(value: unknown): value is ExportedRoomMessages {
if (!isRecord(value))
return false

if (value.version !== 1)
return false

if (!isRecord(value.room) || typeof value.room.id !== 'string')
return false

return Array.isArray(value.messages)
}

Choose a reason for hiding this comment

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

high

The type guard isExportedRoomMessages provides a basic check on the imported data, but it could be more robust. It currently verifies that value.messages is an array, but it doesn't validate the contents of the array. If the messages array contains items that don't match the ExportedMessage interface, it could lead to runtime errors later in the importRoomMessages function in messages.ts. I suggest adding a more thorough validation by checking that each item in the array has the expected structure.

function isExportedRoomMessages(value: unknown): value is ExportedRoomMessages {
  if (!isRecord(value))
    return false

  if (value.version !== 1)
    return false

  if (!isRecord(value.room) || typeof value.room.id !== 'string')
    return false

  return Array.isArray(value.messages) && value.messages.every(
    (msg: unknown) =>
      isRecord(msg)
      && typeof msg.id === 'string'
      && typeof msg.role === 'string'
      && Array.isArray(msg.content),
  )
}

Comment on lines +252 to +279
for (const message of pending) {
const parentId = message.parent_id ? idMap.get(message.parent_id) : null
if (message.parent_id && !parentId) {
remaining.push(message)
continue
}

const [created] = await messageModel.create({
role: message.role,
parent_id: parentId ?? null,
provider: message.provider,
model: message.model,
room_id: roomId,
memory: message.memory ?? [],
summary: message.summary ?? null,
})

if (message.content.length > 0) {
await messageModel.appendContentBatch(created.id, message.content)
}

if (message.show_summary) {
await messageModel.updateShowSummary(created.id, true)
}

idMap.set(message.id, created.id)
progressed = true
}

Choose a reason for hiding this comment

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

medium

The importRoomMessages function iterates through each message and performs several await calls for database operations (create, appendContentBatch, updateShowSummary) within the loop. For large imports, this will result in many sequential database queries, which can be inefficient.

To improve performance, consider batching these operations. For each level of the message tree dependency, you could:

  1. Collect all messages that are ready to be created.
  2. Insert them in a single batch database call.
  3. Then, perform batch operations for content and summary updates for the newly created messages.

This would reduce the number of round-trips to the database and should significantly speed up the import process for large files.

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.

1 participant