Skip to content

feat(tables): preview referenced rows inline - #7106

Open
j15z wants to merge 1 commit into
feat/table-fksfrom
feat/reference-row-preview
Open

feat(tables): preview referenced rows inline#7106
j15z wants to merge 1 commit into
feat/table-fksfrom
feat/reference-row-preview

Conversation

@j15z

@j15z j15z commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

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.

  • One bounded name request handles all direct Reference columns instead of issuing one request per column or loading every table in the workspace.
  • If the opened row contains nested Reference columns, one additional batched name request resolves those chip labels before the preview appears.
  • Clicking another Reference cell updates the open preview directly.
  • Reference integrity is preserved through table/workspace copying, cascading archive and restore, row mutations, and bulk table deletion.
  • Explicit bulk table deletion now scans the reference graph once, archives referrers before their targets, and rejects reference cycles that the singular restore flow could not recover.
  • The global Reference flag from feat(tables): add reference columns #7105 disables the chips, queries, and preview UI together.
  • This PR builds on the Reference column foundation in feat(tables): add reference columns #7105.

Performance

Explicit tables deleted Reference-graph scans before Reference-graph scans now
1 2 1
100 101 1

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

  • New feature

Testing

  • bun run --cwd apps/sim type-check
  • 5 focused table-name and preview test files: 84 passing tests
  • 3 focused bulk-delete and reference-guard suites: 71 passing tests
  • bunx biome check on the 7 files changed by the delete batching pass
  • bun run lint:check (26 tasks)
  • bun run check:api-validation:strict
  • bun run check:react-query
  • bun run check:audits (45 audits)

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added or 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)

Post-Deploy Monitoring & Validation

  • No user-visible runtime change is expected while TABLE_REFERENCE_COLUMNS is disabled.
  • After enabling it, watch table-name, table-detail, row-detail, and bulk-delete request error rates and latency during the first 24 hours.
  • Healthy signals: one batched name request per loaded table schema, detail and row requests only after a Reference cell opens, one reference-graph scan per explicit delete selection, and no deadlock or dangling-reference errors.
  • Failure signals: one request per Reference column, repeated fetches, incorrect names, stuck loading states, stale previews, repeated reference scans, deadlock errors, or broken archive/restore behavior. Disable TABLE_REFERENCE_COLUMNS first; roll back feat(tables): preview referenced rows inline #7106 if errors continue.
  • Validation owner: Tables team during the first 24 hours after flag enablement.

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 3, 2026 10:36pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds feature-flagged inline previews for referenced table rows while preserving reference integrity across table lifecycle and workspace-copy operations.

  • Adds lightweight table-name and on-demand schema/row queries for reference chips and previews.
  • Adds reference-aware copy, remapping, archive, restore, and row-mutation behavior.
  • Adds focused coverage for preview rendering, cache behavior, API contracts, copying, and lifecycle guards.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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
Loading

Reviews (2): Last reviewed commit: "feat(tables): preview referenced rows in..." | Re-trigger Greptile

Comment thread apps/sim/hooks/queries/tables.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

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; stop dblclick propagation 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

@j15z
j15z requested a review from a team as a code owner August 29, 2026 05:41
@j15z
j15z force-pushed the feat/reference-row-preview branch from bc7186a to e4ded13 Compare September 2, 2026 07:35
@j15z
j15z force-pushed the feat/reference-row-preview branch from e4ded13 to a3d2126 Compare September 2, 2026 07:38
@j15z
j15z force-pushed the feat/reference-row-preview branch from a3d2126 to 5eef2b1 Compare September 2, 2026 17:30
@j15z
j15z force-pushed the feat/reference-row-preview branch from 5eef2b1 to 2921222 Compare September 2, 2026 17:31
@j15z
j15z force-pushed the feat/reference-row-preview branch from 2921222 to 2deec54 Compare September 2, 2026 18:34
@j15z
j15z force-pushed the feat/reference-row-preview branch from 2deec54 to 1b145fe Compare September 2, 2026 20:57
@j15z
j15z force-pushed the feat/reference-row-preview branch from 1b145fe to b4cbd5e Compare September 2, 2026 21:00
@j15z
j15z force-pushed the feat/reference-row-preview branch from b4cbd5e to 377c35d Compare September 2, 2026 21:06
@j15z
j15z force-pushed the feat/reference-row-preview branch from 377c35d to 9a8addc Compare September 2, 2026 21:27
@j15z
j15z force-pushed the feat/reference-row-preview branch from 9a8addc to 705f382 Compare September 2, 2026 21:48
@j15z
j15z force-pushed the feat/reference-row-preview branch from 705f382 to bd15a78 Compare September 2, 2026 23:58
@j15z
j15z force-pushed the feat/reference-row-preview branch from bd15a78 to a82a46d Compare September 3, 2026 00:00
@j15z
j15z force-pushed the feat/reference-row-preview branch from a82a46d to 7f35686 Compare September 3, 2026 01:18
@j15z
j15z force-pushed the feat/reference-row-preview branch from 7f35686 to 073495c Compare September 3, 2026 03:14
@j15z
j15z force-pushed the feat/reference-row-preview branch from 073495c to e16aa7a Compare September 3, 2026 18:39
@j15z

j15z commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@j15z I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

3 issues found across 38 files

Confidence score: 2/5

  • apps/sim/lib/folders/config.ts can leave cyclically referenced tables unarchivable: archiveTableChildren deletes siblings one at a time, so an active sibling blocks deleteTable. Make archive handling account for the full reference group before deleting tables.
  • apps/sim/hooks/queries/tables.ts can show an outdated reference preview because staleTime: Infinity preserves 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.ts causes row creates, deletes, and imports to refetch the table-names endpoint when reference columns are enabled, adding unnecessary network work. Separate the names invalidation key from the broader lists prefix.
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>

Fix all with cubic | Re-trigger cubic

}
}

const [blocker] = await findActiveTableReferenceBlockers(db, workspaceId, {

@cubic-dev-ai cubic-dev-ai Bot Sep 3, 2026

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: 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>
Fix with cubic

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,

@cubic-dev-ai cubic-dev-ai Bot Sep 3, 2026

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: 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>
Fix with cubic

return { table, row }
},
enabled: Boolean(workspaceId && tableId && rowId && sourceRowId && sourceColumnKey),
staleTime: TABLE_REFERENCE_PREVIEW_STALE_TIME,

@cubic-dev-ai cubic-dev-ai Bot Sep 3, 2026

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: 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>
Fix with cubic

@j15z
j15z force-pushed the feat/reference-row-preview branch from e16aa7a to 9639bfa Compare September 3, 2026 21:24
@j15z
j15z force-pushed the feat/reference-row-preview branch from 9639bfa to 55f46e4 Compare September 3, 2026 22:36
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