Skip to content

Commit 905d438

Browse files
committed
Void fragments: render follow-up placeholders
1 parent ba3290f commit 905d438

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/apps/chat/components/message/fragments-void/BlockPartPlaceholder.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react';
33
import type { SxProps } from '@mui/joy/styles/types';
44
import { Chip } from '@mui/joy';
55
import BrushRoundedIcon from '@mui/icons-material/BrushRounded';
6+
import HourglassEmptyIcon from '@mui/icons-material/HourglassEmpty';
67
import SearchRoundedIcon from '@mui/icons-material/SearchRounded';
78

89
import { BlocksContainer } from '~/modules/blocks/BlocksContainers';
@@ -12,6 +13,7 @@ import type { DMessageRole } from '~/common/stores/chat/chat.message';
1213
import type { DVoidPlaceholderModelOp } from '~/common/stores/chat/chat.fragments';
1314
import { adjustContentScaling, ContentScaling, themeScalingMap } from '~/common/app.theme';
1415
import { DataStreamViz } from '~/common/components/DataStreamViz';
16+
import { animationSpinHalfPause } from '~/common/util/animUtils';
1517

1618

1719
// configuration
@@ -21,6 +23,21 @@ const MODELOP_TIMEOUT_LIMIT = 300; // seconds
2123

2224

2325
const _styles = {
26+
followUpChip: {
27+
px: 1.5,
28+
py: 0.375,
29+
my: '1px', // to not crop the outline on mobile, or on beam
30+
outline: '1px solid',
31+
outlineColor: 'primary.solidBg', // .outlinedBorder
32+
boxShadow: `1px 2px 4px -3px var(--joy-palette-primary-solidBg)`,
33+
} as const,
34+
35+
followUpChipIcon: {
36+
fontSize: '1rem',
37+
mr: 0.5,
38+
animation: `${animationSpinHalfPause} 2s ease-in-out infinite`,
39+
} as const,
40+
2441
opChip: {
2542
maxWidth: '100%', // fundamental for the ellipsize to work
2643
// width: '100%', // would have way less 'jumpy-ness'
@@ -92,6 +109,7 @@ function ModelOperationChip(props: {
92109

93110
export function BlockPartPlaceholder(props: {
94111
placeholderText: string,
112+
placeholderType?: 'chat-gen-follow-up',
95113
placeholderModelOp?: DVoidPlaceholderModelOp,
96114
messageRole: DMessageRole,
97115
contentScaling: ContentScaling,
@@ -122,6 +140,20 @@ export function BlockPartPlaceholder(props: {
122140
if (shouldShowViz && showVisualization)
123141
return <DataStreamViz height={1 + 8 * 4} />;
124142

143+
144+
// Type-based visualization
145+
if (props.placeholderType === 'chat-gen-follow-up') return (
146+
<Chip
147+
color='primary'
148+
variant='soft'
149+
size='sm'
150+
sx={_styles.followUpChip}
151+
startDecorator={<HourglassEmptyIcon sx={_styles.followUpChipIcon} />}
152+
>
153+
{props.placeholderText}
154+
</Chip>
155+
);
156+
125157
// Model operation renderer
126158
if (props.placeholderModelOp)
127159
return (

src/apps/chat/components/message/fragments-void/VoidFragments.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export function VoidFragments(props: {
104104
<BlockPartPlaceholder
105105
key={fId}
106106
placeholderText={part.pText}
107+
placeholderType={part.pType}
107108
placeholderModelOp={part.modelOp}
108109
messageRole={props.messageRole}
109110
contentScaling={props.contentScaling}

0 commit comments

Comments
 (0)