Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[front] Edit messages and conversations branching #10771

Open
wants to merge 51 commits into
base: main
Choose a base branch
from

Conversation

tdraier
Copy link
Contributor

@tdraier tdraier commented Feb 13, 2025

Description

This PR introduces message threading and edit message functionality to conversations, allowing users to edit messages, and navigate through different versions.

Design here : https://www.notion.so/dust-tt/Design-Doc-Edit-message-19928599d94180ccbf83e75f838b4796

Feb-20-2025 09-41-02

Feb-20-2025 09-41-25

Tests

Tested message editing functionality
Verified thread version navigation
Validated UI updates and button interactions

Risk

Deploy Plan

run migration
deploy front

Copy link

github-actions bot commented Feb 13, 2025

Fails
🚫

Files in **/sdks/js/ have been modified. Changing the types defined in the SDK could break existing client.
Additions (new types, new values) are generally fine but removals are NOT OK : it would break the contract of the Public API.
Please add the sdk-ack label to acknowledge that your are not breaking the existing Public API contract.

Warnings
⚠️

Files in **/lib/models/ have been modified and the PR has the migration-ack label. Don't forget to run the migration from prodbox.

Generated by 🚫 dangerJS against b5b6be1

@tdraier tdraier added the migration-ack 📁 Label to acknowledge that a migration is required. label Feb 15, 2025
@tdraier tdraier changed the title Thomas/edit messages [front] Edit messages and conversations branching Feb 20, 2025
@tdraier tdraier marked this pull request as ready for review February 20, 2025 10:53
@tdraier tdraier requested a review from flvndvd February 20, 2025 10:54
Comment on lines +1378 to +1379
hooks: false,
silent: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we need those two here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Message has hooks and an updatedAt field, we don't want to call them here ?

ALTER TABLE "public"."messages" ADD COLUMN "nextThreadVersion" INTEGER;
ALTER TABLE "public"."messages" ADD COLUMN "previousThreadVersion" INTEGER;
ALTER TABLE "public"."messages" ADD COLUMN "threadVersions" INTEGER[] DEFAULT ARRAY[0]::INTEGER[];
CREATE UNIQUE INDEX CONCURRENTLY "messages_conversation_id_rank_version_parent_id" ON "messages" ("conversationId", "rank", "version", "parentId");
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, CREATE UNIQUE INDEX CONCURRENTLY will resolve before the index is ready, we might want to avoid deleting the existing one until this one is not fully ready.

Copy link
Contributor

Choose a reason for hiding this comment

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

This index won't be fully leverage (at least on in the legacy edit message path to find the "newest" message since version is not in the query anymore.

where: {
rank: messageRow.rank,
conversationId: conversation.id,
version: messageRow.version + 1,
parentId: messageRow.parentId,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we keep using the version here? This would avoid the need to sort afterward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

message is not necessarily the last version - we need to find the last version with this query to get the new message version

ALTER TABLE "public"."messages" ADD COLUMN "nextThreadVersion" INTEGER;
ALTER TABLE "public"."messages" ADD COLUMN "previousThreadVersion" INTEGER;
ALTER TABLE "public"."messages" ADD COLUMN "threadVersions" INTEGER[] DEFAULT ARRAY[0]::INTEGER[];
CREATE UNIQUE INDEX CONCURRENTLY "messages_conversation_id_rank_version_parent_id" ON "messages" ("conversationId", "rank", "version", "parentId");
Copy link
Contributor

Choose a reason for hiding this comment

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

This index won't be fully leverage (at least on in the legacy edit message path to find the "newest" message since version is not in the query anymore.

conversationId: conversation.id,
const lastMessage = await Message.findOne({
attributes: ["id", "rank"],
where: {
Copy link
Contributor

Choose a reason for hiding this comment

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

We do this query pretty often, any chance we can leverage GIN index (doc) to use a composite index and keep good performance here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migration-ack 📁 Label to acknowledge that a migration is required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants