Skip to content

feat: click a user in the user list to prefill an @-mention in chat#19

Merged
JohnMcLear merged 1 commit intomainfrom
feat/click-user-prefill-mention
May 3, 2026
Merged

feat: click a user in the user list to prefill an @-mention in chat#19
JohnMcLear merged 1 commit intomainfrom
feat/click-user-prefill-mention

Conversation

@JohnMcLear
Copy link
Copy Markdown
Member

@JohnMcLear JohnMcLear commented May 2, 2026

Summary

Override the default @<name> chat-input prefill with the configured AI trigger (@ai by default) when a user clicks the AI's row in the user list.

This used to be a self-contained user-list click handler inside this plugin. Per review, the generic "click a user → prefill @-mention" behavior belongs in Etherpad core, since it's a discoverability win for any multi-user pad. That generic feature is now ether/etherpad#7660, which adds the chatPrefillFromUser client hook.

This PR is now the small, AI-specific consumer of that hook.

Depends on

ether/etherpad#7660 — must merge first. On older cores this PR is a no-op (the hook is never fired).

What this PR does

  • clientVars server hook — exposes { trigger, authorName, authorId } under clientVars.ep_ai_chat.
  • chatPrefillFromUser client hook — when the clicked authorId is the AI's, returns the trigger string. Otherwise returns nothing and core's default wins.

~18 lines of glue.

Test plan (after #7660 merges)

  • Click another user in the userlist → core opens chat, prefills @<name> .
  • Click the AI's row → this plugin overrides to @ai .
  • On a core without #7660: clicking a user is a benign no-op.

@qodo-code-review
Copy link
Copy Markdown

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

JohnMcLear added a commit that referenced this pull request May 2, 2026
…ndler

PR #19 originally landed an entire user-list click handler inside
ep_ai_chat. That logic was generic — clicking a user in the user
list to prefill an @-mention is a discoverability win for any
multi-user pad, AI or no AI — and as @JohnMcLear pointed out, it
belongs in Etherpad core, not in this plugin.

The generic feature is now ether/etherpad#7660. This commit shrinks
ep_ai_chat's contribution to the only AI-specific bit: when the
clicked author is the AI, override the default "@AI_Assistant "
prefill with the configured trigger ("@ai " by default) so the
input lands in a useful state.

Implementation:
- Drop the in-plugin click delegation, the chatbox/chaticon DOM
  poking, and the input-prefill logic. Core handles all of that
  uniformly now.
- Add a chatPrefillFromUser client hook that returns the trigger
  string when the clicked authorId matches the AI's. The clientVars
  hook (added earlier in this PR) still exposes the trigger and
  authorId; nothing changes there.
- On older cores the new hook is never fired, so this is a no-op
  on a stock install — graceful degradation.

Net diff vs main is now: a tiny clientVars exposure on the server
and a ~10-line client hook handler. Everything else is core's job.
…lay name

Override the default "@<name> " chat-input prefill with the configured
AI trigger ("@ai " by default) when a user clicks the AI's row in the
user list. Without this, clicking the AI chip would prefill
"@AI_Assistant ", which doesn't match anything the server-side mention
extractor recognises.

What this PR adds:
- clientVars server hook exposing { trigger, authorName, authorId } at
  clientVars.ep_ai_chat so the client can recognise the AI's row.
- chatPrefillFromUser client hook that returns the trigger string when
  the clicked authorId matches the AI's; otherwise returns nothing so
  core's default ("@<name> ") wins.
- Mocha unit test (static/tests/backend/specs/chat_prefill.ts) covering
  AI/non-AI/missing-clientVars/custom-trigger/missing-trigger paths.

Depends on ether/etherpad#7660 which adds the chatPrefillFromUser hook
to core. On older cores the hook is never fired and this PR is a
benign no-op — graceful degradation, no install requirement bump.

Originally this PR shipped the entire user-list click handler inside
the plugin. Per review feedback, the generic "click a user → prefill
@-mention" UX belongs in core (it's a discoverability win for any
multi-user pad, AI or no AI), so the bulk moved to ether/etherpad#7660
and this PR is now ~40 lines of glue.

(Replaces the previous 3-commit history on this branch with a clean
rebase against the new main, which absorbed PRs #18 and #20 since the
branch was opened.)
@JohnMcLear JohnMcLear force-pushed the feat/click-user-prefill-mention branch from bf549f7 to 68cce00 Compare May 3, 2026 04:46
@JohnMcLear JohnMcLear merged commit 132a1e7 into main May 3, 2026
3 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant