Skip to content

feat(tables): autosave persisted default views - #6724

Open
j15z wants to merge 1 commit into
stagingfrom
feat/better-table-views-ux
Open

feat(tables): autosave persisted default views#6724
j15z wants to merge 1 commit into
stagingfrom
feat/better-table-views-ux

Conversation

@j15z

@j15z j15z commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

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

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Focused table, view-state, service, and query-hook suite: 78 tests passed.
  • bun run --cwd apps/sim type-check
  • bun run check:api-validation
  • Review focus: default-view creation stays transactional with table creation, and concurrent view updates merge configuration patches without losing newer state.

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)

Screenshots/Videos

Not included. Automated tests cover default selection, reload hydration, and autosave behavior.

Post-Deploy Monitoring & Validation

  • For 24 hours, monitor table creation and table-view create/update errors for new 4xx or 5xx responses.
  • Validate that a newly created table has exactly one "Default" view and that filter, sort, and layout changes survive navigation and reload.
  • Treat repeated save-error toasts, missing default views, or restored stale configuration as rollback triggers.
  • Owner: Tables feature maintainers. Roll back this PR if the creation or persistence error rate increases materially.

Compound Engineering

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 15, 2026 2:37am

Request Review

@cursor

cursor Bot commented Aug 15, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches core table detail state, URL view params, and concurrent view PATCH ordering; legacy tables without a default view rely on the All fallback until backfill.

Overview
Table views no longer use a Save chip — filter, sort, and column visibility changes on the active view persist immediately via configPatch, alongside the existing layout autosave. The dirty-state helpers and “Save as view” flow are removed; new views are created blank (named first via Create in the modal) and configured after.

New tables get a persisted default view (Default, empty config) at creation. The UI treats that as the active view before the URL ?view= catches up, upgrades legacy All URLs when a default exists, and shows All only for legacy tables without a backfilled default.

Shared view-state helpers (resolveTableViewSelection, revision checks) keep the grid, menu, and resolve effect aligned and avoid rewinding local state while autosave is pending or when stale list responses arrive. useUpdateTableView uses a scoped mutation queue so rapid patches stay ordered; list invalidation no longer blocks the queue.

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.

@j15z j15z changed the title feat/better table views ux feat(tables): autosave persisted default views Aug 15, 2026
@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes saved table views to use persisted defaults and immediate autosaving for filters, sorting, visibility, and layout.

  • Seeds a Default view during normal table creation and synchronously adopts persisted defaults in the table UI.
  • Serializes view updates and reconciles refreshed configurations by persisted revision.
  • Simplifies new-view creation and updates the views menu and associated tests.
  • The workspace-fork creation path remains outside the new default-view lifecycle.

Confidence Score: 4/5

The 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

Important Files Changed

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]
Loading

Reviews (1): Last reviewed commit: "feat(tables): autosave persisted default..." | Re-trigger Greptile

Comment on lines 637 to +650
}

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,
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 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)

Comment on lines +1 to +3
/**
* @vitest-environment jsdom
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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.

Suggested change
/**
* @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!

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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 })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9bdac1d. Configure here.

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