Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(soup): truncate long sender names and overflowing call snippets (#2965)

gbirmane74b41f353f9
diff --git a/js/app/packages/core/util/searchHighlight.tsx b/js/app/packages/core/util/searchHighlight.tsx
index d4dc523dca..e097196865 100644
--- a/js/app/packages/core/util/searchHighlight.tsx
+++ b/js/app/packages/core/util/searchHighlight.tsx
@@ -122,8 +122,14 @@ export function windowSearchMatch(text: string, chars: number): string {
: line
.slice(lastCloseIndex + macroClose.length)
.replace(/<\/?macro_em>/g, '').length;
+ const visibleMatch =
+ lastCloseIndex === -1
+ ? 0
+ : line
+ .slice(tagIndex, lastCloseIndex + macroClose.length)
+ .replace(/<\/?macro_em>/g, '').length;
- const totalBudget = chars * 2;
+ const totalBudget = Math.max(0, chars * 2 - visibleMatch);
const frontKeep = Math.max(chars, totalBudget - visibleAfter);
const backKeep = Math.max(chars, totalBudget - visibleBefore);
diff --git a/js/app/packages/entity/src/components/DisplayName.tsx b/js/app/packages/entity/src/components/DisplayName.tsx
index 5493fa8496..e593d26a23 100644
--- a/js/app/packages/entity/src/components/DisplayName.tsx
+++ b/js/app/packages/entity/src/components/DisplayName.tsx
@@ -1,20 +1,23 @@
import { tryMacroId, useDisplayNameParts } from '@core/user';
+const DEFAULT_MAX_CHARS = 30;
+
export function DisplayName(props: {
id: string;
format?: 'firstName' | 'lastName' | 'fullName';
+ maxChars?: number;
}) {
const name = () => {
const parts = useDisplayNameParts(tryMacroId(props.id));
const format = props.format ?? 'fullName';
- if (format === 'fullName') {
- return parts.fullName();
- }
+ const raw =
+ format === 'fullName'
+ ? parts.fullName()
+ : parts[format]() || parts.fullName();
- // For firstName or lastName, fall back to fullName if empty
- const requestedPart = parts[format]();
- return requestedPart || parts.fullName();
+ const max = props.maxChars ?? DEFAULT_MAX_CHARS;
+ return raw.length > max ? `${raw.slice(0, max)}…` : raw;
};
return <>{name()}</>;
diff --git a/js/app/packages/entity/src/composed/list-entity/call.tsx b/js/app/packages/entity/src/composed/list-entity/call.tsx
index 2a0fec42eb..c5709e363c 100644
--- a/js/app/packages/entity/src/composed/list-entity/call.tsx
+++ b/js/app/packages/entity/src/composed/list-entity/call.tsx
@@ -177,7 +177,7 @@ export function CallWideContent(props: {
</span>
<div
ref={props.setContainerRef}
- class="text-ink/50 font-medium flex-1 min-w-0 overflow-hidden"
+ class="text-ink/50 font-medium flex-1 min-w-0 truncate"
>
<HitSnippet content={h().content} chars={props.chars} />
</div>