-
-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(userlist): click a user to open chat with @<name> prefilled #7660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
504b05b
a494307
ffe9477
f82a615
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| import padutils from './pad_utils' | ||
| const hooks = require('./pluginfw/hooks'); | ||
| const chat = require('./chat').chat; | ||
| import html10n from './vendors/html10n'; | ||
| let myUserInfo = {}; | ||
|
|
||
|
|
@@ -369,6 +370,46 @@ const paduserlist = (() => { | |
| }, 0); | ||
| }); | ||
|
|
||
| // Click any other user's row to open chat with @<their_name> prefilled. | ||
| // Helps newcomers discover the chat panel and the @-mention convention | ||
| // without having to be told. Plugins can transform the prefilled text | ||
| // — for example ep_ai_chat replaces "@AI Assistant" with the | ||
| // configured trigger ("@ai") — via the chatPrefillFromUser client | ||
| // hook (see doc/api/hooks_client-side.md). | ||
| $('#otheruserstable').on('click', 'tr[data-authorId]', async function (event) { | ||
| // Skip clicks on the color swatch — that has its own click handler | ||
| // (color-picker semantics) and shouldn't double up as a chat trigger. | ||
| if ($(event.target).closest('.usertdswatch').length) return; | ||
| const tr = $(this); | ||
| const authorId = tr.attr('data-authorId'); | ||
| if (!authorId) return; | ||
| const name = (tr.find('.usertdname').text() || '').trim(); | ||
| let prefill = name ? `@${name.replace(/\s+/g, '_')} ` : ''; | ||
| try { | ||
| const transforms = await hooks.aCallAll( | ||
| 'chatPrefillFromUser', {authorId, name, prefill}); | ||
| if (Array.isArray(transforms)) { | ||
| for (const tr2 of transforms) { | ||
| if (typeof tr2 === 'string' && tr2.length > 0) { prefill = tr2; break; } | ||
| } | ||
| } | ||
| } catch { /* never let a misbehaving plugin break the click */ } | ||
| try { chat.show(); } catch { /* */ } | ||
| setTimeout(() => { | ||
| const $input = $('#chatinput'); | ||
| if (!$input.length) return; | ||
| const current = ($input.val() || '') as string; | ||
| if (!current.trim() || /^@\S+\s*$/.test(current.trim())) { | ||
| $input.val(prefill); | ||
| } else if (!current.includes(prefill.trim())) { | ||
| $input.val(`${current.trimEnd()} ${prefill}`); | ||
| } | ||
| $input.trigger('focus'); | ||
| const elem = $input[0] as HTMLTextAreaElement; | ||
| try { elem.setSelectionRange(elem.value.length, elem.value.length); } catch (_e) { /* */ } | ||
| }, 50); | ||
| }); | ||
|
Comment on lines
+379
to
+416
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Click-to-chat lacks feature flag The new click handler on user list rows changes default behavior by opening chat and prefilling an @name mention without any feature flag gating. This violates the requirement that new features be disabled by default unless explicitly enabled. Agent Prompt
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Going with a reasoned decline on the feature-flag part of this comment. Replying so the rationale is on the record:
The other comment on this review (rename-input click steals focus) was a real bug and is fixed in |
||
|
|
||
| // color picker | ||
| $('#myswatchbox').on('click', showColorPicker); | ||
| $('#mycolorpicker .pickerswatchouter').on('click', function () { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.