Skip to content

Conversation

@Devessier
Copy link
Contributor

@Devessier Devessier commented Jan 7, 2026

Closes twentyhq/core-team-issues#1943

Demo

CleanShot.2026-01-08.at.11.40.55.mp4

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:8513

This environment will automatically shut down when the PR is closed or after 5 hours.

@Devessier Devessier changed the title Field widget card layout Add a CARD layout to the Field widget Jan 8, 2026
@Devessier Devessier marked this pull request as ready for review January 8, 2026 10:52
Copilot AI review requested due to automatic review settings January 8, 2026 10:52
Copy link
Contributor

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

Choose a reason for hiding this comment

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

2 issues found across 18 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/twenty-front/src/modules/page-layout/widgets/field/components/FieldWidgetRelationCard.tsx">

<violation number="1" location="packages/twenty-front/src/modules/page-layout/widgets/field/components/FieldWidgetRelationCard.tsx:70">
P2: The `useUpdateOneObjectRecordMutation` function is recreated on every render, causing the `FieldContext.Provider` value to change and trigger unnecessary re-renders in child components. Consider memoizing this function with `useCallback` to maintain referential stability.</violation>
</file>

<file name="packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsWidget.tsx">

<violation number="1" location="packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsWidget.tsx:53">
P2: Removing `targetRecord.id` and `isInRightDrawer` from `instanceId` may cause state collision issues. If the same widget displays different records (e.g., main view vs right drawer), they will now share Recoil state for hover position and edit mode. Consider keeping the record and drawer context in the instance ID for proper state isolation:
```javascript
const instanceId = `${widget.id}-${targetRecord.id}${isInRightDrawer ? '-right-drawer' : ''}`;
```</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

objectNameSingular: targetRecord.targetObjectNameSingular,
});

const useUpdateOneObjectRecordMutation = () => {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 8, 2026

Choose a reason for hiding this comment

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

P2: The useUpdateOneObjectRecordMutation function is recreated on every render, causing the FieldContext.Provider value to change and trigger unnecessary re-renders in child components. Consider memoizing this function with useCallback to maintain referential stability.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-front/src/modules/page-layout/widgets/field/components/FieldWidgetRelationCard.tsx, line 70:

<comment>The `useUpdateOneObjectRecordMutation` function is recreated on every render, causing the `FieldContext.Provider` value to change and trigger unnecessary re-renders in child components. Consider memoizing this function with `useCallback` to maintain referential stability.</comment>

<file context>
@@ -0,0 +1,169 @@
+    objectNameSingular: targetRecord.targetObjectNameSingular,
+  });
+
+  const useUpdateOneObjectRecordMutation = () => {
+    const updateEntity = ({
+      variables,
</file context>
Fix with Cubic

…omponents/FieldsWidget.tsx

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Comment on lines 109 to 114
const { onSubmit } = useContext(FieldInputEventContext);

const { openModal } = useModal();
const { isInRightDrawer } = useIsInRightDrawerOrThrow();

const { relationType, objectMetadataNameSingular } =
fieldDefinition.metadata as FieldRelationMetadata;

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment on lines +70 to +88
const useUpdateOneObjectRecordMutation = () => {
const updateEntity = ({
variables,
}: {
variables: {
where: { id: string };
updateOneRecordInput: Record<string, unknown>;
};
}) => {
updateOneRecord?.({
idToUpdate: variables.where.id,
updateOneRecordInput: variables.updateOneRecordInput,
});
};
return [updateEntity, { loading: false }] as [
(params: any) => void,
{ loading: boolean },
];
};
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The useUpdateOneObjectRecordMutation function is defined inline and returns a tuple with an any type for the first element. This loose typing reduces type safety. Consider defining a proper type for the mutation function parameters and return value to improve type safety.

Copilot uses AI. Check for mistakes.
const [expandedItem, setExpandedItem] = useState('');
const targetRecord = useTargetRecord();

const instanceId = getFieldWidgetInstanceId({
Copy link
Member

Choose a reason for hiding this comment

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

naming: I feel it's more generate than get

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

LGTM :)

@Devessier Devessier added this pull request to the merge queue Jan 8, 2026
Merged via the queue into main with commit f1aee7f Jan 8, 2026
68 checks passed
@Devessier Devessier deleted the field-widget-card-layout branch January 8, 2026 15:55
@twenty-eng-sync
Copy link

Hey @Devessier! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

1 similar comment
@twenty-eng-sync
Copy link

Hey @Devessier! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Record Page Layouts] Create the card layout of the Field widget for relations

3 participants