ready to share your asset link with an ai message description - #149
ready to share your asset link with an ai message description#149Oswaldinho24k wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces AI-powered social media descriptions and enhances the sharing UI with loading states and cancellation.
- Replaces the
slugprop with the fullassetobject inShareLinkto access title/type. - Implements
handleSharelinkWithAIDescriptioninSharing, including streaming from/api/v1/ai/sugestions, spinner, and abort logic. - Extends the AI suggestions endpoint to handle a new
"generate_social_description"intent.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| app/routes/assets/AssetPreview.tsx | Updated ShareLink and Sharing to accept asset, added Spinner, async AI description logic, and improved SocialMedia buttons. |
| app/routes/api/v1/ai/sugestions.tsx | Added handling for generate_social_description intent and streaming response. |
Comments suppressed due to low confidence (1)
app/routes/assets/AssetPreview.tsx:117
- The new AI-driven sharing logic (streaming, abort, spinner states) lacks tests. Adding unit/integration tests will help ensure correct behavior and catch future regressions.
export const Sharing = ({ link, asset }: { link: string; asset: Asset }) => {
| } | ||
| } | ||
| setIsLoading(false); | ||
| return text; // Devuelve el texto generado |
There was a problem hiding this comment.
Returning the state variable text here will yield the initial or stale value due to the async state update. Instead, accumulate the description in a local variable and return that.
| return text; // Devuelve el texto generado | |
| return accumulatedText; // Return the accumulated description |
| onClick={() => { | ||
| const description = handleSharelinkWithAIDescription({ |
There was a problem hiding this comment.
This call to handleSharelinkWithAIDescription isn’t awaited, so description will be a Promise rather than the generated string. Mark the onClick callback async and use await here.
| onClick={() => { | |
| const description = handleSharelinkWithAIDescription({ | |
| onClick={async () => { | |
| const description = await handleSharelinkWithAIDescription({ |
| }); | ||
| } | ||
| } | ||
| // i want a new action where I return a description to share in social media based on the name, type and info from the asset i want to share/sell that is well structured based on the platfor it will be shareD |
There was a problem hiding this comment.
The file and endpoint path use sugestions instead of the correct spelling suggestions. Renaming will improve clarity and prevent future confusion.
| // i want a new action where I return a description to share in social media based on the name, type and info from the asset i want to share/sell that is well structured based on the platfor it will be shareD | |
| // I want a new action where I return a description to share on social media based on the name, type, and info from the asset I want to share/sell that is well-structured based on the platform it will be shared on. |
| <a rel="noreferrer" target="_blank" href={link}> | ||
| <button | ||
| disabled={isLoading} | ||
| onMouseEnter={handleMouseEnter} | ||
| onMouseLeave={handleMouseLeave} | ||
| onClick={onClick} |
There was a problem hiding this comment.
Wrapping an action-only button in an anchor with href={link} (often undefined) can confuse screen readers and keyboard users. Consider removing the href when using a pure onClick or add an appropriate aria-label.
| <a rel="noreferrer" target="_blank" href={link}> | |
| <button | |
| disabled={isLoading} | |
| onMouseEnter={handleMouseEnter} | |
| onMouseLeave={handleMouseLeave} | |
| onClick={onClick} | |
| {link ? ( | |
| <a rel="noreferrer" target="_blank" href={link}> | |
| <button | |
| disabled={isLoading} | |
| onMouseEnter={handleMouseEnter} | |
| onMouseLeave={handleMouseLeave} | |
| onClick={onClick} | |
| aria-label={name || "Social media button"} | |
| className={twMerge( | |
| "group bg-black rounded-full transition-all text-lg text-black flex items-center justify-center relative cursor-pointer " | |
| )} | |
| > | |
| <div | |
| className={cn( | |
| "w-12 h-12 border-2 -translate-x-[2px] -translate-y-[2px] grid place-content-center text-2xl border-black bg-purple-600 rounded-full", | |
| className | |
| )} | |
| > | |
| {isLoading ? <Spinner /> : children} | |
| </div> | |
| <motion.div | |
| ref={scope} | |
| className={twMerge( | |
| "absolute bg-dark dark:bg-[#1B1D22] -bottom-7 text-xs text-white px-2 py-1 rounded hidden group-hover:block" | |
| )} | |
| > | |
| {name} | |
| </motion.div> | |
| </button> | |
| </a> | |
| ) : ( | |
| <button | |
| disabled={isLoading} | |
| onMouseEnter={handleMouseEnter} | |
| onMouseLeave={handleMouseLeave} | |
| onClick={onClick} | |
| aria-label={name || "Social media button"} |
…ure/ai-share-message
No description provided.