Skip to content

feat: dynamically track mutability of messages#6367

Merged
Mm2PL merged 5 commits intoChatterino:masterfrom
Nerixyz:feat/track-mutable
Aug 4, 2025
Merged

feat: dynamically track mutability of messages#6367
Mm2PL merged 5 commits intoChatterino:masterfrom
Nerixyz:feat/track-mutable

Conversation

@Nerixyz
Copy link
Copy Markdown
Contributor

@Nerixyz Nerixyz commented Aug 2, 2025

This adds a flag to Message (frozen) that indicates that it shouldn't be modified anymore. This is set once it gets added to a channel.

Why?
Plugins (#6353). Consider the following:

  • Create a message msg
  • Add msg to some channel
  • (some time later) add an element to msg or modify it in some other way
    We don't allow this because we assume messages are immutable (except flags) once they're in a channel. Technically, this is also possible in C++. We can't enforce this statically - mutable messages are std::shared_ptr<Message> and immutable ones are std::shared_ptr<const Message>. There can be const and non-const pointers to the same message at the same time.
    In Lua, we need to check this invariant.

Copy link
Copy Markdown
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

CC @Mm2PL

@Mm2PL Mm2PL self-requested a review August 2, 2025 11:51
Copy link
Copy Markdown
Collaborator

@Mm2PL Mm2PL left a comment

Choose a reason for hiding this comment

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

Code seems good. I just want some more clarification in the comment

Comment thread src/messages/Message.hpp
@Mm2PL Mm2PL enabled auto-merge (squash) August 4, 2025 18:31
@Mm2PL Mm2PL merged commit 4ffdc2f into Chatterino:master Aug 4, 2025
18 checks passed
@Nerixyz Nerixyz deleted the feat/track-mutable branch August 4, 2025 19:09
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.

3 participants