Fix: Ensure local tokens are saved to document on plugin startup
Problem
When working with "local document" storage, tokens loaded into the plugin are lost if the user closes and reopens the plugin without explicitly clicking the "Apply To" button. This creates a poor user experience where tokens appear to be loaded but aren't actually persisted to the document.
Root Cause
The issue was in pullTokensFactory.ts where setTokenData() was called without the shouldUpdate: true flag when loading local tokens on startup. This meant:
- Tokens were loaded into the application state ✅
- But
updateDocument()was never called ❌ - So tokens weren't saved back to the Figma document ❌
Solution
Added shouldUpdate: true to both setTokenData() calls for local token loading:
// For direct local token loading (line 112)
dispatch.tokenState.setTokenData({ ...params.localTokenData, activeTheme, shouldUpdate: true });
// For recovering local changes (line 156)
dispatch.tokenState.setTokenData({ ...params.localTokenData, activeTheme, shouldUpdate: true });
This ensures that when local tokens are loaded on startup, they are automatically saved to the document via the updateDocument() flow.
Testing
- Added comprehensive test to verify
updateDocumentis called when loading local tokens - Verified remote storage providers are unaffected (they should not auto-apply tokens)
- All existing tests pass with no regressions
Impact
Users working with local document storage will no longer lose their tokens when closing and reopening the plugin. The tokens are now properly persisted to the document on startup without requiring manual "Apply To" action.
Fixes #3408.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
http://168.63.129.16:80/machine/
- Triggering command:
/usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs(http block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
⚠️ No Changeset found
Latest commit: 4be1565b9f702684752cc18a832e8054f8701932
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR