Skip to content

feat(files): default sort by updated and add updated sort option#4279

Merged
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/sort-by-updated
Apr 23, 2026
Merged

feat(files): default sort by updated and add updated sort option#4279
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/sort-by-updated

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Default sort across Files, Knowledge Base, and Tables pages is now "Last Updated" (desc) instead of "Created"
  • Added "Last Updated" option to the Files sort dropdown (KB and Tables already had it)
  • Added updated_at column to workspace_files table; bumped on content update, rename, and restore
  • Propagated updatedAt through WorkspaceFileRecord and API

Type of Change

  • New feature

Testing

Tested manually — file list now sorts by most-recently-updated by default; renaming a file bumps it to the top.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 23, 2026 9:55pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 23, 2026

PR Summary

Medium Risk
Moderate risk because it adds a new non-null DB column and changes default sorting behavior across multiple resource lists; potential issues are migration/backfill and any callers expecting uploadedAt-based ordering.

Overview
Updates Files/Knowledge Base/Tables listings to default sort by updated (desc) instead of created, and adds a “Last Updated” column + sort option to the Files table.

Introduces workspace_files.updated_at (non-null, default now()), propagates updatedAt through WorkspaceFileRecord (including mothership upload records), and bumps updatedAt on workspace file content updates, renames, and restores.

Reviewed by Cursor Bugbot for commit 3eab29a. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 23, 2026

Greptile Summary

This PR adds an updated_at column to workspace_files, propagates it through WorkspaceFileRecord and all read/write paths, and changes the default sort for Files, Knowledge Base, and Tables pages from "Created" to "Last Updated" (desc). It also adds a "Last Updated" sort option and table column to the Files page, where it was previously missing.

Confidence Score: 5/5

Safe to merge — migration is additive, all read/write paths are correctly updated, and remaining findings are P2 style suggestions.

All P0/P1 concerns are absent: migration is a safe additive column with a default, TypeScript interface change is fully propagated across mapped call sites, and default sort fallback works correctly. The two open findings are P2 style suggestions (column order inconsistency and missing updatedAt bump on file materialization).

apps/sim/lib/copilot/tools/handlers/materialize-file.ts — missing updatedAt bump during materialization

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/files.tsx Adds 'Last Updated' column to table and sort dropdown, changes default sort to 'updated'; column order in COLUMNS array is inconsistent with sort dropdown order.
apps/sim/lib/uploads/contexts/workspace/workspace-file-manager.ts Adds updatedAt to WorkspaceFileRecord interface and propagates it through all read paths; bumps updatedAt on content update, rename, and restore operations.
packages/db/migrations/0197_unknown_the_captain.sql Adds updated_at column to workspace_files with DEFAULT now() NOT NULL; backfills existing rows to migration timestamp.
packages/db/schema.ts Adds updatedAt: timestamp('updated_at').notNull().defaultNow() to workspaceFiles table definition, consistent with migration.
apps/sim/lib/copilot/tools/handlers/materialize-file.ts Adds updatedAt to toFileRecord mapping but the materialize update itself does not bump updatedAt, so materialized files won't surface at the top of the default sort.
apps/sim/lib/copilot/tools/handlers/upload-file-reader.ts Adds updatedAt to toWorkspaceFileRecord mapping; straightforward propagation change.
apps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx Changes default sort column from 'created' to 'updated'; safe since 'updated' was already a valid sort option.
apps/sim/app/workspace/[workspaceId]/tables/tables.tsx Changes default sort column from 'created' to 'updated'; safe since 'updated' was already a valid sort option.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx Adds updatedAt: STREAMING_EPOCH to the streaming placeholder object to satisfy the updated WorkspaceFileRecord interface.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User Action] --> B{Action Type}
    B -->|Upload| C[uploadWorkspaceFile\nDB default: updatedAt = now]
    B -->|Edit Content| D[updateWorkspaceFileContent\nupdatedAt = new Date]
    B -->|Rename| E[renameWorkspaceFile\nupdatedAt = new Date]
    B -->|Restore| F[restoreWorkspaceFile\nupdatedAt = new Date]
    B -->|Materialize from Chat| G[materialize-file.ts\nupdatedAt NOT bumped]
    C --> H[WorkspaceFileRecord.updatedAt]
    D --> H
    E --> H
    F --> H
    G --> H
    H --> I[Files page\nDefault sort: updated desc]
Loading

Reviews (2): Last reviewed commit: "feat(files): show Last Updated column" | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/files/files.tsx
Matches the visible-column pattern already used on Knowledge and Tables
so users can see the value they're sorting by.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/sort-by-updated branch from 954aa9a to 3eab29a Compare April 23, 2026 21:52
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3eab29a. Configure here.

@waleedlatif1 waleedlatif1 merged commit 0ae19da into staging Apr 23, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/sort-by-updated branch April 23, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant