Skip to content

feat(ChatMessages): expose registerMessageRef#6275

Open
zAlweNy26 wants to merge 4 commits intonuxt:v4from
zAlweNy26:feat/expose-message-ref
Open

feat(ChatMessages): expose registerMessageRef#6275
zAlweNy26 wants to merge 4 commits intonuxt:v4from
zAlweNy26:feat/expose-message-ref

Conversation

@zAlweNy26
Copy link
Copy Markdown
Contributor

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

To be able to reuse the scroll logic even when the default slot is used

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@github-actions github-actions Bot added the v4 #4488 label Mar 31, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 956de80e-cc90-4b8d-9adb-1d82ea1307e7

📥 Commits

Reviewing files that changed from the base of the PR and between 4f1fd8e and c0daa17.

📒 Files selected for processing (2)
  • docs/content/docs/2.components/chat-messages.md
  • src/runtime/components/ChatMessages.vue
✅ Files skipped from review due to trivial changes (1)
  • docs/content/docs/2.components/chat-messages.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/runtime/components/ChatMessages.vue

📝 Walkthrough

Walkthrough

The ChatMessages component now exposes an internal method registerMessageRef(id: string, element: ComponentPublicInstance | null): void via defineExpose, and passes it into the default slot as a required slot prop (registerMessageRef). Slot typings were updated to require this prop, and documentation was added/updated with an "Expose" section describing the method and its signature.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature: exposing the registerMessageRef method from the ChatMessages component.
Description check ✅ Passed The description explains the purpose of the change (reusing scroll logic with the default slot) and confirms documentation updates, relating appropriately to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/content/docs/2.components/chat-messages.md`:
- Line 448: The table cell for the `registerMessageRef` signature is broken by
the unescaped union pipe in `ComponentPublicInstance | null`; update the table
entry for `registerMessageRef(id: string, element: ComponentPublicInstance |
null)` to escape the pipe (e.g., `ComponentPublicInstance \| null`) so the `|`
is not treated as a Markdown column separator and the table renders correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 14812679-c85d-4832-a30b-2ea371b946c8

📥 Commits

Reviewing files that changed from the base of the PR and between ef5959f and 6c69f16.

📒 Files selected for processing (2)
  • docs/content/docs/2.components/chat-messages.md
  • src/runtime/components/ChatMessages.vue

Comment thread docs/content/docs/2.components/chat-messages.md Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 31, 2026

npm i https://pkg.pr.new/@nuxt/ui@6275

commit: c0daa17

zAlweNy26 and others added 3 commits April 11, 2026 15:51
@zAlweNy26 zAlweNy26 force-pushed the feat/expose-message-ref branch from d1913ee to 4f1fd8e Compare April 11, 2026 13:52
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/runtime/components/ChatMessages.vue`:
- Line 70: The slot prop type for registerMessageRef is too narrow and the ref
cleanup is missing; update the slot signature for default (and the other
occurrence referenced) so registerMessageRef accepts Element |
ComponentPublicInstance | null, and modify the implementation of
registerMessageRef (the function that currently stores refs in the message refs
map around the code handling lines ~127–132 and the similar block at ~319) to
delete the map entry when the callback receives null (i.e., on unmount) instead
of leaving stale entries; ensure you update both the type declarations and the
runtime logic that adds/removes entries in the refs map (refer to
registerMessageRef and the message refs map usage).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e34604dd-809a-455b-8542-74a84f20f6d7

📥 Commits

Reviewing files that changed from the base of the PR and between d1913ee and 4f1fd8e.

📒 Files selected for processing (2)
  • docs/content/docs/2.components/chat-messages.md
  • src/runtime/components/ChatMessages.vue
✅ Files skipped from review due to trivial changes (1)
  • docs/content/docs/2.components/chat-messages.md

Comment thread src/runtime/components/ChatMessages.vue
:style="{ '--last-message-height': `${lastMessageHeight}px` }"
>
<slot>
<slot :register-message-ref="registerMessageRef">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need to expose this in default slot? Isn't it enough to access it through a template ref? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Personally, I’d prefer to avoid creating a template ref every time I need one when I’m dealing with simpler cases. I see the template ref as necessary for more complex scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants