feat(copilot): open the table on the view table_views just wrote - #7166
feat(copilot): open the table on the view table_views just wrote#7166j15z wants to merge 4 commits into
Conversation
Direct main-agent tools for saved table views. create_table_view takes a table id (optional name, config, isDefault) and returns the view id; edit_table_view takes a view id plus a config patch and resolves the owning table from the view. Both results name the table and view, so the resource panel opens the table pinned to that view, and an already-open table switches to it once its views list carries the id (view-pin store). viewId now rides the resource stream descriptor and chat-resource persistence so the pin survives reopening the chat.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Greptile SummaryThe PR propagates saved-view identifiers through Copilot resource events and persistence so embedded tables open or switch to the view modified by the table agent.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the prior pin-lifecycle concern is covered by shared teardown and stale-generation checks, and default-view creation and promotion now serialize on the same transaction-scoped lock.
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts | Resets pending table-view pins during chat reset and chat-selection teardown; the previously reported detachment path remains covered. |
| apps/sim/app/workspace/[workspaceId]/home/hooks/stream/handle-resource-event.ts | Extracts table view identifiers from resource upserts, updates open resource state, records a pending pin, and refreshes table queries. |
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx | Applies a pending view only after the refreshed views list contains it, then consumes the sequenced pin. |
| apps/sim/lib/table/views/service.ts | Moves default-on-create and promotion onto the same per-table transactional advisory lock, resolving the previously reported writer race. |
| apps/sim/app/api/copilot/chat/resources/route.ts | Preserves resource metadata such as viewId while re-adding or reordering persisted chat resources. |
| apps/sim/stores/table/view-pin/store.ts | Introduces sequenced per-table pins with guarded consumption and global reset support. |
Sequence Diagram
sequenceDiagram
participant Agent as Table agent
participant Stream as Resource stream
participant Chat as Chat resource state
participant Pin as View-pin store
participant Views as Table views query
participant Table as Embedded table
Agent->>Stream: upsert table resource with viewId
Stream->>Chat: merge and persist viewId
Stream->>Pin: pin(tableId, viewId, sequence)
Stream->>Views: invalidate views query
Views-->>Table: refreshed list contains viewId
Pin-->>Table: pending pin
Table->>Table: select pinned view
Table->>Pin: consume matching sequence
Reviews (4): Last reviewed commit: "refactor(copilot): drop the direct view ..." | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 38 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
- edit_table_view resolves the view's table under a workspace-only context (no table scope exists yet for the delegated principal), then re-enters the table-scoped read and update with that id - updateTableView takes the per-table views lock when promoting, so it serializes with default-on-create instead of racing the unique index - the View N fallback is chosen inside the locked create - unknown column names are classified as validation errors in the shared translation, so the model sees which column it got wrong - pending view pins are reset when a chat is torn down or switched - add and reorder share one chat-resource item schema; reorder merges incoming entries with stored ones so pins and paths survive - mergeChatResource keeps every field the newcomer defines - the pin merge runs for every pinned upsert, not gated on wasAdded
…e_views Views stay with the table subagent's multiplexed table_views; the orchestrator delegates as before. Its create/update/set-default results now name the table and view they wrote, and resource extraction turns that into the pinned table resource, so the panel opens (or switches) the table on that view. Unknown column names are classified as validation errors, and create_view's isDefault lands in the same locked transaction as the insert. The stream/persistence plumbing for viewId, the pin store, and the lock on default promotion are unchanged.
Summary
table_views, the resource panel opens the table pinned to that view — and an already-open table switches to it. No new tools: views stay with the table subagentview-pinstore), since the pin lands before the list refetches and a plain URL write would be treated as a dead view id; pins carry a sequence and reset on chat teardown/switchviewIdnow travels the resource stream descriptor, chat-resource persistence, and the chat-resource contracts (add + reorder share one item schema; reorder merges with stored entries), so the pin survives reopening the chat. This also repairsopen_resource'sviewargument, which never reached the browsertable_views: write results name the table + view; unknown column names come back as validation errors instead of a masked system error;create_view'sisDefaultlands in the same locked transaction as the insertupdateTableViewtakes the per-table views lock when promoting, so promotion and default-on-create no longer race the partial unique indexmergeChatResourcekeeps every field a re-added resource defines (path,executionId,viewId)table_viewsfilter/sort)Type of Change
Testing
bun run type-check,bun run lint,bun run check:audits(incl.check:api-validation)table_viewspayloads, extraction, the pin store, the merge rule, the lock, and the stream contractChecklist
Companion: simstudioai/mothership#461