Skip to content

Commit f932278

Browse files
committed
Merge branch 'staging' into improvement/enforce-outside-hooks
2 parents 2a0d76b + 124fe17 commit f932278

8 files changed

Lines changed: 84 additions & 13 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export function Home({ chatId }: HomeProps = {}) {
293293
return () => ro.disconnect()
294294
}, [hasMessages])
295295

296-
if (!hasMessages && !chatId) {
296+
if (!hasMessages && !showChatSkeleton) {
297297
return (
298298
<div className='h-full overflow-y-auto bg-[var(--bg)] [scrollbar-gutter:stable_both-edges]'>
299299
<div className='flex min-h-full flex-col items-center justify-center px-6 pb-[2vh]'>

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,7 @@ export const Sidebar = memo(function Sidebar() {
790790
)
791791
}
792792

793-
const { data: fetchedTasks } = useTasks(workspaceId)
794-
const tasksLoading = fetchedTasks === undefined
793+
const { data: fetchedTasks, isLoading: tasksLoading } = useTasks(workspaceId)
795794

796795
useTaskEvents(workspaceId)
797796

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import type * as React from 'react'
2+
import { cva, type VariantProps } from 'class-variance-authority'
3+
import { AlertTriangle, CheckCircle2, Info } from 'lucide-react'
4+
import { cn } from '@/lib/core/utils/cn'
5+
6+
const calloutVariants = cva('flex items-center gap-2 rounded-lg border p-2.5 text-[12px]', {
7+
variants: {
8+
variant: {
9+
default: 'border-[var(--border)] bg-[var(--surface-2)] text-[var(--text-muted)]',
10+
info: 'border-[var(--border)] bg-[var(--surface-2)] text-[var(--text-muted)]',
11+
success:
12+
'border-[color-mix(in_srgb,var(--badge-success-text)_30%,transparent)] bg-[var(--badge-success-bg)] text-[var(--badge-success-text)]',
13+
warning:
14+
'border-[color-mix(in_srgb,var(--badge-amber-text)_30%,transparent)] bg-[var(--badge-amber-bg)] text-[var(--badge-amber-text)]',
15+
destructive:
16+
'border-[color-mix(in_srgb,var(--text-error)_40%,transparent)] bg-[color-mix(in_srgb,var(--text-error)_10%,transparent)] text-[var(--text-error)]',
17+
},
18+
},
19+
defaultVariants: {
20+
variant: 'default',
21+
},
22+
})
23+
24+
const DEFAULT_ICONS = {
25+
default: Info,
26+
info: Info,
27+
success: CheckCircle2,
28+
warning: AlertTriangle,
29+
destructive: AlertTriangle,
30+
} as const
31+
32+
export interface CalloutProps
33+
extends React.HTMLAttributes<HTMLDivElement>,
34+
VariantProps<typeof calloutVariants> {
35+
/** Icon component shown before the content. Pass `null` to hide. Defaults per variant. */
36+
icon?: React.ComponentType<{ className?: string }> | null
37+
}
38+
39+
/**
40+
* Inline note used to highlight short pieces of context inside a page or section.
41+
*
42+
* @example
43+
* ```tsx
44+
* <Callout>Applies organization-wide</Callout>
45+
* <Callout variant='warning'>This action is irreversible</Callout>
46+
* ```
47+
*/
48+
function Callout({ className, variant, icon, children, role = 'note', ...props }: CalloutProps) {
49+
const variantKey = (variant ?? 'default') as keyof typeof DEFAULT_ICONS
50+
const Icon = icon === null ? null : (icon ?? DEFAULT_ICONS[variantKey])
51+
52+
return (
53+
<div role={role} className={cn(calloutVariants({ variant }), className)} {...props}>
54+
{Icon && <Icon className='h-[14px] w-[14px] shrink-0' />}
55+
<span>{children}</span>
56+
</div>
57+
)
58+
}
59+
60+
export { Callout, calloutVariants }

apps/sim/components/emcn/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export {
1818
buttonGroupItemVariants,
1919
buttonGroupVariants,
2020
} from './button-group/button-group'
21+
export { Callout, type CalloutProps, calloutVariants } from './callout/callout'
2122
export {
2223
Checkbox,
2324
type CheckboxProps,

apps/sim/components/emcn/components/toast/toast.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ function ToastItem({ toast: t, onDismiss }: { toast: ToastData; onDismiss: (id:
169169
onMouseEnter={hasDuration ? handleMouseEnter : undefined}
170170
onMouseLeave={hasDuration ? handleMouseLeave : undefined}
171171
className={cn(
172-
'pointer-events-auto flex w-[min(100vw-2rem,320px)] flex-col gap-2 overflow-hidden rounded-lg border px-3 py-2.5 shadow-md transition-[transform,opacity]',
172+
'pointer-events-auto flex flex-col gap-2 overflow-hidden rounded-lg border px-3 py-2.5 shadow-md transition-[transform,opacity]',
173+
t.variant === 'error' ? 'w-[min(100vw-2rem,400px)]' : 'w-[min(100vw-2rem,320px)]',
173174
VARIANT_STYLES[t.variant],
174175
exiting
175176
? 'animate-[toast-exit_200ms_ease-in_forwards] motion-reduce:animate-none'
@@ -178,7 +179,12 @@ function ToastItem({ toast: t, onDismiss }: { toast: ToastData; onDismiss: (id:
178179
>
179180
<div className='flex items-start gap-2'>
180181
<div className='min-w-0 flex-1'>
181-
<div className='line-clamp-2 font-medium text-[var(--text-body)] text-small leading-[18px]'>
182+
<div
183+
className={cn(
184+
'font-medium text-[var(--text-body)] text-small leading-[18px]',
185+
t.variant === 'error' ? 'line-clamp-3' : 'line-clamp-2'
186+
)}
187+
>
182188
{t.variant === 'error' && (
183189
<span className='mr-2 mb-0.5 inline-block h-2 w-2 rounded-[2px] bg-[var(--text-error)] align-middle' />
184190
)}

apps/sim/ee/data-retention/components/data-retention-settings.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useEffect, useState } from 'react'
44
import { createLogger } from '@sim/logger'
55
import { toError } from '@sim/utils/errors'
6-
import { Button, Combobox, toast } from '@/components/emcn'
6+
import { Button, Callout, Combobox, toast } from '@/components/emcn'
77
import { useSession } from '@/lib/auth/auth-client'
88
import { isBillingEnabled } from '@/lib/core/config/feature-flags'
99
import { getUserRole } from '@/lib/workspaces/organization/utils'
@@ -169,10 +169,8 @@ export function DataRetentionSettings() {
169169

170170
return (
171171
<div className='flex flex-col gap-8'>
172+
<Callout>Applies organization-wide</Callout>
172173
<section>
173-
<h3 className='mb-4 font-medium text-[15px] text-[var(--text-primary)]'>
174-
Retention Periods
175-
</h3>
176174
<div className='flex flex-col gap-5'>
177175
<SettingRow
178176
label='Log retention'

apps/sim/ee/whitelabeling/components/whitelabeling-settings.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { toError } from '@sim/utils/errors'
66
import { X } from 'lucide-react'
77
import Image from 'next/image'
88
import { useParams } from 'next/navigation'
9-
import { Button, Input, Label, Loader, Skeleton, toast } from '@/components/emcn'
9+
import { Button, Callout, Input, Label, Loader, Skeleton, toast } from '@/components/emcn'
1010
import { useSession } from '@/lib/auth/auth-client'
1111
import { getSubscriptionAccessState } from '@/lib/billing/client/utils'
1212
import { HEX_COLOR_REGEX } from '@/lib/branding'
@@ -318,6 +318,7 @@ export function WhitelabelingSettings() {
318318

319319
return (
320320
<div className='flex flex-col gap-8'>
321+
<Callout>Applies organization-wide</Callout>
321322
<section>
322323
<SectionTitle>Brand Identity</SectionTitle>
323324
<div className='flex flex-col gap-5'>

apps/sim/hooks/queries/tasks.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
1+
import {
2+
keepPreviousData,
3+
skipToken,
4+
useMutation,
5+
useQuery,
6+
useQueryClient,
7+
} from '@tanstack/react-query'
28
import { isApiClientError } from '@/lib/api/client/errors'
39
import { requestJson } from '@/lib/api/client/request'
410
import {
@@ -212,8 +218,8 @@ export async function fetchTasks(
212218
export function useTasks(workspaceId?: string) {
213219
return useQuery({
214220
queryKey: taskKeys.list(workspaceId),
215-
queryFn: ({ signal }) => fetchTasks(workspaceId as string, signal),
216-
enabled: Boolean(workspaceId),
221+
queryFn: workspaceId ? ({ signal }) => fetchTasks(workspaceId, signal) : skipToken,
222+
placeholderData: keepPreviousData,
217223
staleTime: 60 * 1000,
218224
})
219225
}

0 commit comments

Comments
 (0)