Skip to content

improvement(tables): empty-state filter/sort builders + upsert conflict-column selection#5123

Open
TheodoreSpeaks wants to merge 4 commits into
stagingfrom
feat/table-v2-block
Open

improvement(tables): empty-state filter/sort builders + upsert conflict-column selection#5123
TheodoreSpeaks wants to merge 4 commits into
stagingfrom
feat/table-v2-block

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Filter/sort builders now start empty with a "+ Add condition" affordance instead of a phantom blank row; removing the last row clears it
  • Filter converter skips blank-column rows so an empty builder can't serialize to a { '': … } predicate
  • Upsert Row gains a Conflict Column field to pick which unique column to match on
  • Upsert now defaults to the first unique column when none is specified (was throwing on tables with 2+ unique columns)

Type of Change

  • Improvement

Testing

Tested manually; lint, api-validation:strict, and tsc --noEmit pass; table row tests pass (20/20)

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)

TheodoreSpeaks and others added 3 commits June 12, 2026 10:45
…me/drop prompt

`drizzle-kit push --force` only suppresses the data-loss confirm, not the
rename-vs-drop disambiguation prompt. That prompt fires whenever a diff both
adds and drops tables/columns at once (e.g. migration 0231 created
sim_trigger_state while dropping the workspace_notification_* tables), and in
CI it crashes with a bare "Interactive prompts require a TTY" stack trace.

Catch that specific failure in the dev push step and emit a GitHub error
annotation explaining the cause and the fix (drop the stale objects on the dev
DB to match schema.ts — the same DROPs the versioned migration already applied
to staging/prod), instead of leaving an opaque trace. Exit status is preserved
either way.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 17, 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 Jun 17, 2026 11:36pm

Request Review

@cursor

cursor Bot commented Jun 17, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Upsert conflict targeting affects which row is matched on write; wrong or missing values can update the wrong row or fail at runtime, while the rest is mostly UX and CI diagnostics.

Overview
Workflow table UX: Filter and sort builders no longer auto-insert a placeholder row or re-seed one when the last rule is removed. When there are no rules, editable mode shows a dashed Add filter condition / Add sort control; read-only preview renders nothing.

Query safety: filterRulesToFilter now skips rules with no column selected so incomplete builder state cannot become an empty-key filter predicate.

Upsert Row: The Table block adds a Conflict Column field for upsert_row, maps it through block params and table_upsert_row as optional conflictTarget, and documents it on block inputs. Multi–unique-column upserts still require an explicit choice; the service error text now says “conflict column” instead of conflictTarget.

CI (dev only): The migrations workflow captures db:push output and, on the “Interactive prompts require a TTY” failure, emits a GitHub Actions error with steps to reconcile dev DB drift before re-running.

Reviewed by Cursor Bugbot for commit 150b3fe. Bugbot is set up for automated code reviews on this repo. 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 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 766ad33. Configure here.

for (const rule of rules) {
// Skip incomplete rows (no column selected) so a blank builder row never
// serializes to a `{ '': ... }` predicate.
if (!rule.column) continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent drop of incomplete filters

Medium Severity

filterRulesToFilter now skips rules with an empty column, but the workflow filter builder can still persist and display those rows (for example after “Add filter condition” before columns load). On query_rows, that yields no filter while the UI still shows conditions, so the block may return a broad unfiltered result instead of the intended subset.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 766ad33. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR polishes the table block's UX in two areas: (1) filter and sort builders now start empty with a dashed "+ Add condition" button instead of a phantom pre-populated row, and removing the last rule returns to that empty state; (2) the upsert tool gains an optional conflictColumn/conflictTarget field so users can select which unique column to match on when a table has more than one.

  • Filter/sort empty-state: filterRulesToFilter and sortRulesToSort already tolerate an empty array; a new !rule.column guard in the converter prevents a blank builder row from ever serializing to a { '': … } predicate.
  • Upsert conflict column: A short-input sub-block is wired through the param transformer to the existing conflictTarget path in the service; the service still throws a clear error when a table has 2+ unique columns and no target is provided.
  • CI migration step: The db:push --force invocation now captures stderr, detects the "Interactive prompts require a TTY" crash, and emits an actionable GitHub Actions error annotation.

Confidence Score: 5/5

Safe to merge — all three functional changes (empty-state builders, blank-column guard in the converter, conflict-column parameter wiring) are straightforward and correctly implemented.

The filter/sort empty-state refactor is well-contained: the store correctly transitions to an empty array, the converter already handled zero-length arrays, and the new !rule.column guard is the only serialization path change. The upsert conflict-column addition threads consistently through the block definition, tool params, and service (which still throws a clear error for un-resolved multi-unique tables). No behavioral regressions are apparent in any changed path.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/table.ts Adds conflictColumn short-input sub-block for upsert_row, passes it as conflictTarget via the param transformer (falls back to undefined on empty string); input params schema also updated
apps/sim/tools/table/upsert_row.ts Adds optional conflictTarget param (user-only visibility, consistent with tableId); spreads it into the request body only when truthy; pattern is consistent with existing tool params
apps/sim/lib/table/query-builder/converters.ts Added an early continue guard to skip rules with a blank column; correctly prevents blank predicates from an empty builder; all-blank array still returns null via the existing early-return path
apps/sim/lib/table/rows/service.ts Only changes the error-message wording for the multi-unique-column case; functional behaviour (still throws when conflictTarget is absent and table has 2+ unique columns) is unchanged
.github/workflows/migrations.yml Improves CI dev-push step: captures output, detects the Interactive prompts require a TTY crash, and emits an actionable GitHub Actions error annotation instead of a bare stack trace

Reviews (2): Last reviewed commit: "improvement(tables): throw on ambiguous ..." | Re-trigger Greptile

Comment thread apps/sim/lib/table/rows/service.ts Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

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