Skip to content

feat(plugin-gateway): resolve messages and attachments in transformResolved - #249

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
feat/plugin-gateway-util-followups
Oct 17, 2026
Merged

kodiakhq[bot] merged 1 commit into
mainfrom
feat/plugin-gateway-util-followups

Conversation

@RedStar071

Copy link
Copy Markdown
Member

🔗 Linked issue

Refs #159 (partial: the position follow-ups remain open, so the issue stays open)

🧭 Context

#159 tracks the discord.js Util helpers @wolfstar/plugin-gateway still lacks. resolveGuildEmoji merged in #236; this PR takes the transformResolved / mentions follow-ups and settles the small leftover decisions. The computed Role#position / GuildChannel#position, fetchSorted from the cache, and relative entries on setPositions are design-heavy and left for a later PR.

📚 Description

I re-checked every checklist item and the Pullfrog findings against current main first:

  • MessagePayload file names: it already imports basename from util/Util.ts; only the URL pre-handling in the local nameOf() is separate. findName takes the last path segment of the whole string, so it would keep #fragment, name https://cdn.example/ after its host, and mis-name ?next=/a/b. The existing contract (message-payload.test.ts) requires the opposite, so I kept nameOf(), documented why, and added a query-with-slash case.
  • messages / attachments: the Pullfrog plan put them on MessageMentions, but discord.js's MessageMentions has neither. The issue text is about transformResolved (the interaction resolved payload), so they are added there: messages (IDs read from the cache of a new channelId option, raw data resolved to the cached message or built from it) and attachments (built as Attachment). Nothing is written to the cache.
  • Mentioned users from the payload: MessageMentions#users and #members already fall back to the payload. discord.js's parsedUsers only reads the cache, but discord.js caches the payload's mentioned users first, so they show up there. The message manager now hands those raw users to transformResolved, so parsedUsers includes them without writing the cache; content-only mentions stay cache-only, as in discord.js. This also feeds cleanContent.
  • GuildMemberRoleManager: left alone. discordSort(roles).reverse() gives the same order, but needs a second array copy and relies on discordSort telling roles from channels by whether the first item has a type, so it is not a simplification.
  • flatten / resolveSKUId: kept as exported public util API; resolveSKUId gets a consumer with the monetization work.

Key changes

Area Change
transformResolved New messages, attachments data and channelId context option, messages/attachments in the result
MessageManager Mentioned users are resolved from the payload when uncached, so MessageMentions#parsedUsers includes them
MessagePayload nameOf() documented as an intentional difference from findName
Tests util.test.ts, relations-messages.test.ts, message-payload.test.ts
Changeset @wolfstar/plugin-gateway minor

Still open on #159: computed sorted position with rawPosition, sorting cached channels/roles without refetching, and relative entries on setPositions.

Verification: pnpm lint (oxlint: no errors; oxfmt --check passes with CRLF line endings, as git on Windows checks files out; the LF index is normalised on commit), pnpm build, pnpm typecheck and pnpm test (121 files, 1716 tests) all pass locally.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Workflow / CI change

Pre-flight Checklist

  • I have read the Contributing Guidelines (if applicable)
  • My code follows the code style of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly
  • I added a changeset with pnpm changeset (or pnpm changeset add --empty if no release is needed). See .changeset/README.md.

🤖 AI disclosure: Claude Code was used on this PR. Code written with claude-sonnet-5-5; PR description written with claude-sonnet-5-5. AI policy.

…mentioned users

transformResolved resolves messages (IDs from the cache of the new channelId option, raw data
to the cached message or a built one) and attachments (built as Attachment), like discord.js.
MessageMentions#parsedUsers includes the users the payload mentions even when uncached, without
writing the cache. Document why MessagePayload keeps its URL-aware file name helper.
@coldtea-pr-lens

coldtea-pr-lens Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Architecture

Architecture diagram for wolfstar-project/plugins at 5d7ad9f

Play the walkthrough


Data flow

Data flow diagram for wolfstar-project/plugins at 5d7ad9f

Follow each request


Review

Nothing flagged · reviewed 5d7ad9f


Tip

Run npx @coldtea/pr-lens-cli analyze --base origin/main on a branch, then npx @coldtea/pr-lens-cli render .pr-lens/graph.json. Same lenses, your own model key, before the pull request exists

🪧 More tips
  • Run npx skills add coldteadotai/pr-lens, then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Click the link under each diagram to open it on a canvas you can zoom, pan and step through
  • The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change
  • Open a diagram on the canvas, then press W or click play to walk through the change one step at a time
  • The CLI's render reads .github/pr-lens.yml and applies your renames, exclusions and lane pins at draw time
  • Set github.comment.collapsed: true in .github/pr-lens.yml to fold the comment behind one View architecture and data flow row. Drawing still runs as before
  • Set github.draw: on-demand in .github/pr-lens.yml and PR Lens stops drawing pull requests on its own. Comment @pr-lens draw on a pull request when you want that one drawn
  • Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and your model provider's key as its api-key to run PR Lens from your own CI. Any /chat/completions endpoint works
  • After a push, tick Redraw to draw the latest commit
  • Switch GitHub to dark mode and the diagrams follow. The moving dots are this pull request's data in motion

Thanks for using PR Lens! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the full single-commit diff, plus the surrounding resolveEach, CachedManager#_resolveData, MessageMentions and Attachment code. I ran the three touched test files locally (util, relations-messages, message-payload): 65 tests pass.

  • transformResolved messages/attachments — messages read IDs from the cache of the new channelId option, and raw data resolves to the cached message or is built from the data. attachments are always built as Attachment. Nothing is written to the cache.
  • Mentioned users from the payload — MessageManager#resolveMentions now passes the payload's raw users (without member) so MessageMentions#parsedUsers and cleanContent include uncached mentioned users. _resolveData still prefers a cached copy, so a cached user wins over the payload's.
  • MessagePayload nameOf() — a comment documents why it differs from findName, and a query-with-slash test case was added.
  • Changeset — a minor bump for @wolfstar/plugin-gateway.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@kodiakhq
kodiakhq Bot merged commit e55801b into main Oct 17, 2026
19 checks passed
@kodiakhq
kodiakhq Bot deleted the feat/plugin-gateway-util-followups branch October 17, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages:plugin-gateway Changes in plugin-gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants