Skip to content

Allow files uploaded in AI chat box to be removed#18299

Open
LTan-101104 wants to merge 2 commits intotwentyhq:mainfrom
LTan-101104:ai-upload
Open

Allow files uploaded in AI chat box to be removed#18299
LTan-101104 wants to merge 2 commits intotwentyhq:mainfrom
LTan-101104:ai-upload

Conversation

@LTan-101104
Copy link
Contributor

This aims to fix the bug mentioned in #18298

##Summary##

In AgentChatFilePreview.tsx, wrap the original rightComponent with a div that would stop propagation event so this can avoid transferring event to StyledLink and thus avoid redirecting, only triggering the remove event.

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.

No issues found across 1 file

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 27, 2026

Greptile Summary

Fixed bug where clicking the remove button on file previews would also trigger navigation to the file URL. Wrapped the AvatarChip in a div with event handlers that stop propagation and prevent default behavior.

Key changes:

  • Added wrapper div with onMouseDown and onClick handlers that stop event propagation
  • Prevents clicks on the remove button from bubbling up to the parent LinkChip
  • Removed onClick from AvatarChip itself (handled by wrapper instead)

Issues found:

  • Missing cursor: pointer style causes UX regression - remove button doesn't visually indicate it's clickable

Confidence Score: 3/5

  • Safe to merge with minor UX fix - addresses the navigation bug but needs cursor styling
  • The fix functionally solves the reported bug and correctly handles event propagation for both onMouseDown and onClick. However, removing the onClick prop from AvatarChip means it no longer shows a pointer cursor, which is a UX regression that should be addressed.
  • AgentChatFilePreview.tsx needs the cursor style added to the wrapper div

Important Files Changed

Filename Overview
packages/twenty-front/src/modules/ai/components/internal/AgentChatFilePreview.tsx Wrapped AvatarChip in event-handling div to prevent navigation when removing files; missing cursor styling

Last reviewed commit: ccc1c8c

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +46 to +59
<div
onMouseDown={(e) => e.stopPropagation()}
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
onRemove();
}}
>
<AvatarChip
Icon={IconX}
IconColor={theme.font.color.secondary}
divider="left"
/>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing cursor: pointer on wrapper div - users won't get visual feedback that the remove button is clickable

Suggested change
<div
onMouseDown={(e) => e.stopPropagation()}
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
onRemove();
}}
>
<AvatarChip
Icon={IconX}
IconColor={theme.font.color.secondary}
divider="left"
/>
</div>
<div
onMouseDown={(e) => e.stopPropagation()}
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
onRemove();
}}
style={{ cursor: 'pointer' }}
>
<AvatarChip
Icon={IconX}
IconColor={theme.font.color.secondary}
divider="left"
/>
</div>

@github-actions
Copy link
Contributor

🚀 Preview Environment Ready!

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

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

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