refac
This commit is contained in:
1 parent
396d9ac181
commit
e6d35fc4cc
1 file changed
+2
-37
@@ -2516,44 +2516,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse skill mentions (<$skillId|label>) from user messages
|
// Menu-selected skills are sent as IDs; inline <$skillId|label> mentions stay
|
||||||
const skillMentionRegex = /<\$([^|>]+)\|?[^>]*>/g;
|
// in the message so the backend can inject their full content.
|
||||||
const skillIds = [...selectedSkillIds];
|
const skillIds = [...selectedSkillIds];
|
||||||
const mentionSkillIds = [];
|
|
||||||
for (const message of messages) {
|
|
||||||
const content =
|
|
||||||
typeof message.content === 'string' ? message.content : (message.content?.[0]?.text ?? '');
|
|
||||||
for (const match of content.matchAll(skillMentionRegex)) {
|
|
||||||
if (!mentionSkillIds.includes(match[1])) {
|
|
||||||
mentionSkillIds.push(match[1]);
|
|
||||||
}
|
|
||||||
if (!skillIds.includes(match[1])) {
|
|
||||||
skillIds.push(match[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strip skill mentions from message content
|
|
||||||
if (mentionSkillIds.length > 0) {
|
|
||||||
messages = messages.map((message) => {
|
|
||||||
if (typeof message.content === 'string') {
|
|
||||||
return {
|
|
||||||
...message,
|
|
||||||
content: message.content.replace(/<\$[^>]+>/g, '').trim()
|
|
||||||
};
|
|
||||||
} else if (Array.isArray(message.content)) {
|
|
||||||
return {
|
|
||||||
...message,
|
|
||||||
content: message.content.map((part) =>
|
|
||||||
part.type === 'text'
|
|
||||||
? { ...part, text: part.text.replace(/<\$[^>]+>/g, '').trim() }
|
|
||||||
: part
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the user-selected terminal from the dropdown
|
// Use the user-selected terminal from the dropdown
|
||||||
const activeTerminalId = $selectedTerminalId ?? null;
|
const activeTerminalId = $selectedTerminalId ?? null;
|
||||||
|
|||||||
Reference in new issue
Block a user