Skip to content

Commit 28ad438

Browse files
committed
v0
1 parent a36454d commit 28ad438

94 files changed

Lines changed: 199 additions & 15296 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/sim/app/api/files/upload/route.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import '@/lib/uploads/core/setup.server'
55
import { getSession } from '@/lib/auth'
66
import type { StorageContext } from '@/lib/uploads/config'
77
import { generateWorkspaceFileKey } from '@/lib/uploads/contexts/workspace/workspace-file-manager'
8-
import { isImageFileType, resolveFileType } from '@/lib/uploads/utils/file-utils'
8+
import { isImageFileType } from '@/lib/uploads/utils/file-utils'
99
import {
1010
SUPPORTED_AUDIO_EXTENSIONS,
1111
SUPPORTED_DOCUMENT_EXTENSIONS,
@@ -280,19 +280,8 @@ export async function POST(request: NextRequest) {
280280
continue
281281
}
282282

283-
// Handle copilot, chat, profile-pictures contexts
284283
if (context === 'copilot' || context === 'chat' || context === 'profile-pictures') {
285-
if (context === 'copilot') {
286-
const { isSupportedFileType: isCopilotSupported } = await import(
287-
'@/lib/uploads/contexts/copilot/copilot-file-manager'
288-
)
289-
const resolvedType = resolveFileType(file)
290-
if (!isImageFileType(resolvedType) && !isCopilotSupported(resolvedType)) {
291-
throw new InvalidRequestError(
292-
'Unsupported file type. Allowed: images, PDF, and text files (TXT, CSV, MD, HTML, JSON, XML).'
293-
)
294-
}
295-
} else if (!isImageFileType(file.type)) {
284+
if (context !== 'copilot' && !isImageFileType(file.type)) {
296285
throw new InvalidRequestError(
297286
`Only image files (JPEG, PNG, GIF, WebP, SVG) are allowed for ${context} uploads`
298287
)

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ function extractResourceFromReadResult(
249249

250250
export interface UseChatOptions {
251251
onResourceEvent?: () => void
252+
apiPath?: string
253+
stopPath?: string
254+
workflowId?: string
255+
onToolResult?: (toolName: string, success: boolean, result: unknown) => void
252256
}
253257

254258
export function useChat(
@@ -267,6 +271,14 @@ export function useChat(
267271
const [activeResourceId, setActiveResourceId] = useState<string | null>(null)
268272
const onResourceEventRef = useRef(options?.onResourceEvent)
269273
onResourceEventRef.current = options?.onResourceEvent
274+
const apiPathRef = useRef(options?.apiPath ?? MOTHERSHIP_CHAT_API_PATH)
275+
apiPathRef.current = options?.apiPath ?? MOTHERSHIP_CHAT_API_PATH
276+
const stopPathRef = useRef(options?.stopPath ?? '/api/mothership/chat/stop')
277+
stopPathRef.current = options?.stopPath ?? '/api/mothership/chat/stop'
278+
const workflowIdRef = useRef(options?.workflowId)
279+
workflowIdRef.current = options?.workflowId
280+
const onToolResultRef = useRef(options?.onToolResult)
281+
onToolResultRef.current = options?.onToolResult
270282
const resourcesRef = useRef(resources)
271283
resourcesRef.current = resources
272284
const activeResourceIdRef = useRef(activeResourceId)
@@ -355,6 +367,7 @@ export function useChat(
355367
}, [initialChatId])
356368

357369
useEffect(() => {
370+
if (workflowIdRef.current) return
358371
if (!isHomePage || !chatIdRef.current) return
359372
streamGenRef.current++
360373
chatIdRef.current = undefined
@@ -418,7 +431,7 @@ export function useChat(
418431
if (batchEvents.length === 0 && streamStatus === 'unknown') {
419432
const cid = chatIdRef.current
420433
if (cid) {
421-
fetch('/api/mothership/chat/stop', {
434+
fetch(stopPathRef.current, {
422435
method: 'POST',
423436
headers: { 'Content-Type': 'application/json' },
424437
body: JSON.stringify({ chatId: cid, streamId: activeStreamId, content: '' }),
@@ -597,11 +610,13 @@ export function useChat(
597610
resources: [],
598611
})
599612
}
600-
window.history.replaceState(
601-
null,
602-
'',
603-
`/workspace/${workspaceId}/task/${parsed.chatId}`
604-
)
613+
if (!workflowIdRef.current) {
614+
window.history.replaceState(
615+
null,
616+
'',
617+
`/workspace/${workspaceId}/task/${parsed.chatId}`
618+
)
619+
}
605620
}
606621
}
607622
break
@@ -786,6 +801,8 @@ export function useChat(
786801
invalidateResourceQueries(queryClient, workspaceId, resource.type, resource.id)
787802
}
788803
}
804+
805+
onToolResultRef.current?.(tc.name, tc.status === 'success', tc.result?.output)
789806
}
790807

791808
break
@@ -909,7 +926,7 @@ export function useChat(
909926
}
910927

911928
try {
912-
const res = await fetch('/api/mothership/chat/stop', {
929+
const res = await fetch(stopPathRef.current, {
913930
method: 'POST',
914931
headers: { 'Content-Type': 'application/json' },
915932
body: JSON.stringify({
@@ -1061,7 +1078,7 @@ export function useChat(
10611078
}))
10621079
: undefined
10631080

1064-
const response = await fetch(MOTHERSHIP_CHAT_API_PATH, {
1081+
const response = await fetch(apiPathRef.current, {
10651082
method: 'POST',
10661083
headers: { 'Content-Type': 'application/json' },
10671084
body: JSON.stringify({
@@ -1073,6 +1090,7 @@ export function useChat(
10731090
...(fileAttachments && fileAttachments.length > 0 ? { fileAttachments } : {}),
10741091
...(resourceAttachments ? { resourceAttachments } : {}),
10751092
...(contexts && contexts.length > 0 ? { contexts } : {}),
1093+
...(workflowIdRef.current ? { workflowId: workflowIdRef.current } : {}),
10761094
userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
10771095
}),
10781096
signal: abortController.signal,

apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { useSession } from '@/lib/auth/auth-client'
77
import { AdminSkeleton } from '@/app/workspace/[workspaceId]/settings/components/admin/admin-skeleton'
88
import { ApiKeysSkeleton } from '@/app/workspace/[workspaceId]/settings/components/api-keys/api-key-skeleton'
99
import { BYOKSkeleton } from '@/app/workspace/[workspaceId]/settings/components/byok/byok-skeleton'
10-
import { CopilotSkeleton } from '@/app/workspace/[workspaceId]/settings/components/copilot/copilot-skeleton'
1110
import { CredentialSetsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/credential-sets/credential-sets-skeleton'
1211
import { CredentialsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/credentials/credential-skeleton'
1312
import { CustomToolsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/custom-tools/custom-tool-skeleton'
@@ -96,13 +95,6 @@ const BYOK = dynamic(
9695
() => import('@/app/workspace/[workspaceId]/settings/components/byok/byok').then((m) => m.BYOK),
9796
{ loading: () => <BYOKSkeleton /> }
9897
)
99-
const Copilot = dynamic(
100-
() =>
101-
import('@/app/workspace/[workspaceId]/settings/components/copilot/copilot').then(
102-
(m) => m.Copilot
103-
),
104-
{ loading: () => <CopilotSkeleton /> }
105-
)
10698
const MCP = dynamic(
10799
() => import('@/app/workspace/[workspaceId]/settings/components/mcp/mcp').then((m) => m.MCP),
108100
{ loading: () => <McpSkeleton /> }
@@ -185,7 +177,6 @@ export function SettingsPage({ section }: SettingsPageProps) {
185177
{isBillingEnabled && effectiveSection === 'team' && <TeamManagement />}
186178
{effectiveSection === 'sso' && <SSO />}
187179
{effectiveSection === 'byok' && <BYOK />}
188-
{effectiveSection === 'copilot' && <Copilot />}
189180
{effectiveSection === 'mcp' && <MCP initialServerId={mcpServerId} />}
190181
{effectiveSection === 'custom-tools' && <CustomTools />}
191182
{effectiveSection === 'skills' && <Skills />}

apps/sim/app/workspace/[workspaceId]/settings/components/copilot/copilot-skeleton.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)