Skip to content

Improvement for CopyMarkdown action #3465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 15, 2025

Conversation

nolannbiron
Copy link
Member

@nolannbiron nolannbiron commented Jul 11, 2025

This pull request introduces improvements to the CopyMarkdown action in the GitBook project. The main goal of these enhancements is to optimize the functionality, improve performance, and ensure better usability for end-users.

@nolannbiron nolannbiron requested a review from zenoachtig July 11, 2025 10:48
Copy link

changeset-bot bot commented Jul 11, 2025

🦋 Changeset detected

Latest commit: 5ce9748

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gitbook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

argos-ci bot commented Jul 11, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2 (Inspect) 👍 Changes approved 5 changed Jul 15, 2025, 11:35 AM
v2-cloudflare (Inspect) ✅ No changes detected - Jul 15, 2025, 11:39 AM
v2-vercel (Inspect) ✅ No changes detected - Jul 15, 2025, 11:37 AM

Copy link
Contributor

@gregberge gregberge left a comment

Choose a reason for hiding this comment

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

I will approve but this code is quite messy to be honest.

@nolannbiron
Copy link
Member Author

@gregberge I've updated the timeout, I know it's quite messy but I need to share the whole state between multiple instances (default action button + dropdown-menu item), so the goal of this PR is to fetch the markdown only once if you click multiple times on the copy button, with better loading state for default action and dropdown menu, etc

Introduced IconWithLoading component to handle icon rendering with loading state for both Button and link variants in AIActionWrapper. Also reset copied and loading states in CopyMarkdown cleanup. This improves code reuse and UI consistency for loading indicators.
@nolannbiron
Copy link
Member Author

@SamyPesse @gregberge I’ve updated the code to use an LRU cache for markdown content (max 10 paths), simplified useCopiedStore to only store copied, loading and the copy function (which is what we share between instances), wrapped DropdownMenu in a context, and created a useDropdownMenuClose hook (similar to what we use for Dialogs on GBX)

@nolannbiron nolannbiron merged commit 9ee9082 into main Jul 15, 2025
16 checks passed
@nolannbiron nolannbiron deleted the nolann/ai-actions-dropdown-loading branch July 15, 2025 11:41
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.

3 participants