Skip to content

AI SDK client side id generation creates out of sync frontend state #7

@Andrew-Chen-Wang

Description

@Andrew-Chen-Wang

The example repository (see here

await upsertMessage({ chatId, id: message.id, message });
) seems to accept the client side ID of the user written message which doesn't seem safe.

My assumption is that in the example repository, you could rewrite the submitted message ID to your own ID, but then your frontend would be out of sync -- I assume that's fine though. What doesn't make sense is, if you generate the ID for the user ID and send it back as per the doc (

writer.write({
type: "start",
messageId: generateId(),
});
writer.write({
type: "start-step",
});
), then the frontend state is out of sync.

Please advise @nicoalbanese

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions