Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
consolidate files
  • Loading branch information
icecrasher321 committed Mar 19, 2026
commit 0fb04fbbb011bbc2e6d0b3533d30d8f8dc66a14c
28 changes: 25 additions & 3 deletions apps/sim/lib/uploads/contexts/workspace/workspace-file-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import {
incrementStorageUsage,
} from '@/lib/billing/storage'
import { normalizeVfsSegment } from '@/lib/copilot/vfs/normalize-segment'
import { normalizeWorkspaceFileReference } from '@/lib/uploads/contexts/workspace/workspace-file-reference'

export { normalizeWorkspaceFileReference }
import {
downloadFile,
hasCloudStorage,
Expand Down Expand Up @@ -334,6 +331,31 @@ export async function listWorkspaceFiles(
}
}

/**
* Normalize a workspace file reference to its display name.
* Supports raw names and VFS-style paths like `files/name`, `files/name/content`,
* and `files/name/meta.json`.
*
* Used by storage resolution (`findWorkspaceFileRecord`), not by `open_resource`, which
* requires the canonical database UUID only.
*/
export function normalizeWorkspaceFileReference(fileReference: string): string {
const trimmed = fileReference.trim().replace(/^\/+/, '')

if (trimmed.startsWith('files/')) {
const withoutPrefix = trimmed.slice('files/'.length)
if (withoutPrefix.endsWith('/meta.json')) {
return withoutPrefix.slice(0, -'/meta.json'.length)
}
if (withoutPrefix.endsWith('/content')) {
return withoutPrefix.slice(0, -'/content'.length)
}
return withoutPrefix
}

return trimmed
}

/**
* Find a workspace file record in an existing list from either its id or a VFS/name reference.
* For copilot `open_resource` and the resource panel, use {@link getWorkspaceFile} with a UUID only.
Expand Down

This file was deleted.

Loading