Skip to content

feat(tables): create and open views from chat - #6058

Open
BillLeoutsakosvl346 wants to merge 6 commits into
stagingfrom
improvement/chat-table-views
Open

feat(tables): create and open views from chat#6058
BillLeoutsakosvl346 wants to merge 6 commits into
stagingfrom
improvement/chat-table-views

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • add durable view chat resources that reopen the live source Table with the saved View selected
  • add write-gated user_table.create_view with workspace validation, canonical column/option ID conversion, generated collision-free names, and automatic resource opening
  • make saved Views alphabetical, label the implicit state Default view, auto-save View filters/sorts, and prune deleted-column predicates safely
  • build on the saved-Views CRUD, migration, selector, URL state, and layout persistence already present on staging

Before / after

Before: Chat could query Table rows, but an explicit “show me this filtered/sorted Table” request could not create a durable UI surface.

After: The same request creates a named View, opens it beside the conversation, persists it with the chat, and restores the live filtered Table on reload. Ordinary analytical questions continue using read-only query_rows.

Validation

  • 221 focused Table/Copilot/resource tests passed
  • 560 related Table tests passed
  • Sim and DB TypeScript checks passed
  • focused Biome checks passed
  • API contract audit, React Query audit, migration safety, and generated catalog check passed
  • full local app lint is blocked only by pre-existing ignored e2e/.runs artifacts and two existing fit.fit() false positives; changed files are clean

Canonical Copilot contract

Manual demo

  1. Open a chat in a workspace containing a Table.
  2. Ask: “Show the Leads table where Status is Open, sorted by Company descending.”
  3. Confirm a named View opens beside chat with the live editable grid.
  4. Reload the chat, switch between Default view and the saved View, then edit filter/sort and confirm they persist.

Notes

  • no public v1 API change
  • no row copying; Views reference their source Table
  • source Table permissions remain authoritative
  • generated Playwright artifacts remain untracked and ignored

@vercel

vercel Bot commented Jul 29, 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 Jul 29, 2026 8:12pm

Request Review

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches copilot write tools, workspace-scoped View resolution, and auto-persisted table filters/sorts; mistakes could widen row sets or open wrong tables, but permissions stay table-authoritative and read-only members are gated on create_view.

Overview
Chat can now persist View resources (tableId:viewId) that reopen the live source Table with the saved filter/sort, instead of only opening whole tables or using read-only query_rows.

Copilot & mothership: Adds write-gated user_table.create_view (workspace checks, column/option canonicalization, auto naming, opens the View tab). open_resource and tool extraction honor view; generated catalogs include view in openable types. Embedded UI: EmbeddedViewTable parses composite ids, respects the views flag, and passes viewId into embedded Table with local selection so host URL state does not race chat tab switches.

Table UX: Renames the implicit state to Default view; auto-saves filter/sort on an active saved View for editors; lists Views alphabetically. Filter safety: pruneViewFilterForColumns drops predicates on deleted column ids (read, write, and create_view validation) so stale configs do not break queries or dirty-state.

Tests cover embedding, Views menu, resource open/resolve, create_view, and read-only gating; Playwright artifact paths are gitignored.

Reviewed by Cursor Bugbot for commit b3fc19e. Bugbot is set up for automated code reviews on this repo. Configure here.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor @greptile-apps Please review the chat-created Table Views implementation, including permission boundaries, canonical filter/sort ID conversion, durable View resources, autosave behavior, and stale-column pruning. Flag any correctness, security, persistence, or regression issues before merge.

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

Comment thread apps/sim/lib/copilot/tools/server/table/user-table.ts
Comment thread apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx
Comment thread apps/sim/lib/copilot/tools/handlers/resources.ts
@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds durable chat View resources that open the live source Table with a saved View selected.

  • user_table.create_view creates Views with workspace checks, canonical filters/sorts, and auto-open as view resources (tableId:viewId)
  • open_resource resolves bare and composite View ids, verifies source Table/workspace, and returns the composite resource id
  • Embedded View UI, registry invalidation, context mapping, Default view labeling, filter prune, and View filter/sort auto-save

Confidence Score: 5/5

Safe to merge; the prior composite View id open failure is fixed and no remaining blocking issues were identified on that path.

open_resource now parses persisted tableId:viewId values, looks up the canonical view id, rejects mismatched source tables, keeps workspace checks, and tests cover reopen and mismatch cases.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/handlers/resources.ts open_resource parses composite View ids, loads by canonical viewId, rejects table mismatch and cross-workspace sources, and returns tableId:viewId.
apps/sim/lib/copilot/resources/types.ts Adds tableViewResourceId/parseTableViewResourceId and persists view as a chat resource type.
apps/sim/lib/copilot/tools/server/table/user-table.ts Adds write-gated create_view with validation, naming, and resource emission for auto-open.
apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx Embedded View selection, missing-view cleanup, and filter/sort auto-save on active Views.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/components/embedded-view-table/embedded-view-table.tsx Parses composite resource ids and mounts the source Table with the saved View when views are enabled.

Sequence Diagram

sequenceDiagram
  participant Chat as Copilot chat
  participant UT as user_table.create_view
  participant OR as open_resource
  participant UI as EmbeddedViewTable
  participant T as Table (source)

  Chat->>UT: create_view(tableId, filter, sort)
  UT-->>Chat: view + resources[view, tableId:viewId]
  Chat->>OR: "open type=view id=tableId:viewId"
  OR->>OR: parse composite id, load view, check table/workspace
  OR-->>Chat: resources[view, tableId:viewId]
  Chat->>UI: render resource id
  UI->>T: tableId + viewId embedded
Loading

Reviews (5): Last reviewed commit: "fix(tables): clear deleted embedded view..." | Re-trigger Greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor @greptile-apps Please re-review the latest commit a7d12e5. The three reported findings are fixed with regression coverage: composite View reopen, create_view auto-opening the View resource, and synchronous embedded View ownership.

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

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

Copy link
Copy Markdown
Contributor Author

@cursor @greptile-apps Please run a fresh review on a59c683. The latest Bugbot findings are addressed: View embeds now honor the resolved feature flag, and stale stable-column filter IDs are recursively pruned before query/autosave with regression coverage.

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

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/lib/copilot/tools/server/table/user-table.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor @greptile-apps Please re-review acfef82. The three latest edge cases are fixed with focused coverage: disabled View resources fail closed, stale chat View IDs fall back without adopting another saved View, and empty model filters persist as null.

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

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

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

Copy link
Copy Markdown
Contributor Author

@cursor @greptile-apps Please re-review b3fc19e. It fixes the latest deleted-View embed finding by clearing inherited host state when the missing resource falls back to Default/All. Focused tests (97), Biome, and app TypeScript are green locally.

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Merge-readiness update for b3fc19e:

  • Full CI green: lint/test/audits/schema+migration checks and production app build
  • Cursor Bugbot clean on latest commit
  • Greptile clean on latest commit
  • Companion contract check green
  • 0 unresolved review threads
  • GitHub reports CLEAN and MERGEABLE
  • Local focused suite: 97 tests; app TypeScript and Biome green

Companion catalog PR: simstudioai/mothership#378 (checks green, mergeable, awaiting the repository-required human approval).

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