Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 11, 2025

Problem

The plugin did not remember user preferences for the Export to Figma screen on a per-file basis. When users opened the export modal:

  • All themes were enabled by default, regardless of which themes were actually active in the editor
  • All token sets were selected by default
  • The active tab (Themes vs Sets) always defaulted based on Pro status

This forced users to manually reconfigure their export settings every time they worked with a file, which was time-consuming and error-prone, especially when managing multiple files with distinct export requirements.

Solution

Implemented a comprehensive system that saves and automatically restores export preferences for each individual file. The plugin now remembers:

  1. Selected Themes - Which themes are enabled/active for export
  2. Selected Token Sets - Which token sets are marked for export
  3. Active Tab - Whether the user was viewing "Themes" or "Sets" tab

Technical Implementation

The preferences are stored in Figma's shared plugin data (per-file storage) and follow the same architecture as the existing selectedExportThemes feature:

  • Storage Layer: Created SelectedExportSetsProperty and ActiveExportTabProperty for persistent storage
  • Redux State: Added new properties to uiState model with effects that trigger async messages
  • Component: Modified ManageStylesAndVariables to initialize from saved preferences and save changes
  • Startup: Extended startup logic to load all saved preferences on plugin initialization

Edge Case Handling

The implementation robustly handles scenarios where saved preferences reference items that no longer exist:

  • Validates saved themes against current theme list
  • Validates saved sets against current set list
  • Filters out deleted items automatically
  • Falls back to sensible defaults (all items selected) when no valid saved preferences exist

Example

Before this change:

// User opens Export modal → all themes selected by default
// User deselects unwanted themes → exports
// User closes modal and reopens → all themes selected again 😞

After this change:

// User opens Export modal → previously selected themes restored ✅
// User deselects unwanted themes → exports
// User closes modal and reopens → same selection restored ✅

Testing

  • ✅ All startup tests pass
  • ✅ Build succeeds without errors
  • ✅ Lint passes without issues
  • ✅ Follows existing code patterns for consistency

Related

Fixes issue where export configurations needed to be manually set for each file every time the export modal was opened.

Original prompt

The plugin currently does not remember user preferences for enabled Themes and export configurations (styles and variables) on a per-file basis. When exporting "Themes," the system defaults to enabling ALL themes, which often doesn't reflect the user's active themes in the editor view for that specific file. This forces users to manually deselect unwanted themes repeatedly for each file, which is time-consuming and increases the risk of exporting incorrect assets, especially when managing multiple files with distinct theme and export requirements.

Proposed Solution:

Implement a system that saves and automatically applies preferences for each individual file. These preferences should include:

• The selection of enabled/active Themes within the editor and for export.

• The configuration of which specific styles and variables are marked for export.

This way, when a user opens a file, their previously used settings for that file are automatically restored.

--

this is about the Export to Figma screen where users can choose the Themes, the export config, or the Sets (if using Set export). Let's remember what they used, so that they land on the right tab (themes vs sets) and have the right settings enabled, and the right Themes.

Also add handling for the edge case where a theme no longer exists - in that case just dont have it selected.


✨ 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: b3fd9e7

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

…ve tab

Co-authored-by: six7 <4548309+six7@users.noreply.github.com>
Copilot AI changed the title [WIP] Add user preference retention for enabled themes and export settings Remember export preferences per file (themes, sets, and active tab) Oct 11, 2025
Copilot AI requested a review from six7 October 11, 2025 12:35
Copilot finished work on behalf of six7 October 11, 2025 12:35
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