feat(tables): autosave persisted default views - #6724
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview New tables get a persisted default view ( Shared Tests cover view selection labels, revision application, and mutation ordering. Reviewed by Cursor Bugbot for commit 9bdac1d. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR changes saved table views to use persisted defaults and immediate autosaving for filters, sorting, visibility, and layout.
Confidence Score: 4/5The workspace-fork path must create or copy a default view before merging; the unnecessary jsdom test environment is non-blocking. Normal creation now establishes the persisted default required by the new autosave model, but workspace forks bypass that insertion and produce tables that remain on the legacy persistence path. Files Needing Attention: apps/sim/lib/table/service.ts; apps/sim/ee/workspace-forking/lib/copy/copy-resources.ts; apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/views-menu/views-menu.test.tsx
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx | Replaces explicit saves with serialized autosaving and adds default-view adoption and revision reconciliation. |
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/view-state.ts | Centralizes active/default selection and timestamp-based view revision decisions. |
| apps/sim/hooks/queries/tables.ts | Serializes table-view mutations and performs asynchronous authoritative list reconciliation. |
| apps/sim/lib/table/service.ts | Seeds persisted defaults for createTable callers but leaves direct table-copy creation paths uncovered. |
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/views-menu/views-menu.test.tsx | Adds default-label coverage but selects jsdom despite using only server rendering and string assertions. |
| packages/db/schema.ts | Updates table-view documentation to describe seeded defaults and the legacy fallback without changing schema shape. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Normal table creation] --> B[createTable]
B --> C[Insert table definition]
B --> D[Insert persisted Default view]
E[Workspace fork] --> F[Directly copy table definition]
F --> G[No persisted default view]
D --> H[View-backed autosave]
G --> I[Legacy All / metadata behavior]
Reviews (1): Last reviewed commit: "feat(tables): autosave persisted default..." | Re-trigger Greptile
| } | ||
|
|
||
| await trx.insert(userTableDefinitions).values(newTable) | ||
| await trx.insert(tableViews).values({ | ||
| id: generateId(), | ||
| tableId, | ||
| workspaceId: data.workspaceId, | ||
| name: DEFAULT_TABLE_VIEW_NAME, | ||
| config: {}, | ||
| isDefault: true, | ||
| createdBy: data.userId, | ||
| createdAt: now, | ||
| updatedAt: now, | ||
| }) |
There was a problem hiding this comment.
Forks miss persisted default views
When a workspace containing a table is forked, the fork path inserts userTableDefinitions directly and bypasses this new default-view insertion, causing forked tables to remain on the legacy All/metadata persistence path instead of using the view-backed autosave behavior established for newly created tables.
Knowledge Base Used: User Tables (apps/sim/lib/table)
| /** | ||
| * @vitest-environment jsdom | ||
| */ |
There was a problem hiding this comment.
Unnecessary jsdom test environment
This test only uses renderToStaticMarkup and string assertions, so selecting jsdom initializes an unnecessary browser-like environment and obscures the test's actual runtime requirements.
| /** | |
| * @vitest-environment jsdom | |
| */ |
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9bdac1d. Configure here.
|
|
||
| const handleHiddenColumnsChange = (next: string[]) => { | ||
| setHiddenColumns(next) | ||
| persistActiveViewConfig({ hiddenColumns: next }) |
There was a problem hiding this comment.
Filter by cell skips autosave
High Severity
handleFilterByCellValue applies the filter locally via replaceFilter but never calls persistActiveViewConfig, unlike handleFilterApply, sort, and hidden-column changes. Under autosave, that filter is lost on reload and can be silently wiped when a later view revision apply runs after layout or rename settles.
Reviewed by Cursor Bugbot for commit 9bdac1d. Configure here.


Summary
This first PR in a two-layer table-views stack replaces the unsaved "All" state for new tables with a persisted "Default" view. Filter, sort, column visibility, and layout changes now autosave to the active view, and returning to a table restores the saved default configuration.
Existing tables without a persisted view keep the legacy "All" fallback. Backfilling those tables is intentionally deferred; this PR does not add a migration.
The child PR, #6725, adds default-view selection and refines the view controls.
Type of Change
Testing
bun run --cwd apps/sim type-checkbun run check:api-validationChecklist
Screenshots/Videos
Not included. Automated tests cover default selection, reload hydration, and autosave behavior.
Post-Deploy Monitoring & Validation