Skip to content

Commit eb3e8a1

Browse files
committed
improvement(cleanup): drop dead folder plumbing and stale names left by the removals
1 parent c796564 commit eb3e8a1

8 files changed

Lines changed: 19 additions & 78 deletions

File tree

‎apps/sim/app/api/mothership/chat/route.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mothershipChatPostEnvelopeSchema } from '@/lib/api/contracts/mothership
33
import { getSession } from '@/lib/auth'
44
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
55
import { handleUnifiedChatPost } from '@/lib/mothership/chat/post'
6-
import { validateShimEnvelope } from '@/lib/mothership/request/http'
6+
import { validateChatPostEnvelope } from '@/lib/mothership/request/http'
77

88
/**
99
* Caps this response on serverless hosts only; the Node server bounds nothing with it.
@@ -18,7 +18,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
1818
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
1919
}
2020

21-
const invalid = await validateShimEnvelope(request, mothershipChatPostEnvelopeSchema)
21+
const invalid = await validateChatPostEnvelope(request, mothershipChatPostEnvelopeSchema)
2222
if (invalid) return invalid
2323

2424
return handleUnifiedChatPost(request)

‎apps/sim/app/api/mothership/chat/stop/route.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ import { withIncomingGoSpan } from '@/lib/mothership/request/otel'
2626

2727
const logger = createLogger('CopilotChatStopAPI')
2828

29-
// POST /api/mothership/chat/stop — persists partial assistant content
30-
// when the user stops mid-stream. Lock release is handled by the
31-
// aborted server stream unwinding, not this handler.
29+
/**
30+
* Persists partial assistant content when the user stops mid-stream. Lock release is handled by
31+
* the aborted server stream unwinding, not this handler.
32+
*/
3233
export const POST = withRouteHandler((req: NextRequest) =>
3334
withIncomingGoSpan(req.headers, TraceSpan.CopilotChatStopStream, undefined, async (span) => {
3435
try {

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/components/keyboard-navigation-handler.tsx‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ const findFolderInfoForTag = (
5050
): {
5151
id: string
5252
parentTag: string
53-
group: NestedBlockTagGroup
5453
nestedTag: NestedTag
5554
} | null => {
5655
for (const nestedTag of nestedTags) {
@@ -61,7 +60,6 @@ const findFolderInfoForTag = (
6160
return {
6261
id: `${group.blockId}-${nestedTag.key}`,
6362
parentTag: nestedTag.parentTag,
64-
group,
6563
nestedTag,
6664
}
6765
}
@@ -191,7 +189,7 @@ export const KeyboardNavigationHandler: React.FC<KeyboardNavigationHandlerProps>
191189
const handleKeyboardEvent = useEffectEvent((e: KeyboardEvent) => {
192190
if (!flatTagList.length) return
193191

194-
const openFolderWithSelection = (folderId: string, parentTag: string) => {
192+
const enterFolder = (folderId: string, parentTag: string) => {
195193
const parentIdx = flatTagList.findIndex((item) => item.tag === parentTag)
196194
openFolder(folderId)
197195
if (parentIdx >= 0) {
@@ -202,12 +200,7 @@ export const KeyboardNavigationHandler: React.FC<KeyboardNavigationHandlerProps>
202200
const selected = flatTagList[selectedIndex]
203201
if (!selected && e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return
204202

205-
let currentFolderInfo: {
206-
id: string
207-
parentTag: string
208-
group: NestedBlockTagGroup
209-
nestedTag: NestedTag
210-
} | null = null
203+
let currentFolderInfo: ReturnType<typeof findFolderInfoForTag> = null
211204

212205
if (selected) {
213206
for (const group of nestedBlockTagGroups) {
@@ -283,7 +276,7 @@ export const KeyboardNavigationHandler: React.FC<KeyboardNavigationHandlerProps>
283276
if (isInFolder && nestedNav) {
284277
nestedNav.navigateIn(currentFolderInfo.nestedTag)
285278
} else {
286-
openFolderWithSelection(currentFolderInfo.id, currentFolderInfo.parentTag)
279+
enterFolder(currentFolderInfo.id, currentFolderInfo.parentTag)
287280
onFolderEnter?.()
288281
}
289282
}

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx‎

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ interface NestedNavigationContextValue {
4646
navigateIn: (tag: NestedTag) => void
4747
/** Navigate back one level, returns true if navigation happened, false if at root */
4848
navigateBack: () => boolean
49-
/** Register the base folder when it opens */
50-
registerFolder: (folderId: string) => void
5149
}
5250

5351
const NestedNavigationContext = React.createContext<NestedNavigationContextValue | null>(null)
@@ -526,29 +524,16 @@ const FolderContentsInner: React.FC<FolderContentsProps> = ({
526524

527525
/**
528526
* Wrapper component that uses shared nested navigation state from context.
529-
* Handles registration of the base folder and navigation callbacks.
527+
* Supplies the current nested path and the navigate-in callback.
530528
*/
531529
const FolderContents: React.FC<Omit<NestedTagRendererProps, never>> = (props) => {
532530
const nestedNav = useNestedNavigation()
533-
const { currentFolder } = usePopoverContext()
534531

535532
const nestedPath = nestedNav?.nestedPath ?? []
536533

537-
useEffect(() => {
538-
if (nestedNav && currentFolder) {
539-
const folderId = `${props.group.blockId}-${props.nestedTag.key}`
540-
if (currentFolder === folderId) {
541-
nestedNav.registerFolder(folderId)
542-
}
543-
}
544-
}, [currentFolder, nestedNav, props.group, props.nestedTag])
545-
546-
const handleNavigateIn = useCallback(
547-
(nestedTag: NestedTag) => {
548-
nestedNav?.navigateIn(nestedTag)
549-
},
550-
[nestedNav, props.group]
551-
)
534+
const handleNavigateIn = (nestedTag: NestedTag) => {
535+
nestedNav?.navigateIn(nestedTag)
536+
}
552537

553538
return <FolderContentsInner {...props} nestedPath={nestedPath} onNavigateIn={handleNavigateIn} />
554539
}
@@ -800,23 +785,6 @@ const BlockRootTagItem: React.FC<{
800785
)
801786
}
802787

803-
/**
804-
* Helper component to capture popover context for nested navigation
805-
*/
806-
const PopoverContextCapture: React.FC<{
807-
contextRef: React.RefObject<{
808-
openFolder: (id: string, onLoad?: () => void | Promise<void>) => void
809-
} | null>
810-
}> = ({ contextRef }) => {
811-
const { openFolder } = usePopoverContext()
812-
useEffect(() => {
813-
if (contextRef && 'current' in contextRef) {
814-
;(contextRef as { current: typeof contextRef.current }).current = { openFolder }
815-
}
816-
}, [openFolder, contextRef])
817-
return null
818-
}
819-
820788
/**
821789
* Back button that handles nested navigation.
822790
* When in nested folders, goes back one level at a time.
@@ -898,7 +866,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
898866
const itemRefs = (itemElementsRef.current ??= new Map())
899867

900868
const [nestedPath, setNestedPath] = useState<NestedTag[]>([])
901-
const baseFolderRef = useRef<{ id: string } | null>(null)
902869
const scrollAreaRef = useRef<HTMLDivElement>(null)
903870

904871
const inputValueRef = useRef(inputValue)
@@ -1474,47 +1441,28 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
14741441
[workflowVariables, onSelect, onClose, getMergedSubBlocks]
14751442
)
14761443

1477-
const popoverContextRef = useRef<{
1478-
openFolder: (id: string, onLoad?: () => void | Promise<void>) => void
1479-
} | null>(null)
1480-
14811444
const nestedNavigationValue = useMemo<NestedNavigationContextValue>(
14821445
() => ({
14831446
nestedPath,
14841447
navigateIn: (tag: NestedTag) => {
1485-
const baseFolder = baseFolderRef.current
1486-
if (!baseFolder || !popoverContextRef.current) return
1487-
14881448
setNestedPath((prev) => [...prev, tag])
14891449

14901450
if (scrollAreaRef.current) {
14911451
scrollAreaRef.current.scrollTop = 0
14921452
}
1493-
1494-
popoverContextRef.current.openFolder(baseFolder.id)
14951453
},
14961454
navigateBack: () => {
1497-
const baseFolder = baseFolderRef.current
1498-
if (!baseFolder || !popoverContextRef.current) return false
14991455
if (nestedPath.length === 0) return false
1500-
1501-
const newPath = nestedPath.slice(0, -1)
1502-
setNestedPath(newPath)
1503-
1504-
popoverContextRef.current.openFolder(baseFolder.id)
1456+
setNestedPath(nestedPath.slice(0, -1))
15051457
return true
15061458
},
1507-
registerFolder: (folderId) => {
1508-
baseFolderRef.current = { id: folderId }
1509-
},
15101459
}),
15111460
[nestedPath]
15121461
)
15131462

15141463
useEffect(() => {
15151464
if (!visible) {
15161465
setNestedPath([])
1517-
baseFolderRef.current = null
15181466
}
15191467
}, [visible])
15201468

@@ -1559,7 +1507,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
15591507
return (
15601508
<NestedNavigationContext.Provider value={nestedNavigationValue}>
15611509
<Popover open={visible} onOpenChange={(open) => !open && onClose?.()} colorScheme='inverted'>
1562-
<PopoverContextCapture contextRef={popoverContextRef} />
15631510
<PopoverAnchor asChild>
15641511
<div
15651512
className={cn('pointer-events-none', className)}

‎apps/sim/lib/core/config/env.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export const env = createEnv({
131131
DISABLE_REGISTRATION: z.boolean().optional(), // Flag to disable new user registration
132132
EMAIL_PASSWORD_SIGNUP_ENABLED: z.boolean().optional().default(true), // Enable email/password authentication (server-side enforcement)
133133
DISABLE_AUTH: z.boolean().optional(), // Bypass authentication entirely (self-hosted only, creates anonymous session)
134-
ALLOW_PRIVATE_DATABASE_HOSTS: z.boolean().optional(), // Removed; read only to log a startup error that it has no effect. Use EGRESS_ALLOWED_HOSTS.
134+
ALLOW_PRIVATE_DATABASE_HOSTS: z.boolean().optional(), // Removed; read only to log a startup error that it has no effect. Use EGRESS_ALLOWED_HOSTS / EGRESS_ALLOWED_IP_RANGES.
135135
EGRESS_ALLOWED_HOSTS: z.string().optional(), // Comma-separated hostnames outbound requests may reach on a private network, leading wildcard allowed (e.g. "host.docker.internal,*.svc.cluster.local"). Self-hosted only; ignored on the hosted platform. Replaces ALLOW_PRIVATE_DATABASE_HOSTS.
136136
EGRESS_ALLOWED_IP_RANGES: z.string().optional(), // Comma-separated CIDRs or IPs outbound requests may reach on a private network (e.g. "10.0.0.0/8,192.168.65.254/32"). Self-hosted only; never lifts the cloud-metadata block.
137137
DOMAIN_VERIFICATION_NAMESERVERS: z.string().optional(), // Comma-separated nameserver IPs for the domain-verification TXT lookup (e.g. "10.0.0.2"). Defaults to 1.1.1.1 and 8.8.8.8; set it where outbound DNS is restricted to an internal resolver.

‎apps/sim/lib/mothership/request/http.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function checkInternalApiKey(req: NextRequest) {
116116
* schema. Returns the 400 to send, or null to proceed. A non-JSON body proceeds, since the
117117
* handler owns that failure mode.
118118
*/
119-
export async function validateShimEnvelope(
119+
export async function validateChatPostEnvelope(
120120
request: NextRequest,
121121
schema: z.ZodType
122122
): Promise<NextResponse | null> {

‎packages/emcn/src/components/tag-input/tag-input.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
*
44
* @example
55
* ```tsx
6-
* import { TagInput, type TagItem } from './tag-input'
6+
* import { TagInput } from '@sim/emcn'
77
*
8-
* const [items, setItems] = useState<TagItem[]>([])
8+
* const [items, setItems] = useState<{ value: string; isValid: boolean }[]>([])
99
*
1010
* <TagInput
1111
* items={items}

‎scripts/check-api-validation-contracts.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const DECLARATIVE_ROUTE_BUILDER_USAGE_PATTERN =
160160
/\b(?:defineInternalJsonRoute|defineV2JsonRoute|defineV2BodyLifecycleRoute|defineInternalBinaryRoute|defineV2BinaryRoute|defineScimRoute)\s*\(/
161161
const SERVER_VALIDATION_IMPORT_PATTERN = /\bfrom\s+['"]@\/lib\/api\/server(?:\/validation)?['"]/
162162
const SCHEMA_PARSE_PATTERN = /\b\w+Schema\.(?:safeParse|parse)\(/
163-
const CONTRACT_SERVER_HELPER_PATTERN = /\bvalidateShimEnvelope\(/
163+
const CONTRACT_SERVER_HELPER_PATTERN = /\bvalidateChatPostEnvelope\(/
164164
const CANONICAL_HELPER_USAGE_PATTERN =
165165
/\b(?:isZodError|validationErrorResponse|validationErrorResponseFromError|getValidationErrorMessage)\s*\(/
166166
const CONTRACT_MAP_PARSE_PATTERN =

0 commit comments

Comments
 (0)