Scope added one-to-many relation columns from the Edit column panel

Closed
FE
2d ago
+1574-110

Lets an added one-to-many relation column show a scoped subset of related records, e.g. "open action items, most recent first, at most 1", configured from the Edit column panel. Behind IS_COLUMN_SETTINGS_ENABLED. Filters and sorts live in the column's scope view (#30341); the record limit lives in viewField.settings. Front-end only, built on aliased relation queries (#30468); scopes are saved through upsertViewFieldWithScope (#30466). #30469 (a sort diff fix) is merged into its integration branch but this PR doesn't depend on it.

Changes

  • One query: each visible scoped column becomes an alias in the main table query, scope_<viewFieldId>: <relation>(filter: $…, orderBy: $…, first: $…), through the relation aliases of #30468 (per-alias arguments come from #30465). Also in grouped tables and offset loads. Columns whose related object the user cannot read are skipped. getScopedRelationAliases holds the one rule for "scoped" and builds the alias key in one place; cells read it through ScopedRelationAliasesContext.
  • One source of truth: results land on the parent record in the store under the alias key; the cell and the picker's checked state both read it.
  • Freshness: when a related record is created, updated or deleted elsewhere, scoped columns refresh through the table's existing debounced reset (ungrouped) or group reload (grouped), triggered by useListenToScopedRelationRecordOperation. The table reloads when a column scope changes.
  • Edit column panel: filters, sorts and record limit. Save sends one upsertViewFieldWithScope request (#30466) and shows a loading state; the column is updated in the table once the save succeeds, and the panel stays open on failure. Measured locally for a new scoped column: ~11 s and 3 requests before, ~4–6 s and 1 request (~0.7–1 s) now.
  • Creating a record from a scoped cell: prefilled from the scope's top-level AND filters; record creation and canonical cells are unchanged without a scope.
  • Views: copying a view copies each scope onto the new column (one request per scoped column, in parallel); deleting a column drops its scope view from the store.

Stack

This PR targets felix/relaxed-einstein-vxil3q-base-column-scope, an integration branch merging #30348, #30466, #30468, #30469 and #30465 (with their own bases), so the diff shows only this PR.

The work is split into short tracks that can be reviewed and merged in parallel. Each PR targets main or the one PR it builds on. Two PRs need several others; they target an integration branch (felix/relaxed-einstein-vxil3q-base-*, not a PR) that merges exactly their dependencies, so their diff shows only their own changes. A PR can merge once everything in its "Builds on" column is merged; retarget it to main at that point.

Size counts changed lines outside tests and generated files: S < 300, M 300–800, L > 800. Sizes are a snapshot and are not kept in sync with every push.

TrackPRWhat it doesSizeCodeTests / generatedBuilds on
Server: views#30339Per-column settings on view fields (label, record limit)S+300 −2+703 −152main
Server: views#30341A view can be owned by a one-to-many view field (scope view)M+584 −56+891 −4main
Server: views#30472Lookup: a view field shows one field of its related recordM+280 −38+428 −4#30339
Server: views#30466upsertViewFieldWithScope: save a column with its settings, lookup and scope in one migration (~600 lines moved out of view-widget-upsert)L+1330 −567+1117 −256#30339, #30341, #30472
Server: views#30450Expose column scopes and lookups in the view AI toolsS+31+222#30339, #30341, #30472
Server: query engine#30347Honor filter / orderBy / first on nested one-to-many relationsM+462 −86+509main
Server: query engine#30473One relation-selection tree through the common query layer (refactor, no behavior change)L+663 −685+277 −46#30347
Server: query engine#30465Each alias of a nested relation gets its own arguments and rowsL+595 −237+727 −21#30473
Front#30468Query a relation under an alias with its own filter, sort and limitS+140 −19—main
Front#30469Don't recreate a saved sort that comes back under a new idS+21 −17+8main
Front#30348Extra table columns and the Edit column panel, behind IS_COLUMN_SETTINGS_ENABLEDM+718 −76+152 −30#30339
Front#30349 👈Scope one-to-many columns from the Edit column panelL+1053 −92+316 −18#30348, #30466, #30468, #30469, #30465
Front#30439Lookup columns in the table, editable from their cells (absorbs #30440)L+805 −223+283 −30#30349
Front#30458Lookup and scoped columns on boards and calendarsM+404 −284+140 −7#30439

The longest dependency chain is #30339 → #30348 → #30349 → #30439 → #30458; everything else is one or two levels deep. #30339, #30341 and #30472 each add a 2.59 instance command, so whichever merges after another may need a fresh timestamp.

Testing

  • Unit: buildViewFieldScopeInput, computeScopedRelationArgs, getScopedRelationAliases, isScopedRelationColumn, parseRecordLimitInput; record-table, views, optimistic-effect and side-panel suites.
  • In the app: adding a scoped "Key person" column (filter, sort, limit 1) on Companies; adding and clearing a sort on an existing scope; the scoped column next to the plain People column; moving a person between companies updates both rows' scoped cells without reload.
  • Typecheck, lint and knip.

Generated by Claude Code