Skip to content

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

Open
j15z wants to merge 8 commits into
stagingfrom
feat/better-table-views-ux
Open

feat(tables): autosave persisted default views#6724
j15z wants to merge 8 commits 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. When table-views is enabled, filter, sort, column visibility, and layout changes 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; this PR intentionally adds no backfill migration. Workspace forks now copy every saved table view, and a copied legacy table receives a persisted "Default" view seeded from its current table configuration so the fork preserves what users see.

Initial hydration preserves a deep-linked sort and queues filter, sort, or hidden-column gestures made before the views query identifies their owner. A stale table-view URL adopts the real default before pending layout is resolved, so an early resize is never written to the legacy table metadata under the wrong owner.

Upgrading a legacy All URL to the persisted default also preserves and flushes any local work completed during hydration. Layout and hidden-column metadata written while the flag was off remains the baseline for fields an ungated Default view has not stored yet, and early layout gestures are saved to the owner chosen during hydration. Same-view autosave echoes use order-insensitive structural equality to skip an identical filter instead of remounting the editor and wiping an in-progress draft. A newly created blank view stays blank while its query-cache row and URL selection catch up, and deleting a sorted column removes the dead sort from both the URL and persisted view. The current default cannot be deleted from the Views menu; another view must become default first, so the table always retains an autosave owner.

The feature flag remains a UI gate: view controls, fetching, hydration, and autosave stay behind table-views in both table-detail and embedded surfaces. The routes and persistence layer remain available by design, and new or forked tables create/copy view rows even while the flag is off so rollout state survives toggles. With the flag off, users continue to get the legacy Filter/Sort behavior.

The child PR, #6725, adds default-view selection and refines the view, column, and filter controls.

Type of Change

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

Testing

  • Five focused view-menu, view-state, service, query-hook, and workspace-fork suites: 104 tests passed.
  • bun run lint and bun run lint:check
  • bun run check:audits (30 repository policy audits)
  • bun run type-check (26 package tasks)
  • bun run apps/sim/scripts/check-block-registry.ts origin/staging
  • bun run check:migrations origin/staging
  • Review focus: default-view creation stays transactional with table creation, hydration cannot rewind early local work, concurrent view updates merge configuration patches without losing newer state, and workspace forks preserve persisted and legacy table configurations.

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, autosave behavior, and workspace-fork preservation.

Post-Deploy Monitoring & Validation

  • For 24 hours, monitor table creation, workspace-fork, 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.
  • Validate that forked tables preserve their saved views and that a legacy table without views receives one persisted default in the fork.
  • Treat repeated save-error toasts, missing or duplicate default views, or restored stale configuration as rollback triggers.
  • Owner: Tables feature maintainers. Roll back this PR if the creation, fork, 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.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 20, 2026 3:42am

Request Review

@cursor

cursor Bot commented Aug 15, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches table-detail hydration, concurrent autosave, and default-view ownership across URL, cache, and DB; mistakes could mis-route layout writes or flash stale config, but behavior is heavily tested and legacy tables keep the All fallback.

Overview
Replaces the manual Save / Save as view flow with immediate autosave of filter, sort, column visibility, and layout into the active view, and seeds new tables with a persisted Default view at creation time.

Hydration and selection move into view-state (resolveTableViewSelection, resolveTableViewConfig, revision tracking via shouldApplyTableViewRevision) so the grid, menu, and URL stay aligned while the default is adopted, legacy All URLs upgrade when a default exists, and server echoes do not rewind in-flight edits.

Views menu shows the default name instead of a generic label, hides the synthetic All row when a default exists, and blocks delete on the default view. SaveViewModal drops the create mode (name-only new vs rename).

Backend / forks: table creation and workspace fork copy insert default views; forked legacy tables without views get a Default seeded from table metadata. useUpdateTableView uses a per-table mutation scope so config patches serialize in gesture order.

The table-views flag remains the UI gate; no migration backfills existing tables.

Reviewed by Cursor Bugbot for commit 2a379fa. 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

The PR replaces the unsaved state of newly created tables with persisted default views and adds autosaving and hydration reconciliation for view configuration.

  • Creates default views transactionally with new tables.
  • Copies saved views during workspace forks and seeds legacy forked tables from their metadata.
  • Autosaves filter, sort, hidden-column, and layout changes through serialized view updates.
  • Preserves local gestures and deep-linked state while resolving the active persisted view.
  • Prevents deletion of the current default view.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; both previously reported issues are fixed in the current code.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx Adds persisted-default resolution, initial-state preservation, serialized autosave routing, and default-view lifecycle handling without leaving an eligible follow-up defect.
apps/sim/app/workspace/[workspaceId]/tables/[tableId]/view-state.ts Centralizes active/default selection, metadata inheritance, and revision comparison for table-view hydration.
apps/sim/hooks/queries/tables.ts Serializes view mutations per table and reconciles returned revisions without holding the mutation queue open for refetching.
apps/sim/lib/table/service.ts Creates each new table and its persisted default view within the same database transaction.
apps/sim/ee/workspace-forking/lib/copy/copy-resources.ts Fixes the prior fork issue by copying source views to remapped table IDs and seeding a default for legacy tables.
apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/views-menu/views-menu.test.tsx Adds genuine DOM interaction coverage, making the file-level jsdom environment appropriate.
packages/db/schema.ts Updates table-view schema documentation to reflect persisted defaults while retaining the existing uniqueness constraint.

Sequence Diagram

sequenceDiagram
  participant UI as Table UI
  participant Cache as Views Query Cache
  participant API as Table View API
  participant DB as Postgres
  UI->>Cache: Resolve selected or default view
  Cache-->>UI: Active view configuration
  UI->>UI: Apply filter, sort, columns, and layout
  UI->>API: Autosave configuration patch
  API->>DB: Merge patch into persisted view
  DB-->>API: Updated view revision
  API-->>Cache: Reconcile cached view
  Cache-->>UI: Apply newer revision after queue settles
Loading

Reviews (8): Last reviewed commit: "fix(tables): preserve valid saved sort o..." | Re-trigger Greptile

Comment thread apps/sim/lib/table/service.ts
Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx
@j15z
j15z force-pushed the feat/better-table-views-ux branch from 9bdac1d to 30c1a95 Compare August 19, 2026 19:32
@j15z
j15z requested a review from a team as a code owner August 19, 2026 19:32
@j15z
j15z changed the base branch from staging to dev August 19, 2026 19:38
@j15z

j15z commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@j15z

j15z commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx
Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx Outdated
@j15z
j15z force-pushed the feat/better-table-views-ux branch from 30c1a95 to bbb38f2 Compare August 19, 2026 20:14
@j15z

j15z commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@j15z

j15z commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

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

✅ 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 bbb38f2. Configure here.

@j15z
j15z force-pushed the feat/better-table-views-ux branch from bbb38f2 to 17c16ea Compare August 20, 2026 00:02
@j15z
j15z changed the base branch from dev to staging August 20, 2026 00:04
@j15z
j15z force-pushed the feat/better-table-views-ux branch from 17c16ea to 43482c2 Compare August 20, 2026 00:06
@j15z
j15z force-pushed the feat/better-table-views-ux branch from 43482c2 to ea31794 Compare August 20, 2026 00:22
@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx
Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx
@j15z
j15z force-pushed the feat/better-table-views-ux branch from ea31794 to 677a2fa Compare August 20, 2026 01:09
Comment thread apps/sim/lib/table/service.ts
Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx Outdated
@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx
@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx
Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx
Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx Outdated

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

✅ 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 daefc28. Configure here.

@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 03a4e49. Configure here.

Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx Outdated
@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

Creating the first view left isDefault false, so the legacy All
fallback stayed in the menu instead of handing off to the new view.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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