refactor(desktop): memoize the directive image-segment filter

Matches the two derived values above it and fixes the indentation.
This commit is contained in:
Brooklyn Nicholson 2026-07-24 20:15:43 -05:00
parent ffbcfa1597
commit 3d2033db6b

View file

@ -354,10 +354,14 @@ export function DirectiveContent({ text }: { text: string }) {
// `@image:<path>` directives render as a block-level thumbnail row (like
// embedded base64 images below), not inline mid-text — otherwise a large
// thumbnail gets wedged between words and breaks the text's line flow.
const imageSegments = segments.filter(
(segment): segment is Extract<Unstable_DirectiveSegment, { kind: 'mention' }> =>
segment.kind === 'mention' && segment.type === 'image'
)
const imageSegments = useMemo(
() =>
segments.filter(
(segment): segment is Extract<Unstable_DirectiveSegment, { kind: 'mention' }> =>
segment.kind === 'mention' && segment.type === 'image'
),
[segments]
)
return (
<span className="whitespace-pre-line" data-slot="aui_directive-text">