mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(ui): posthog guard, dynamic import loading, compact variant, rebase cleanup (#4196)
* v0.6.29: login improvements, posthog telemetry (#4026) * feat(posthog): Add tracking on mothership abort (#4023) Co-authored-by: Theodore Li <theo@sim.ai> * fix(login): fix captcha headers for manual login (#4025) * fix(signup): fix turnstile key loading * fix(login): fix captcha header passing * Catch user already exists, remove login form captcha * fix(ui): posthog guard, dynamic import loading, compact variant, rebase cleanup --------- Co-authored-by: Theodore Li <theodoreqili@gmail.com>
This commit is contained in:
co-authored by
Theodore Li
Theodore Li
parent
23ccd4a50c
commit
0464a57601
@@ -7,8 +7,9 @@ import Link from 'next/link'
|
||||
import { Badge } from '@/components/emcn'
|
||||
import { trackLandingCta } from '@/app/(landing)/landing-analytics'
|
||||
|
||||
const AuthModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal)
|
||||
const AuthModal = dynamic(
|
||||
() => import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
interface DotGridProps {
|
||||
|
||||
@@ -8,8 +8,9 @@ import { Badge } from '@/components/emcn'
|
||||
import { FeaturesPreview } from '@/app/(landing)/components/features/components/features-preview'
|
||||
import { trackLandingCta } from '@/app/(landing)/landing-analytics'
|
||||
|
||||
const AuthModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal)
|
||||
const AuthModal = dynamic(
|
||||
() => import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
function hexToRgba(hex: string, alpha: number): string {
|
||||
|
||||
@@ -9,8 +9,9 @@ import { useLandingSubmit } from '@/app/(landing)/components/landing-preview/com
|
||||
import { trackLandingCta } from '@/app/(landing)/landing-analytics'
|
||||
import { useAnimatedPlaceholder } from '@/hooks/use-animated-placeholder'
|
||||
|
||||
const AuthModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal)
|
||||
const AuthModal = dynamic(
|
||||
() => import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
const MAX_HEIGHT = 120
|
||||
|
||||
@@ -4,14 +4,17 @@ import dynamic from 'next/dynamic'
|
||||
import { cn } from '@/lib/core/utils/cn'
|
||||
import { trackLandingCta } from '@/app/(landing)/landing-analytics'
|
||||
|
||||
const AuthModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal)
|
||||
const AuthModal = dynamic(
|
||||
() => import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
const DemoRequestModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/demo-request/demo-request-modal').then(
|
||||
(m) => m.DemoRequestModal
|
||||
)
|
||||
const DemoRequestModal = dynamic(
|
||||
() =>
|
||||
import('@/app/(landing)/components/demo-request/demo-request-modal').then(
|
||||
(m) => m.DemoRequestModal
|
||||
),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
const LandingPreview = dynamic(
|
||||
|
||||
+3
-2
@@ -21,8 +21,9 @@ import {
|
||||
} from '@/app/(landing)/components/landing-preview/components/landing-preview-workflow/workflow-data'
|
||||
import { trackLandingCta } from '@/app/(landing)/landing-analytics'
|
||||
|
||||
const AuthModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal)
|
||||
const AuthModal = dynamic(
|
||||
() => import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
type PanelTab = 'copilot' | 'editor'
|
||||
|
||||
@@ -17,8 +17,9 @@ import { GitHubStars } from '@/app/(landing)/components/navbar/components/github
|
||||
import { trackLandingCta } from '@/app/(landing)/landing-analytics'
|
||||
import { getBrandConfig } from '@/ee/whitelabeling'
|
||||
|
||||
const AuthModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal)
|
||||
const AuthModal = dynamic(
|
||||
() => import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
type DropdownId = 'docs' | 'blog' | null
|
||||
|
||||
@@ -4,14 +4,17 @@ import dynamic from 'next/dynamic'
|
||||
import { Badge } from '@/components/emcn'
|
||||
import { trackLandingCta } from '@/app/(landing)/landing-analytics'
|
||||
|
||||
const AuthModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal)
|
||||
const AuthModal = dynamic(
|
||||
() => import('@/app/(landing)/components/auth-modal/auth-modal').then((m) => m.AuthModal),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
const DemoRequestModal = dynamic(() =>
|
||||
import('@/app/(landing)/components/demo-request/demo-request-modal').then(
|
||||
(m) => m.DemoRequestModal
|
||||
)
|
||||
const DemoRequestModal = dynamic(
|
||||
() =>
|
||||
import('@/app/(landing)/components/demo-request/demo-request-modal').then(
|
||||
(m) => m.DemoRequestModal
|
||||
),
|
||||
{ loading: () => null }
|
||||
)
|
||||
|
||||
interface PricingTier {
|
||||
|
||||
@@ -94,6 +94,7 @@ export function SessionProvider({ children }: { children: React.ReactNode }) {
|
||||
})
|
||||
if (
|
||||
typeof posthog.startSessionRecording === 'function' &&
|
||||
typeof posthog.sessionRecordingStarted === 'function' &&
|
||||
!posthog.sessionRecordingStarted()
|
||||
) {
|
||||
posthog.startSessionRecording()
|
||||
|
||||
+11
-10
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useCallback, useRef, useState } from 'react'
|
||||
import { ArrowUp, ChevronDown, ChevronRight, Paperclip, Pencil, Trash2 } from 'lucide-react'
|
||||
import { Tooltip } from '@/components/emcn'
|
||||
import { UserMessageContent } from '@/app/workspace/[workspaceId]/home/components/user-message-content'
|
||||
@@ -17,22 +17,23 @@ interface QueuedMessagesProps {
|
||||
|
||||
export function QueuedMessages({ messageQueue, onRemove, onSendNow, onEdit }: QueuedMessagesProps) {
|
||||
const [isExpanded, setIsExpanded] = useState(true)
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const [isNarrow, setIsNarrow] = useState(false)
|
||||
const roRef = useRef<ResizeObserver | null>(null)
|
||||
|
||||
const hasMessages = messageQueue.length > 0
|
||||
|
||||
useEffect(() => {
|
||||
const el = containerRef.current
|
||||
const containerRef = useCallback((el: HTMLDivElement | null) => {
|
||||
if (roRef.current) {
|
||||
roRef.current.disconnect()
|
||||
roRef.current = null
|
||||
}
|
||||
if (!el) return
|
||||
const ro = new ResizeObserver((entries) => {
|
||||
setIsNarrow(entries[0].contentRect.width < NARROW_WIDTH_PX)
|
||||
})
|
||||
ro.observe(el)
|
||||
return () => ro.disconnect()
|
||||
}, [hasMessages])
|
||||
roRef.current = ro
|
||||
}, [])
|
||||
|
||||
if (!hasMessages) return null
|
||||
if (messageQueue.length === 0) return null
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -70,7 +71,7 @@ export function QueuedMessages({ messageQueue, onRemove, onSendNow, onEdit }: Qu
|
||||
content={msg.content}
|
||||
contexts={msg.contexts}
|
||||
plainMentions
|
||||
className='!truncate !whitespace-nowrap !text-small !leading-[20px]'
|
||||
compact
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
+11
-6
@@ -10,12 +10,17 @@ import { useWorkflows } from '@/hooks/queries/workflows'
|
||||
const USER_MESSAGE_CLASSES =
|
||||
'whitespace-pre-wrap break-words [overflow-wrap:anywhere] font-[430] font-[family-name:var(--font-inter)] text-base text-[var(--text-primary)] leading-[23px] tracking-[0] antialiased'
|
||||
|
||||
const COMPACT_CLASSES =
|
||||
'truncate text-small leading-[20px] font-[430] font-[family-name:var(--font-inter)] text-[var(--text-primary)] tracking-[0] antialiased'
|
||||
|
||||
interface UserMessageContentProps {
|
||||
content: string
|
||||
contexts?: ChatMessageContext[]
|
||||
className?: string
|
||||
/** When true, render mentions as plain inline text (no icon/pill) so truncation flows naturally. */
|
||||
plainMentions?: boolean
|
||||
/** Use compact single-line layout with truncation. */
|
||||
compact?: boolean
|
||||
}
|
||||
|
||||
function escapeRegex(str: string): string {
|
||||
@@ -73,15 +78,15 @@ export function UserMessageContent({
|
||||
contexts,
|
||||
className,
|
||||
plainMentions = false,
|
||||
compact = false,
|
||||
}: UserMessageContentProps) {
|
||||
const trimmed = content.trim()
|
||||
const classes = cn(USER_MESSAGE_CLASSES, className)
|
||||
const classes = cn(compact ? COMPACT_CLASSES : USER_MESSAGE_CLASSES, className)
|
||||
|
||||
if (!contexts || contexts.length === 0) {
|
||||
return <p className={classes}>{trimmed}</p>
|
||||
}
|
||||
|
||||
const ranges = computeMentionRanges(content, contexts)
|
||||
const ranges = useMemo(
|
||||
() => (contexts && contexts.length > 0 ? computeMentionRanges(content, contexts) : []),
|
||||
[content, contexts]
|
||||
)
|
||||
|
||||
if (ranges.length === 0) {
|
||||
return <p className={classes}>{trimmed}</p>
|
||||
|
||||
Reference in New Issue
Block a user