Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
Fix: chat names contain raw mention data (#1784)
Eric Hayesf023f0252d0d
diff --git a/js/app/packages/app/component/SoupChatInput.tsx b/js/app/packages/app/component/SoupChatInput.tsxindex ac3cdc008e..1a7e179c26 100644--- a/js/app/packages/app/component/SoupChatInput.tsx+++ b/js/app/packages/app/component/SoupChatInput.tsx@@ -11,6 +11,7 @@ import { setPendingSendData } from '@core/component/AI/signal/pendingSend';import { ENABLE_SNAPSHOT_NODE } from '@core/constant/featureFlags';import { TOKENS } from '@core/hotkey/tokens';import { isErr } from '@core/util/maybeResult';+import { markdownToPlainText } from '@lexical-core/utils/parsers';import { cognitionApiServiceClient } from '@service-cognition/client';import { ChatInput } from 'core/component/AI/component/input/ChatInput';import { registerHotkey, useHotkeyDOMScope } from 'core/hotkey/hotkeys';@@ -58,10 +59,12 @@ function SoupChatInputInner() {function deriveChatName(userQuery: string): string | undefined {const MAX_LENGTH = 80;- const firstLine = userQuery+ const plainText = markdownToPlainText(userQuery);+ const firstLine = plainText.split('\n').map((line) => line.trim()).filter((line) => line.length > 0)[0];+ console.log('DERIVED CHAT NAME', firstLine);return firstLine ? firstLine.slice(0, MAX_LENGTH) : undefined;}diff --git a/js/app/packages/lexical-core/utils/parsers.ts b/js/app/packages/lexical-core/utils/parsers.tsindex 73b971fdff..ed9427379d 100644--- a/js/app/packages/lexical-core/utils/parsers.ts+++ b/js/app/packages/lexical-core/utils/parsers.ts@@ -73,6 +73,37 @@ export function parseGroupMentions(text: string): string {);}+export function parseDocumentCards(text: string): string {+ return text.replace(+ /<m-document-card>(.*?)<\/m-document-card>/g,+ (_, json) => {+ try {+ const data = JSON.parse(json);+ return data.documentName || '';+ } catch {+ return '';+ }+ }+ );+}++export function parseSnapshots(text: string): string {+ return text.replace(/<m-snapshot>(.*?)<\/m-snapshot>/g, (_, encoded) => {+ try {+ // Decode base64 (may also be raw JSON for backward compat)+ const jsonStr = encoded.startsWith('{')+ ? encoded+ : new TextDecoder().decode(+ Uint8Array.from(atob(encoded), (c) => c.charCodeAt(0))+ );+ const data = JSON.parse(jsonStr);+ return data.documentName || '';+ } catch {+ return '';+ }+ });+}+/*** Converts markdown text with XML mention tags to plain text.* Extracts the readable text from mention nodes:@@ -80,14 +111,20 @@ export function parseGroupMentions(text: string): string {* - Contact mentions: name (fallback to emailOrDomain)* - Date mentions: displayFormat* - Document mentions: documentName+ * - Document cards: documentName+ * - Snapshots: documentName (base64-encoded payload)* - Group mentions: @groupAlias (e.g., @here)* - Links: text (fallback to url)*/export function markdownToPlainText(markdown: string): string {return parseLinks(- parseDocumentMentions(- parseGroupMentions(- parseDateMentions(parseContactMentions(parseUserMentions(markdown)))+ parseDocumentCards(+ parseSnapshots(+ parseDocumentMentions(+ parseGroupMentions(+ parseDateMentions(parseContactMentions(parseUserMentions(markdown)))+ )+ ))));