From 5a4715e6084ecd95485efb96ff72dfd71ca2c950 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Mon, 12 Aug 2024 22:24:28 -0700 Subject: [PATCH] Uniformly use `isMobile: boolean` --- src/apps/chat/components/message/ChatMessage.tsx | 3 ++- .../DocAttachmentFragment.tsx | 5 +++-- .../DocumentAttachmentFragments.tsx | 2 +- .../message/fragments-content/ContentFragments.tsx | 2 ++ .../fragments-content/ContentPartPlaceholder.tsx | 1 + .../ContentPartText_AutoBlocks.tsx | 2 ++ src/apps/draw/gallery/ZeroGallery.tsx | 14 ++++++++++++-- src/apps/settings-modal/ShortcutsModal.tsx | 8 +++++--- src/common/components/ExplainerCarousel.tsx | 5 ++++- src/modules/aifn/digrams/DiagramsModal.tsx | 1 + src/modules/beam/gather/BeamFusionGrid.tsx | 1 + src/modules/beam/gather/Fusion.tsx | 2 ++ .../instructions/ChatGenerateInstruction.tsx | 5 ++++- src/modules/beam/scatter/BeamRay.tsx | 4 +++- src/modules/beam/scatter/BeamRayGrid.tsx | 1 + src/modules/blocks/AutoBlocksRenderer.tsx | 4 +++- 16 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/apps/chat/components/message/ChatMessage.tsx b/src/apps/chat/components/message/ChatMessage.tsx index 5db295c08..c99b41a17 100644 --- a/src/apps/chat/components/message/ChatMessage.tsx +++ b/src/apps/chat/components/message/ChatMessage.tsx @@ -103,7 +103,7 @@ export function ChatMessage(props: { diffPreviousText?: string, fitScreen: boolean, hasInReferenceTo?: boolean; - isMobile?: boolean, + isMobile: boolean, isBottom?: boolean, isImagining?: boolean, isSpeaking?: boolean, @@ -621,6 +621,7 @@ export function ChatMessage(props: { contentScaling={adjContentScaling} fitScreen={props.fitScreen} + isMobile={props.isMobile} messageOriginLLM={messageOriginLLM} messageRole={messageRole} optiAllowSubBlocksMemo={!!messagePendingIncomplete} diff --git a/src/apps/chat/components/message/fragments-attachment-doc/DocAttachmentFragment.tsx b/src/apps/chat/components/message/fragments-attachment-doc/DocAttachmentFragment.tsx index f8f2e2dd1..57ef73d97 100644 --- a/src/apps/chat/components/message/fragments-attachment-doc/DocAttachmentFragment.tsx +++ b/src/apps/chat/components/message/fragments-attachment-doc/DocAttachmentFragment.tsx @@ -37,7 +37,7 @@ export function DocAttachmentFragment(props: { setEditedText: (fragmentId: DMessageFragmentId, value: string) => void, messageRole: DMessageRole, contentScaling: ContentScaling, - isMobile?: boolean, + isMobile: boolean, zenMode: boolean, disableMarkdownText: boolean, onFragmentDelete: (fragmentId: DMessageFragmentId) => void, @@ -90,7 +90,7 @@ export function DocAttachmentFragment(props: { const { liveFileControlButton, liveFileActions } = useLiveFileSync( fragment.liveFileId ?? null, workspaceId, - props.isMobile === true, + props.isMobile, fragmentDocPart.data.text, handleReplaceDocFragmentText, handleReplaceFragmentLiveFileId, @@ -277,6 +277,7 @@ export function DocAttachmentFragment(props: { fromRole={props.messageRole} contentScaling={props.contentScaling} fitScreen={props.isMobile} + isMobile={props.isMobile} codeRenderVariant='plain' textRenderVariant={props.disableMarkdownText ? 'text' : 'markdown'} /> diff --git a/src/apps/chat/components/message/fragments-attachment-doc/DocumentAttachmentFragments.tsx b/src/apps/chat/components/message/fragments-attachment-doc/DocumentAttachmentFragments.tsx index 469972376..2d26f9e6f 100644 --- a/src/apps/chat/components/message/fragments-attachment-doc/DocumentAttachmentFragments.tsx +++ b/src/apps/chat/components/message/fragments-attachment-doc/DocumentAttachmentFragments.tsx @@ -19,7 +19,7 @@ export function DocumentAttachmentFragments(props: { attachmentFragments: DMessageAttachmentFragment[], messageRole: DMessageRole, contentScaling: ContentScaling, - isMobile?: boolean, + isMobile: boolean, zenMode: boolean, disableMarkdownText: boolean, onFragmentDelete: (fragmentId: DMessageFragmentId) => void, diff --git a/src/apps/chat/components/message/fragments-content/ContentFragments.tsx b/src/apps/chat/components/message/fragments-content/ContentFragments.tsx index f6db76392..0133b9403 100644 --- a/src/apps/chat/components/message/fragments-content/ContentFragments.tsx +++ b/src/apps/chat/components/message/fragments-content/ContentFragments.tsx @@ -45,6 +45,7 @@ export function ContentFragments(props: { contentScaling: ContentScaling, fitScreen: boolean, + isMobile: boolean, messageOriginLLM?: string, messageRole: DMessageRole, optiAllowSubBlocksMemo?: boolean, @@ -173,6 +174,7 @@ export function ContentFragments(props: { messageOriginLLM={props.messageOriginLLM} contentScaling={props.contentScaling} fitScreen={props.fitScreen} + isMobile={props.isMobile} disableMarkdownText={props.disableMarkdownText} enhanceCodeBlocks={props.enhanceCodeBlocks} // renderTextDiff={textDiffs || undefined} diff --git a/src/apps/chat/components/message/fragments-content/ContentPartPlaceholder.tsx b/src/apps/chat/components/message/fragments-content/ContentPartPlaceholder.tsx index d7979a682..9108fe873 100644 --- a/src/apps/chat/components/message/fragments-content/ContentPartPlaceholder.tsx +++ b/src/apps/chat/components/message/fragments-content/ContentPartPlaceholder.tsx @@ -21,6 +21,7 @@ export function ContentPartPlaceholder(props: { fromRole={props.messageRole} contentScaling={props.contentScaling} fitScreen={false} + isMobile={false /* assumption that the Placeholder Part doesn't react to size, and we assume desktop */} showAsDanger={props.showAsDanger} showAsItalic={props.showAsItalic} textRenderVariant='text' diff --git a/src/apps/chat/components/message/fragments-content/ContentPartText_AutoBlocks.tsx b/src/apps/chat/components/message/fragments-content/ContentPartText_AutoBlocks.tsx index 0033f0188..d5d2a38c3 100644 --- a/src/apps/chat/components/message/fragments-content/ContentPartText_AutoBlocks.tsx +++ b/src/apps/chat/components/message/fragments-content/ContentPartText_AutoBlocks.tsx @@ -21,6 +21,7 @@ export function ContentPartText_AutoBlocks(props: { messageOriginLLM?: string, contentScaling: ContentScaling, + isMobile: boolean, fitScreen: boolean, disableMarkdownText: boolean, enhanceCodeBlocks: boolean, @@ -58,6 +59,7 @@ export function ContentPartText_AutoBlocks(props: { fromRole={props.messageRole} contentScaling={props.contentScaling} fitScreen={props.fitScreen} + isMobile={props.isMobile} showUnsafeHtml={props.showUnsafeHtml} renderSanityTextDiffs={props.renderTextDiff} codeRenderVariant={props.enhanceCodeBlocks ? 'enhanced' : 'outlined'} diff --git a/src/apps/draw/gallery/ZeroGallery.tsx b/src/apps/draw/gallery/ZeroGallery.tsx index 7d9be5305..a6833a283 100644 --- a/src/apps/draw/gallery/ZeroGallery.tsx +++ b/src/apps/draw/gallery/ZeroGallery.tsx @@ -4,6 +4,9 @@ import { Card } from '@mui/joy'; import { AutoBlocksRenderer } from '~/modules/blocks/AutoBlocksRenderer'; +import { useIsMobile } from '~/common/components/useMatchMedia'; +import { useUIContentScaling } from '~/common/state/store-ui'; + const zeroGalleryMd = ` ### {{title}} @@ -20,10 +23,16 @@ Your past creations will appear here once you start drawing. export function ZeroGallery(props: { domain: 'draw' | 'app' }) { + + // external state + const isMobile = useIsMobile(); + const contentScaling = useUIContentScaling(); + const text = zeroGalleryMd.replace('{{title}}', props.domain === 'draw' ? 'Empty Gallery' : 'No App Media', ); + return ( {/**/} diff --git a/src/apps/settings-modal/ShortcutsModal.tsx b/src/apps/settings-modal/ShortcutsModal.tsx index d99976d28..10d8afe62 100644 --- a/src/apps/settings-modal/ShortcutsModal.tsx +++ b/src/apps/settings-modal/ShortcutsModal.tsx @@ -5,6 +5,7 @@ import { AutoBlocksRenderer } from '~/modules/blocks/AutoBlocksRenderer'; import { GoodModal } from '~/common/components/GoodModal'; import { platformAwareKeystrokes } from '~/common/components/KeyStroke'; import { useIsMobile } from '~/common/components/useMatchMedia'; +import { useUIContentScaling } from '~/common/state/store-ui'; const shortcutsMd = platformAwareKeystrokes(` @@ -40,16 +41,17 @@ const shortcutsMd = platformAwareKeystrokes(` export function ShortcutsModal(props: { onClose: () => void }) { // external state - const isMobile - = useIsMobile(); + const isMobile = useIsMobile(); + const contentScaling = useUIContentScaling(); return ( diff --git a/src/common/components/ExplainerCarousel.tsx b/src/common/components/ExplainerCarousel.tsx index 3e6f6ef62..a5df6f326 100644 --- a/src/common/components/ExplainerCarousel.tsx +++ b/src/common/components/ExplainerCarousel.tsx @@ -16,6 +16,7 @@ import { ShortcutKey, useGlobalShortcuts } from '~/common/components/shortcuts/u import { animationTextShadowLimey } from '~/common/util/animUtils'; import { hasGoogleAnalytics } from '~/common/components/GoogleAnalytics'; import { useIsMobile } from '~/common/components/useMatchMedia'; +import { useUIContentScaling } from '~/common/state/store-ui'; // configuration @@ -126,6 +127,7 @@ export function ExplainerCarousel(props: { // external state const isMobile = useIsMobile(); + const contentScaling = useUIContentScaling(); // derived state const { onFinished } = props; @@ -232,8 +234,9 @@ export function ExplainerCarousel(props: { diff --git a/src/modules/aifn/digrams/DiagramsModal.tsx b/src/modules/aifn/digrams/DiagramsModal.tsx index c8d5a6f64..fd8df2abb 100644 --- a/src/modules/aifn/digrams/DiagramsModal.tsx +++ b/src/modules/aifn/digrams/DiagramsModal.tsx @@ -227,6 +227,7 @@ export function DiagramsModal(props: { config: DiagramConfig, onClose: () => voi fromRole='assistant' contentScaling={adjustContentScaling(contentScaling, -1)} fitScreen={isMobile} + isMobile={isMobile} blocksProcessor='diagram' codeRenderVariant='plain' textRenderVariant='text' diff --git a/src/modules/beam/gather/BeamFusionGrid.tsx b/src/modules/beam/gather/BeamFusionGrid.tsx index 91936b41f..b4c1f32f7 100644 --- a/src/modules/beam/gather/BeamFusionGrid.tsx +++ b/src/modules/beam/gather/BeamFusionGrid.tsx @@ -111,6 +111,7 @@ export function BeamFusionGrid(props: { key={'fusion-' + fusionId} beamStore={props.beamStore} fusionId={fusionId} + isMobile={props.isMobile} /> ))} diff --git a/src/modules/beam/gather/Fusion.tsx b/src/modules/beam/gather/Fusion.tsx index 5ae96b292..2f0db6465 100644 --- a/src/modules/beam/gather/Fusion.tsx +++ b/src/modules/beam/gather/Fusion.tsx @@ -28,6 +28,7 @@ import { useBeamCardScrolling } from '../store-module-beam'; export function Fusion(props: { beamStore: BeamStoreApi, fusionId: string, + isMobile: boolean, }) { // external state @@ -144,6 +145,7 @@ export function Fusion(props: { SCATTER_RAY_MIN} rayId={rayId} // linkedLlmId={props.linkedLlmId} diff --git a/src/modules/blocks/AutoBlocksRenderer.tsx b/src/modules/blocks/AutoBlocksRenderer.tsx index 6a4336876..49229036d 100644 --- a/src/modules/blocks/AutoBlocksRenderer.tsx +++ b/src/modules/blocks/AutoBlocksRenderer.tsx @@ -35,7 +35,9 @@ export function AutoBlocksRenderer(props: { fromRole: DMessageRole; contentScaling: ContentScaling; - fitScreen?: boolean; + fitScreen: boolean; + isMobile: boolean; + showAsDanger?: boolean; showAsItalic?: boolean; showUnsafeHtml?: boolean;