Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion apps/sim/app/workspace/[workspaceId]/files/files.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const COLUMNS: ResourceColumn[] = [
{ id: 'type', header: 'Type' },
{ id: 'created', header: 'Created' },
{ id: 'owner', header: 'Owner' },
{ id: 'updated', header: 'Last Updated' },
]

const MIME_TYPE_LABELS: Record<string, string> = {
Expand Down Expand Up @@ -249,7 +250,7 @@ export function Files() {
result = result.filter((f) => uploadedByFilter.includes(f.uploadedBy))
}

const col = activeSort?.column ?? 'created'
const col = activeSort?.column ?? 'updated'
Comment thread
waleedlatif1 marked this conversation as resolved.
const dir = activeSort?.direction ?? 'desc'
return [...result].sort((a, b) => {
let cmp = 0
Expand All @@ -266,6 +267,9 @@ export function Files() {
case 'created':
cmp = new Date(a.uploadedAt).getTime() - new Date(b.uploadedAt).getTime()
break
case 'updated':
cmp = new Date(a.updatedAt).getTime() - new Date(b.updatedAt).getTime()
break
case 'owner':
cmp = (members?.find((m) => m.userId === a.uploadedBy)?.name ?? '').localeCompare(
members?.find((m) => m.userId === b.uploadedBy)?.name ?? ''
Expand Down Expand Up @@ -310,6 +314,7 @@ export function Files() {
},
created: timeCell(file.uploadedAt),
owner: ownerCell(file.uploadedBy, members),
updated: timeCell(file.updatedAt),
},
}
nextCache.set(file.id, { row, file, members })
Expand Down Expand Up @@ -875,6 +880,7 @@ export function Files() {
{ id: 'size', label: 'Size' },
{ id: 'type', label: 'Type' },
{ id: 'created', label: 'Created' },
{ id: 'updated', label: 'Last Updated' },
{ id: 'owner', label: 'Owner' },
],
active: activeSort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const ResourceContent = memo(function ResourceContent({
type,
uploadedBy: '',
uploadedAt: STREAMING_EPOCH,
updatedAt: STREAMING_EPOCH,
}
}, [workspaceId, streamFileName])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function Knowledge() {
result = result.filter((kb) => ownerFilter.includes(kb.userId))
}

const col = activeSort?.column ?? 'created'
const col = activeSort?.column ?? 'updated'
const dir = activeSort?.direction ?? 'desc'
return [...result].sort((a, b) => {
let cmp = 0
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/app/workspace/[workspaceId]/tables/tables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function Tables() {
if (ownerFilter.length > 0) {
result = result.filter((t) => ownerFilter.includes(t.createdBy))
}
const col = activeSort?.column ?? 'created'
const col = activeSort?.column ?? 'updated'
const dir = activeSort?.direction ?? 'desc'
return [...result].sort((a, b) => {
let cmp = 0
Expand Down
1 change: 1 addition & 0 deletions apps/sim/lib/copilot/tools/handlers/materialize-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function toFileRecord(row: typeof workspaceFiles.$inferSelect) {
uploadedBy: row.userId,
deletedAt: row.deletedAt,
uploadedAt: row.uploadedAt,
updatedAt: row.updatedAt,
storageContext: 'mothership' as const,
}
}
Expand Down
1 change: 1 addition & 0 deletions apps/sim/lib/copilot/tools/handlers/upload-file-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function toWorkspaceFileRecord(row: typeof workspaceFiles.$inferSelect): Workspa
uploadedBy: row.userId,
deletedAt: row.deletedAt,
uploadedAt: row.uploadedAt,
updatedAt: row.updatedAt,
storageContext: 'mothership',
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface WorkspaceFileRecord {
uploadedBy: string
deletedAt?: Date | null
uploadedAt: Date
updatedAt: Date
/** Pass-through to `downloadFile` when not default `workspace` (e.g. chat mothership uploads). */
storageContext?: 'workspace' | 'mothership'
}
Expand Down Expand Up @@ -375,6 +376,7 @@ export async function getWorkspaceFileByName(
uploadedBy: file.userId,
deletedAt: file.deletedAt,
uploadedAt: file.uploadedAt,
updatedAt: file.updatedAt,
}
}

Expand Down Expand Up @@ -423,6 +425,7 @@ export async function listWorkspaceFiles(
uploadedBy: file.userId,
deletedAt: file.deletedAt,
uploadedAt: file.uploadedAt,
updatedAt: file.updatedAt,
}))
} catch (error) {
logger.error(`Failed to list workspace files for ${workspaceId}:`, error)
Expand Down Expand Up @@ -560,6 +563,7 @@ export async function getWorkspaceFile(
uploadedBy: file.userId,
deletedAt: file.deletedAt,
uploadedAt: file.uploadedAt,
updatedAt: file.updatedAt,
}
} catch (error) {
logger.error(`Failed to get workspace file ${fileId}:`, error)
Expand Down Expand Up @@ -638,7 +642,7 @@ export async function updateWorkspaceFileContent(

await db
.update(workspaceFiles)
.set({ size: content.length, contentType: nextContentType })
.set({ size: content.length, contentType: nextContentType, updatedAt: new Date() })
.where(
and(
eq(workspaceFiles.id, fileId),
Expand Down Expand Up @@ -707,7 +711,7 @@ export async function renameWorkspaceFile(
try {
updated = await db
.update(workspaceFiles)
.set({ originalName: trimmedName })
.set({ originalName: trimmedName, updatedAt: new Date() })
.where(
and(
eq(workspaceFiles.id, fileId),
Expand Down Expand Up @@ -807,7 +811,7 @@ export async function restoreWorkspaceFile(workspaceId: string, fileId: string):

await db
.update(workspaceFiles)
.set({ deletedAt: null, originalName: newName })
.set({ deletedAt: null, originalName: newName, updatedAt: new Date() })
.where(
and(
eq(workspaceFiles.id, fileId),
Expand Down
1 change: 1 addition & 0 deletions packages/db/migrations/0197_unknown_the_captain.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "workspace_files" ADD COLUMN "updated_at" timestamp DEFAULT now() NOT NULL;
Loading
Loading