This commit is contained in:
Nicholas-Xiong 2026-05-31 01:23:29 -04:00 committed by GitHub
commit a53a9ed935
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 37 additions and 0 deletions

View file

@ -1962,6 +1962,37 @@ export const ChatComposer = forwardRef<ChatComposerHandle, Props>(
}}
/>
<div className="composer-tools-wrap">
<button
type="button"
className="icon-btn"
onClick={() => {
const ta = textareaRef.current;
if (!ta) return;
const cursor = ta.selectionStart;
const before = draft.slice(0, cursor);
const after = draft.slice(cursor);
const next = before + '@' + after;
setDraft(next);
// Manually open the mention popover, same as handleChange
// does when it detects a fresh @ in the typed input.
const pos = cursor + 1;
const textBefore = next.slice(0, pos);
const m = /(^|\\s)@([^\\s@]*)$/.exec(textBefore);
if (m) {
setMention({ q: m[2] ?? '', cursor: pos });
} else {
setMention(null);
}
requestAnimationFrame(() => {
ta.focus();
ta.setSelectionRange(pos, pos);
});
}}
title={t('chat.mentionButtonTitle')}
aria-label={t('chat.mentionButtonAria')}
>
<span style={{ fontFamily: 'monospace', fontSize: 15 }}>@</span>
</button>
<button
ref={toolsTriggerRef}
type="button"

View file

@ -1517,6 +1517,8 @@ export const en: Dict = {
'chat.send': 'Send',
'chat.stop': 'Stop',
'chat.removeAria': 'Remove {name}',
'chat.mentionButtonTitle': 'Mention a file',
'chat.mentionButtonAria': 'Open file mention picker',
'chat.example1Title': 'Editorial pitch deck',
'chat.example1Tag': 'Magazine',
'chat.example1Prompt':

View file

@ -1508,6 +1508,8 @@ export const zhCN: Dict = {
'chat.send': '发送',
'chat.stop': '停止',
'chat.removeAria': '移除 {name}',
'chat.mentionButtonTitle': '引用文件',
'chat.mentionButtonAria': '打开文件引用选择器',
'chat.example1Title': '编辑风路演 PPT',
'chat.example1Tag': '杂志',
'chat.example1Prompt':

View file

@ -1842,6 +1842,8 @@ export interface Dict {
'chat.send': string;
'chat.stop': string;
'chat.removeAria': string;
'chat.mentionButtonTitle': string;
'chat.mentionButtonAria': string;
'chat.example1Title': string;
'chat.example1Tag': string;
'chat.example1Prompt': string;