Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 11, 2025

Problem

When a Git branch is deleted (e.g., after a merge), it continues to appear in the Tokens Studio branch selector until the plugin is closed and reopened. This issue affects all Git-based syncing providers including GitHub, GitLab, Azure DevOps, and Bitbucket, creating a confusing user experience when branches no longer exist remotely.

Solution

This PR implements automatic branch refresh using a stale-while-revalidate approach whenever the branch selector popover is opened. The implementation:

  1. Shows cached data immediately - When users open the branch selector, they see the existing branches from Redux state without any delay or loading indicators
  2. Fetches fresh data in background - Simultaneously triggers an API call to fetch the latest branch list from the remote Git provider
  3. Updates seamlessly - Once the fetch completes, the UI automatically updates to reflect any changes (new branches, deleted branches, etc.)

Changes

BranchSelectorPopover.tsx

  • Added optional onRefreshBranches prop to the component interface
  • Added useEffect hook that triggers the refresh callback when the popover opens

BranchSelector.tsx

  • Added handleRefreshBranches callback that:
    • Verifies the current provider is Git-based
    • Calls fetchBranches from useRemoteTokens hook
    • Updates Redux state with fresh branch data
    • Handles errors gracefully with informative logging
  • Connected the callback to BranchSelectorPopover component

Benefits

  • No manual refresh needed - Branches automatically update when opening the selector
  • Zero UI disruption - No loading spinners or delays, cached data shows immediately
  • Universal support - Works across all Git providers (GitHub, GitLab, ADO, Bitbucket)
  • Error resilient - Failures don't block the UI, users still see cached branches

Testing

  • Build passes successfully
  • Linting passes with no issues
  • Existing tests continue to pass
  • Changeset added per repository guidelines

Fixes the issue described in user feedback where deleted branches remained visible in the UI.

Original prompt

when a Git branch is deleted (e.g., after a merge), it still appears in Tokens Studio until the plugin is closed and reopened. This behavior affects the usability of all syncing providers that use branching, including GitHub, GitLab, Azure DevOps (ADO), and Bitbucket.

User Feedback
It would be helpful to have a “Refresh” button or an automatic refresh feature in Tokens Studio that updates the Git branch status without requiring a restart. This feature would detect changes in branch availability (e.g., deletions or updates) across all supported syncing providers, ensuring the interface accurately reflects the current state of the repository. This enhancement would streamline workflows and reduce the need for repetitive manual actions.

--

lets make it so whenever we open the branch menu, we perform a check if the branches still exist. it should be a stale while revalidate sort of approach, where we show the old, but then update it when its there, instead of always refetching or showing a spinner. its ok to update the content while content is already there


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2025

🦋 Changeset detected

Latest commit: ce90595

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

This PR includes changesets to release 1 package
Name Type
@tokens-studio/figma-plugin 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

Copilot AI and others added 2 commits October 11, 2025 12:22
Co-authored-by: six7 <4548309+six7@users.noreply.github.com>
Co-authored-by: six7 <4548309+six7@users.noreply.github.com>
Copilot AI changed the title [WIP] Add refresh feature to update branch status in Tokens Studio Add automatic branch refresh when opening branch selector menu Oct 11, 2025
Copilot AI requested a review from six7 October 11, 2025 12:30
Copilot finished work on behalf of six7 October 11, 2025 12:30
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.

2 participants