From 03eec23efe6155f85637542c4f0a2d964ab33dfd Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Fri, 13 Mar 2026 14:02:31 -0700 Subject: [PATCH] BlockOpOptions: supports bold options --- .../components/message/BlockOpOptions.tsx | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/apps/chat/components/message/BlockOpOptions.tsx b/src/apps/chat/components/message/BlockOpOptions.tsx index a32454251..b727363ad 100644 --- a/src/apps/chat/components/message/BlockOpOptions.tsx +++ b/src/apps/chat/components/message/BlockOpOptions.tsx @@ -36,7 +36,7 @@ const optionGroupSx: SxProps = { flexDirection: 'column', alignItems: 'flex-start', gap: 0, -}; +} as const; const optionSx: SxProps = { // style @@ -52,7 +52,19 @@ const optionSx: SxProps = { // layout justifyContent: 'flex-start', -}; +} as const; + +const optionBoldSx: SxProps = { + ...optionSx, + fontWeight: 'lg', +} as const; + + +// "**text** -> text +function _stripMarkdownBold(text: string): { text: string; isBold: boolean } { + const stripped = text.replace(/^(\*{2,})(.+)\1$/, '$2'); + return { text: stripped, isBold: stripped !== text }; +} export function optionsExtractFromFragments_dangerModifyFragment(enabled: boolean, fragments: InterleavedFragment[]): { fragments: InterleavedFragment[], options: string[] } { @@ -164,21 +176,25 @@ export function BlockOpOptions(props: { options: string[], onContinue: (continueText: null | string) => void, }) { - const buttonSx = React.useMemo(() => ({ ...optionSx, fontSize: props.contentScaling }), [props.contentScaling]); + const normalSx = React.useMemo(() => ({ ...optionSx, fontSize: props.contentScaling }), [props.contentScaling]); + const boldSx = React.useMemo(() => ({ ...optionBoldSx, fontSize: props.contentScaling }), [props.contentScaling]); return ( - {props.options.map((option, index) => ( - - ))} + {props.options.map((option, index) => { + const { text, isBold } = _stripMarkdownBold(option); + return ( + + ); + })} ); }