fix: don't drop role_mentions when hydrating messages - #181
Merged
Conversation
`hydrateInternal` resolves incoming payload keys using `keyMapping[key] ?? key` before invoking `functions[targetKey]`. Because `keyMapping` included entries for `mentions` and `replies` but missed `role_mentions`, the target key remained as its raw API string (`role_mentions`). Since no matching handler function existed under that name, it threw an error that was silently caught and logged as "Skipping key ... during hydration!". Because of this missing mapping, `roleMentionIds` was never populated during hydration and its extractor function went completely unused. Any code relying on it received `undefined`. Specifically, `Message.mentioned` checks `roleMentions?.some((role) => role.assigned)`, which meant it could never return true for role-based mentions. Adding `role_mentions` to the key mapping allows the existing extractor function to run as intended. Signed-off-by: Aki <aki@akiworks.xyz> Signed-off-by: Aki <aki@akiworks.xyz>
Member
|
Thanks for investigating this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
keyMappinginsrc/hydration/message.tswas missing an entry forrole_mentions, causing the field to be silently dropped on every message.hydrateInternalmaps incoming payload keys throughkeyMapping[key] ?? keybefore callingfunctions[targetKey]. Without an entry inkeyMapping, the key stayed as the raw API string (role_mentions). Since no handler existed under that name, it threw an error that got caught and swallowed by the fallback log ("Skipping key ... during hydration!").As a result,
roleMentionIdswas never populated and the extractor function right below the mapping was completely bypassed.Message.roleMentionstherefore always returnedundefined, andMessage.mentioned- which checksroleMentions?.some((role) => role.assigned)- could never evaluate to true for role mentions.Adding the missing mapping lets the existing extractor run as expected.
Related to stoatchat/for-web#1461. This won't automatically close that issue, since
for-webvendors this package as a submodule and will need its reference updated after this lands.How was this PR tested?
hydrate()against a message payload containing bothmentionsandrole_mentions. Previously, this outputroleMentionIds: undefinedalongside the "Skipping key role_mentions" log; with this change, it populatesroleMentionIds: ["01RRR..."]. Standard user mentions remained unaffected.tsc --noEmitandprettier --check(both passed clean).Screenshots & Screencasts (if appropriate)
Active Session on Stoat Chat Desktop Client on Same Account

Web Client Session with Fix Applied

Checklist:
Please declare, if any, LLM usage involved in creating this PR
None - Updated to remove em dashes placed automatically by Grammarly. No AI used in PR or Coding.