feat(tables): preview referenced rows inline - #7106
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThe PR adds feature-flagged inline previews for referenced table rows while preserving reference integrity across table lifecycle and workspace-copy operations.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/hooks/queries/tables.ts | Adds lightweight table-name loading, on-demand reference previews, and targeted invalidation after local row mutations. |
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/reference-row-preview.tsx | Implements the loading, error, missing-row, and ready states for the inline referenced-row preview. |
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx | Integrates reference selection, preview query state, and virtualized preview-row rendering into the table grid. |
| apps/sim/ee/workspace-forking/lib/copy/copy-resources.ts | Copies referenced-table dependencies transitively and deterministically remaps copied table and row identities. |
| apps/sim/lib/table/service.ts | Adds lightweight table-name reads and reference-integrity checks around table archive and restore operations. |
| apps/sim/lib/table/column-types/registry.server.ts | Centralizes reference discovery, remapping, validation, and deletion-blocker detection in the server column registry. |
Sequence Diagram
sequenceDiagram
participant User
participant Grid as Table grid
participant Names as Table names query
participant Preview as Reference preview query
participant API as Table API
User->>Grid: Open table
Grid->>Names: Load lightweight table labels
Names->>API: GET /api/table/names
API-->>Names: Table IDs and names
User->>Grid: Click reference cell
Grid->>Preview: Request referenced schema and row
Preview->>API: Fetch table detail and row detail
API-->>Preview: Schema and referenced row
Preview-->>User: Render inline preview
Reviews (2): Last reviewed commit: "feat(tables): preview referenced rows in..." | Re-trigger Greptile
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Confidence score: 4/5
- In
cell-render.tsx, double-clicking a reference chip can also trigger the cell’s inline edit mode after opening the preview, creating conflicting interactions; stopdblclickpropagation on the chip to match URL cell behavior.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/cell-render.tsx">
<violation number="1" location="apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/cell-render.tsx:409">
P2: Double-clicking a reference chip still bubbles `dblclick` to the cell, so opening the preview can also enter inline edit mode. Stop double-click propagation on the chip, matching the URL cell behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
bc7186a to
e4ded13
Compare
e4ded13 to
a3d2126
Compare
a3d2126 to
5eef2b1
Compare
5eef2b1 to
2921222
Compare
2921222 to
2deec54
Compare
2deec54 to
1b145fe
Compare
1b145fe to
b4cbd5e
Compare
b4cbd5e to
377c35d
Compare
377c35d to
9a8addc
Compare
9a8addc to
705f382
Compare
705f382 to
bd15a78
Compare
bd15a78 to
a82a46d
Compare
a82a46d to
7f35686
Compare
7f35686 to
073495c
Compare
073495c to
e16aa7a
Compare
|
@cubic-dev-ai review this PR |
@j15z I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
3 issues found across 38 files
Confidence score: 2/5
apps/sim/lib/folders/config.tscan leave cyclically referenced tables unarchivable:archiveTableChildrendeletes siblings one at a time, so an active sibling blocksdeleteTable. Make archive handling account for the full reference group before deleting tables.apps/sim/hooks/queries/tables.tscan show an outdated reference preview becausestaleTime: Infinitypreserves the mounted{ table, row }snapshot after target schema/name mutations. Invalidate these previews or derive the schema and name from the invalidated source.apps/sim/hooks/queries/utils/table-keys.tscauses row creates, deletes, and imports to refetch the table-names endpoint when reference columns are enabled, adding unnecessary network work. Separate thenamesinvalidation key from the broaderlistsprefix.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/folders/config.ts">
<violation number="1" location="apps/sim/lib/folders/config.ts:394">
P1: When tables in the folder reference each other, this guard returns `null`, but `archiveTableChildren` deletes them one at a time. The still-active sibling then blocks `deleteTable`, so cycles can never be archived and other orders can fail after partial progress. Pass the full archive cohort into each reference check or archive the cohort atomically.</violation>
</file>
<file name="apps/sim/hooks/queries/utils/table-keys.ts">
<violation number="1" location="apps/sim/hooks/queries/utils/table-keys.ts:23">
P2: When reference columns are enabled, row creates, deletes, and imports refetch the table-names endpoint because `names` shares the `lists` invalidation prefix, even though those mutations cannot change table names. Put names under a separate key root and invalidate that key only from table create/rename/delete/archive operations.</violation>
</file>
<file name="apps/sim/hooks/queries/tables.ts">
<violation number="1" location="apps/sim/hooks/queries/tables.ts:403">
P2: While this preview is mounted, `staleTime: Infinity` keeps its `{ table, row }` snapshot unchanged. Invalidate reference previews for target schema/name mutations, or derive the preview schema and name from the invalidated detail cache.</violation>
</file>
| } | ||
| } | ||
|
|
||
| const [blocker] = await findActiveTableReferenceBlockers(db, workspaceId, { |
There was a problem hiding this comment.
P1: When tables in the folder reference each other, this guard returns null, but archiveTableChildren deletes them one at a time. The still-active sibling then blocks deleteTable, so cycles can never be archived and other orders can fail after partial progress. Pass the full archive cohort into each reference check or archive the cohort atomically.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/sim/lib/folders/config.ts, line 394:
<comment>When tables in the folder reference each other, this guard returns `null`, but `archiveTableChildren` deletes them one at a time. The still-active sibling then blocks `deleteTable`, so cycles can never be archived and other orders can fail after partial progress. Pass the full archive cohort into each reference check or archive the cohort atomically.</comment>
<file context>
@@ -376,12 +383,22 @@ async function guardLockedTables({
+ }
+ }
+
+ const [blocker] = await findActiveTableReferenceBlockers(db, workspaceId, {
+ folderIds: new Set(folderIds),
+ })
</file context>
| lists: () => [...tableKeys.all, 'list'] as const, | ||
| list: (workspaceId?: string, scope: TableQueryScope = 'active') => | ||
| [...tableKeys.lists(), workspaceId ?? '', scope] as const, | ||
| names: (workspaceId?: string) => [...tableKeys.lists(), 'names', workspaceId ?? ''] as const, |
There was a problem hiding this comment.
P2: When reference columns are enabled, row creates, deletes, and imports refetch the table-names endpoint because names shares the lists invalidation prefix, even though those mutations cannot change table names. Put names under a separate key root and invalidate that key only from table create/rename/delete/archive operations.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/sim/hooks/queries/utils/table-keys.ts, line 23:
<comment>When reference columns are enabled, row creates, deletes, and imports refetch the table-names endpoint because `names` shares the `lists` invalidation prefix, even though those mutations cannot change table names. Put names under a separate key root and invalidate that key only from table create/rename/delete/archive operations.</comment>
<file context>
@@ -20,11 +20,15 @@ export const tableKeys = {
lists: () => [...tableKeys.all, 'list'] as const,
list: (workspaceId?: string, scope: TableQueryScope = 'active') =>
[...tableKeys.lists(), workspaceId ?? '', scope] as const,
+ names: (workspaceId?: string) => [...tableKeys.lists(), 'names', workspaceId ?? ''] as const,
details: () => [...tableKeys.all, 'detail'] as const,
detail: (tableId: string) => [...tableKeys.details(), tableId] as const,
</file context>
| return { table, row } | ||
| }, | ||
| enabled: Boolean(workspaceId && tableId && rowId && sourceRowId && sourceColumnKey), | ||
| staleTime: TABLE_REFERENCE_PREVIEW_STALE_TIME, |
There was a problem hiding this comment.
P2: While this preview is mounted, staleTime: Infinity keeps its { table, row } snapshot unchanged. Invalidate reference previews for target schema/name mutations, or derive the preview schema and name from the invalidated detail cache.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/sim/hooks/queries/tables.ts, line 403:
<comment>While this preview is mounted, `staleTime: Infinity` keeps its `{ table, row }` snapshot unchanged. Invalidate reference previews for target schema/name mutations, or derive the preview schema and name from the invalidated detail cache.</comment>
<file context>
@@ -314,6 +370,44 @@ export function useTable(workspaceId: string | undefined, tableId: string | unde
+ return { table, row }
+ },
+ enabled: Boolean(workspaceId && tableId && rowId && sourceRowId && sourceColumnKey),
+ staleTime: TABLE_REFERENCE_PREVIEW_STALE_TIME,
+ gcTime: TABLE_REFERENCE_PREVIEW_GC_TIME,
+ refetchOnMount: 'always',
</file context>
e16aa7a to
9639bfa
Compare
9639bfa to
55f46e4
Compare
Summary
Reference cells display the target table name and open the referenced row inline. Table load fetches only the unique names needed by its Reference columns, and previews wait for their schema and row before appearing, so users do not see placeholder content flash.
Performance
The count is structural: the previous path performed one bulk preflight scan plus one scan per table. The new explicit-table phase shares one locked scan for the full selection.
Type of Change
Testing
bun run --cwd apps/sim type-checkbunx biome checkon the 7 files changed by the delete batching passbun run lint:check(26 tasks)bun run check:api-validation:strictbun run check:react-querybun run check:audits(45 audits)Checklist
Post-Deploy Monitoring & Validation
TABLE_REFERENCE_COLUMNSis disabled.TABLE_REFERENCE_COLUMNSfirst; roll back feat(tables): preview referenced rows inline #7106 if errors continue.