Skip to content

fix: don't drop role_mentions when hydrating messages - #181

Merged
Dadadah merged 1 commit into
stoatchat:mainfrom
GalaxyAkiii:main
Aug 8, 2026
Merged

fix: don't drop role_mentions when hydrating messages#181
Dadadah merged 1 commit into
stoatchat:mainfrom
GalaxyAkiii:main

Conversation

@GalaxyAkiii

@GalaxyAkiii GalaxyAkiii commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

keyMapping in src/hydration/message.ts was missing an entry for role_mentions, causing the field to be silently dropped on every message.

hydrateInternal maps incoming payload keys through keyMapping[key] ?? key before calling functions[targetKey]. Without an entry in keyMapping, 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, roleMentionIds was never populated and the extractor function right below the mapping was completely bypassed. Message.roleMentions therefore always returned undefined, and Message.mentioned - which checks roleMentions?.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-web vendors this package as a submodule and will need its reference updated after this lands.

How was this PR tested?

  • Ran hydrate() against a message payload containing both mentions and role_mentions. Previously, this output roleMentionIds: undefined alongside the "Skipping key role_mentions" log; with this change, it populates roleMentionIds: ["01RRR..."]. Standard user mentions remained unaffected.
  • Built the package and loaded it in the web client: verified that messages mentioning a role I hold now trigger the expected highlight, and the skipped-key log is gone.
  • Ran tsc --noEmit and prettier --check (both passed clean).

Screenshots & Screencasts (if appropriate)

Active Session on Stoat Chat Desktop Client on Same Account
Screenshot 2026-08-08 at 1 10 17 PM

Web Client Session with Fix Applied
Screenshot 2026-08-08 at 1 08 57 PM

Checklist:

  • I have carefully read the contributing guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR
  • I have confirmed that any new dependencies are strictly necessary
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code

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.

`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>
@Dadadah

Dadadah commented Aug 8, 2026

Copy link
Copy Markdown
Member

Thanks for investigating this!

@Dadadah
Dadadah merged commit 836ae4c into stoatchat:main Aug 8, 2026
4 checks passed
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.

2 participants