Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

Skip @-mentions inside `>` markdown blockquotes in parseMentions

wyt061ad4c77e3b
diff --git a/src/main/features/group_chat/router.ts b/src/main/features/group_chat/router.ts
index 7ac83274..ae38446c 100644
--- a/src/main/features/group_chat/router.ts
+++ b/src/main/features/group_chat/router.ts
@@ -72,11 +72,24 @@ export function parseMentions(
): string[] {
if (!text) return [];
if (opts?.fromKind && opts.fromKind !== 'user') return [];
+ // Markdown blockquote lines (`> ...`) are context the user pulled in
+ // from another bubble via the quote-reply feature. `@<name>` tokens
+ // inside the quote belong to the original author's outgoing routing,
+ // not the current user's — counting them as dispatch signals
+ // re-triggers whoever the original message addressed every time
+ // someone forwards it. Strip those lines from the routing-relevant
+ // view; the original `text` still flows through the bus unchanged so
+ // the persisted bubble keeps the quote intact.
+ const routingText = text
+ .split('\n')
+ .filter((line) => !/^\s*>/.test(line))
+ .join('\n');
+ if (!routingText) return [];
const re = _buildMentionRe(opts?.names);
const out: string[] = [];
const seen = new Set<string>();
let m: RegExpExecArray | null;
- while ((m = re.exec(text)) !== null) {
+ while ((m = re.exec(routingText)) !== null) {
const token = m[2];
if (!token || seen.has(token)) continue;
seen.add(token);
diff --git a/test/main/features/group_chat/router.test.ts b/test/main/features/group_chat/router.test.ts
index de6ed4f0..d26b325d 100644
--- a/test/main/features/group_chat/router.test.ts
+++ b/test/main/features/group_chat/router.test.ts
@@ -54,6 +54,26 @@ describe('group_chat router › parseMentions', () => {
// 缺省 fromKind 等价老行为(向后兼容)
expect(parseMentions(text)).toEqual(['需求挖掘师', '全面评估师']);
});
+
+ // Quote-reply prepends the quoted bubble's body as `> ...` blockquote
+ // lines. `@<name>` inside that quote refers to the original author's
+ // dispatch — re-routing to it whenever someone forwards the bubble
+ // is wrong (the user's intent is in their own typed prose, not in the
+ // pasted-in context). Lines starting with `>` are stripped from the
+ // routing-relevant view.
+ it('ignores @-mentions inside `>` blockquote lines (quote-reply context)', () => {
+ // Pure quote, no body → no mentions parsed (default routing applies upstream).
+ expect(parseMentions('> hi @alice')).toEqual([]);
+ // Quote contains @, body has its own @ → only the body's @ counts.
+ expect(parseMentions('> previous reply mentioned @alice\n@bob please review'))
+ .toEqual(['bob']);
+ // Multi-line quote, multiple @s ignored; user's plain @ kept.
+ expect(parseMentions('> line one @x\n> line two @y\nfinal: @z'))
+ .toEqual(['z']);
+ // Leading whitespace before `>` (some clients indent quotes).
+ expect(parseMentions(' > @alice from somewhere\nplain @bob'))
+ .toEqual(['bob']);
+ });
});
describe('group_chat router › resolveRecipients', () => {