mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(guard-change): run finalize at right time
This commit is contained in:
@@ -740,13 +740,12 @@ export function useChat(
|
||||
return { aborted: true, error: false }
|
||||
}
|
||||
|
||||
logger.warn('Failed to attach to existing stream', {
|
||||
logger.error('Failed to attach to existing stream, will throw for outer retry', {
|
||||
streamId,
|
||||
latestEventId,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
})
|
||||
setError(err instanceof Error ? err.message : RECONNECT_TAIL_ERROR)
|
||||
return { aborted: false, error: true }
|
||||
throw err
|
||||
} finally {
|
||||
setIsReconnecting(false)
|
||||
}
|
||||
@@ -833,11 +832,17 @@ export function useChat(
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!chatHistory || appliedChatIdRef.current === chatHistory.id) return
|
||||
if (!chatHistory) return
|
||||
|
||||
const activeStreamId = chatHistory.activeStreamId
|
||||
const snapshot = chatHistory.streamSnapshot
|
||||
applyChatHistorySnapshot(chatHistory, { preserveActiveStreamingMessage: true })
|
||||
const isNewChat = appliedChatIdRef.current !== chatHistory.id
|
||||
|
||||
if (isNewChat) {
|
||||
applyChatHistorySnapshot(chatHistory, { preserveActiveStreamingMessage: true })
|
||||
} else if (!activeStreamId || sendingRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (activeStreamId && !sendingRef.current) {
|
||||
const gen = ++streamGenRef.current
|
||||
|
||||
@@ -20,6 +20,7 @@ import type { SettingsSection } from '@/app/workspace/[workspaceId]/settings/nav
|
||||
import {
|
||||
allNavigationItems,
|
||||
isBillingEnabled,
|
||||
isCredentialSetsEnabled,
|
||||
} from '@/app/workspace/[workspaceId]/settings/navigation'
|
||||
|
||||
/**
|
||||
@@ -164,9 +165,11 @@ export function SettingsPage({ section }: SettingsPageProps) {
|
||||
const effectiveSection =
|
||||
!isBillingEnabled && (section === 'subscription' || section === 'team')
|
||||
? 'general'
|
||||
: section === 'admin' && !sessionLoading && !isAdminRole
|
||||
: section === 'credential-sets' && !isCredentialSetsEnabled
|
||||
? 'general'
|
||||
: section
|
||||
: section === 'admin' && !sessionLoading && !isAdminRole
|
||||
? 'general'
|
||||
: section
|
||||
|
||||
const label =
|
||||
allNavigationItems.find((item) => item.id === effectiveSection)?.label ?? effectiveSection
|
||||
|
||||
@@ -72,6 +72,7 @@ const isAccessControlEnabled = isTruthy(getEnv('NEXT_PUBLIC_ACCESS_CONTROL_ENABL
|
||||
const isInboxEnabled = isTruthy(getEnv('NEXT_PUBLIC_INBOX_ENABLED'))
|
||||
|
||||
export const isBillingEnabled = isTruthy(getEnv('NEXT_PUBLIC_BILLING_ENABLED'))
|
||||
export { isCredentialSetsEnabled }
|
||||
|
||||
export const sectionConfig: { key: NavigationSection; title: string }[] = [
|
||||
{ key: 'account', title: 'Account' },
|
||||
@@ -141,14 +142,16 @@ export const allNavigationItems: NavigationItem[] = [
|
||||
selfHostedOverride: isInboxEnabled,
|
||||
showWhenLocked: true,
|
||||
},
|
||||
{
|
||||
id: 'credential-sets',
|
||||
label: 'Email Polling',
|
||||
icon: Mail,
|
||||
section: 'system',
|
||||
requiresHosted: true,
|
||||
selfHostedOverride: isCredentialSetsEnabled,
|
||||
},
|
||||
...(isCredentialSetsEnabled
|
||||
? [
|
||||
{
|
||||
id: 'credential-sets' as const,
|
||||
label: 'Email Polling',
|
||||
icon: Mail,
|
||||
section: 'system' as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{ id: 'recently-deleted', label: 'Recently Deleted', icon: TrashOutline, section: 'system' },
|
||||
{
|
||||
id: 'sso',
|
||||
|
||||
Reference in New Issue
Block a user