Skip to content

The agent that grows with you

fix(desktop): preserve quoted reference punctuation

Denis H4e8b7a71c718
diff --git a/apps/desktop/src/components/assistant-ui/directive-text.test.ts b/apps/desktop/src/components/assistant-ui/directive-text.test.ts
index 0c065725b35..e34a7fbceee 100644
--- a/apps/desktop/src/components/assistant-ui/directive-text.test.ts
+++ b/apps/desktop/src/components/assistant-ui/directive-text.test.ts
@@ -39,6 +39,22 @@ describe('hermesDirectiveFormatter.parse', () => {
])
})
+ it('preserves punctuation inside quoted values but trims bare sentence punctuation', () => {
+ const quoted = hermesDirectiveFormatter.parse('see @file:`report!` now')
+ const bare = hermesDirectiveFormatter.parse('see @file:report! now')
+
+ expect(quoted).toEqual([
+ { kind: 'text', text: 'see ' },
+ { kind: 'mention', type: 'file', label: 'report!', id: 'report!' },
+ { kind: 'text', text: ' now' }
+ ])
+ expect(bare).toEqual([
+ { kind: 'text', text: 'see ' },
+ { kind: 'mention', type: 'file', label: 'report', id: 'report' },
+ { kind: 'text', text: ' now' }
+ ])
+ })
+
it('parses session links with profile/id values', () => {
const segments = hermesDirectiveFormatter.parse('see @session:work/20260101_abc123 next')
diff --git a/apps/desktop/src/components/assistant-ui/reference-kinds.ts b/apps/desktop/src/components/assistant-ui/reference-kinds.ts
index f30f86a696f..51b5976d37a 100644
--- a/apps/desktop/src/components/assistant-ui/reference-kinds.ts
+++ b/apps/desktop/src/components/assistant-ui/reference-kinds.ts
@@ -210,7 +210,14 @@ export function unquoteReferenceValue(raw: string): string {
: raw
}
-/** Remove optional wire-format quotes and terminal prose punctuation from a reference value. */
+/**
+ * Remove wire-format quotes; bare directives also shed terminal prose punctuation.
+ *
+ * Punctuation inside a quoted value is part of that value, while a bare
+ * `@file:report!` retains the historical sentence-boundary behavior.
+ */
export function unwrapReferenceValue(raw: string): string {
- return unquoteReferenceValue(raw).replace(/[,.;!?]+$/, '')
+ const value = unquoteReferenceValue(raw)
+
+ return value === raw ? value.replace(/[,.;!?]+$/, '') : value
}