Show lookup and scoped columns on boards and calendars
Context
Stacked on #30439. Added (non-canonical) columns only worked in table views. On a kanban board or a calendar, a lookup column rendered as a second copy of the relation chip and a scoped column rendered the whole unscoped relation, because:
- boards and calendars load through group-by queries, which never selected the scoped alias;
- the card bodies build their field context from
fieldMetadataItemIdalone, and the lookup context was tied to the table.
The parent stack also kept extra columns out of every layout except tables (isRecordFieldSupportedByViewType). This PR makes both column kinds display correctly on board and calendar cards, and lets them through on those layouts.
Stack
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.
| Track | PR | What it does | Size | Code | Tests / generated | Builds on |
|---|---|---|---|---|---|---|
| Server: views | #30339 | Per-column settings on view fields (label, record limit) | S | +300 −2 | +703 −152 | main |
| Server: views | #30341 | A view can be owned by a one-to-many view field (scope view) | M | +584 −56 | +891 −4 | main |
| Server: views | #30472 | Lookup: a view field shows one field of its related record | M | +280 −38 | +428 −4 | #30339 |
| Server: views | #30466 | upsertViewFieldWithScope: 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 | #30450 | Expose column scopes and lookups in the view AI tools | S | +31 | +222 | #30339, #30341, #30472 |
| Server: query engine | #30347 | Honor filter / orderBy / first on nested one-to-many relations | M | +462 −86 | +509 | main |
| Server: query engine | #30473 | One relation-selection tree through the common query layer (refactor, no behavior change) | L | +663 −685 | +277 −46 | #30347 |
| Server: query engine | #30465 | Each alias of a nested relation gets its own arguments and rows | L | +595 −237 | +727 −21 | #30473 |
| Front | #30468 | Query a relation under an alias with its own filter, sort and limit | S | +140 −19 | — | main |
| Front | #30469 | Save record filters and sorts to a given view (replaces the old hooks) | M | +341 −348 | — | main |
| Front | #30348 | Extra table columns and the Edit column panel, behind IS_COLUMN_SETTINGS_ENABLED | M | +718 −76 | +152 −30 | #30339 |
| Front | #30349 | Scope one-to-many columns from the Edit column panel | L | +1053 −92 | +316 −18 | #30348, #30466, #30468, #30469, #30465 |
| Front | #30439 | Lookup columns in the table, editable from their cells (absorbs #30440) | L | +805 −223 | +283 −30 | #30349 |
| Front | #30458 👈 | Lookup and scoped columns on boards and calendars | M | +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.
What changes
Query
generateGroupsRecordsGroupByQuery(board) andgenerateGroupByRecordsQuery(calendar) takerelationAliasesand emit the alias selection and its variables, the same waygenerateFindManyRecordsQuerydoes.useRecordIndexGroupCommonQueryVariablesreturns the scoped aliases, so the board's initial query and fetch-more both carry them. The calendar hook passes them throughuseGroupByRecordsQuery.useRecordBoardQueryIdentifiercovers the full selected-field tree and the scope arguments, so changing a lookup target or a scope refetches the board.- Board and calendar loaders use the plain
upsertRecordsInStore, which already stores the selected related records (no per-loader lookup ingestion). - Server fixes: a group-by query returned
nullfor an aliased relation, becauseformatResultdrops any key that is not a field name (field::alias); group-by now keeps aliased relations (found throughgetRecordFieldEntries) next to the formatted record. The nested many-to-one relation query quotes its"id"column, which the permission check otherwise read as a column named after the table alias.
Rendering
isRecordFieldSupportedByViewTypekeeps extra columns on tables, boards and calendars, and out of the list layout only.RecordTableCellLookupFieldContextbecomesRecordFieldLookupFieldContext: it takesrecordId, the instance id prefix, the non-editable flag and its presentation options (displayedMaxRows,maxWidth,isDisplayModeFixHeight,triggerEvent,anchorId,onOpenEditMode) as explicit props, replacingfieldContextOverrides, so callers cannot override its read-only and permission flags. The table passes a read-only row through the non-editable flag.- One shared renderer,
RecordCardField, renders a canonical, lookup or scoped column for both card bodies. It reads the column descriptor (lookup target and label) fromcolumnDescriptorByRecordFieldId, and the scoped alias fromScopedRelationAliasesContext, which boards and calendars now provide from the sameuseScopedRelationAliases()list their query uses (as tables do).RecordBoardCardBodyandRecordCalendarCardBodykeep their own layout, hover and update wrappers and map their fields through it. useRecordCardVisibleRecordFieldsis the one field list that card bodies and the hover/edit portals index into.useIsFieldEmptyreadsFieldContext.scopedRelationAlias, so an empty scope shows the empty placeholder even when the relation itself has records.- Added columns get their own instance and anchor ids, since they share a field with the canonical column.
Known limits
- Added columns are read-only on cards. The card hover and edit portals find a cell by field, so they would open the canonical column's editor. Editing stays available in table views.
- At most 5 related records per scoped column on boards and calendars. The group-by path caps nested relations at
RELATIONS_PER_RECORD_LIMIT(5), below the 60 allowed on tables. - No live refresh of scoped values on cards. The table's scoped refresh (
useListenToScopedRelationRecordOperation) is mounted in the table only; a board picks up related-record changes on its next fetch. - List layout and CSV export are not covered.
Tests
- Integration:
nested-relation-query-arguments.integration-spec.tshas a group-by case with an aliased, filtered, ordered and limited relation next to the plain one; the suite passes (13/13). - Unit:
generateGroupsRecordsGroupByQuery.test.ts(alias selection and variables; unchanged query without aliases) andisRecordFieldSupportedByViewType.test.ts(extra columns on table, board and calendar, not on list). Front suites for record-board, record-calendar, record-card, record-column-lookup, record-column-scope, record-store, record-index and record-table cells pass. - Typecheck / lint:
tsgo --noEmitis clean fortwenty-frontandtwenty-server;oxlintandoxfmtare clean on the changed files. - Manual, against a local app (on an earlier version of the stack; Opportunities, with an added "Company → Employees" lookup column and an added Attachments column limited to 1):
- Board: the lookup shows the company's employee count; opportunities with 3–5 attachments return exactly 1 in the limited column next to the full list; hovering or clicking an added column opens nothing; a canonical field still opens its editor.
- Calendar: both columns render, and the query carries the alias and the lookup target with no errors.
Generated by Claude Code