Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 9, 2025

Summary

This PR removes all functionality related to the automatically generated 'id' field in the studio.tokens extension while adding backward compatibility to clean up existing ID fields when parsing tokens. The id field was being added to tokens but never actually used anywhere in the codebase, making it unnecessary overhead.

Changes Made

Removed Utility Functions

  • addIdPropertyToTokens.ts - Completely removed this utility that was adding UUIDs to tokens
  • removeTokenId.ts - Removed utility for stripping IDs from tokens
  • removeIdPropertyFromTokens.ts - Removed batch ID removal utility

Added Cleanup Logic

  • cleanupTokenExtensions.ts - New utility function that removes 'id' fields from studio.tokens extensions during token parsing
  • Updated convertToTokenArray - Integrated cleanup logic to automatically remove legacy ID fields when parsing tokens
  • Comprehensive tests - Added test coverage for the cleanup functionality to ensure proper removal of ID fields

Updated Core Token Handling

  • tokenState.tsx - Removed all calls to addIdPropertyToTokens() and UUID imports
  • updateTokenPayloadToSingleToken.ts - Simplified to no longer generate or include IDs and refactored for better code quality
  • Token formatting utilities (stringifyTokens.ts, formatTokens.ts, convertTokensToObject.ts) - Removed ID-related parameters and processing

Updated Components and Storage

  • Removed storeTokenIdInJsonEditor parameter usage from components like PushJSON.tsx and MultiFilesExport.tsx
  • Updated storage providers (GitSyncOptimizer.ts, RemoteTokenStorage.ts) to use simplified function signatures
  • Cleaned up unused imports and variables

Test Updates

  • Updated test expectations to no longer expect ID fields in token objects
  • Removed UUID mocks that are no longer needed
  • All core functionality tests continue to pass

Impact

Before:

{
  "name": "primary",
  "type": "color", 
  "value": "#ff0000",
  "$extensions": {
    "studio.tokens": {
      "id": "abc-123-def-456"
    }
  }
}

After:

{
  "name": "primary",
  "type": "color",
  "value": "#ff0000"
}

Benefits

  • Reduced complexity: Eliminates unnecessary ID generation and management code
  • Better performance: Removes UUID generation overhead for every token operation
  • Cleaner data: Token objects are now simpler without unused metadata
  • Smaller payload: Reduced memory usage and serialization size
  • Backward compatibility: Automatically cleans up legacy ID fields from existing tokens during parsing

No breaking changes to user-facing functionality since the IDs were never exposed or used in the UI or token operations. Users with existing tokens containing ID fields will have them automatically removed during parsing.


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

@Copilot Copilot AI assigned Copilot and six7 Sep 9, 2025
Copy link

changeset-bot bot commented Sep 9, 2025

🦋 Changeset detected

Latest commit: 6e43638

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

Co-authored-by: six7 <4548309+six7@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Remove all functionality that had a 'id' in the studio.tokens field of $extensions. We never made use of it, lets remove it entirely. All related checks and test data as well. Remove unused 'id' field functionality from studio.tokens extension Sep 9, 2025
@Copilot Copilot AI requested a review from six7 September 9, 2025 06:51
Copilot finished work on behalf of six7 September 9, 2025 06:51
@six7
Copy link
Collaborator

six7 commented Sep 9, 2025

@copilot shall we have some logic in still on parse? When users would still have this in their tokens, remove it.

…sions during parsing

Co-authored-by: six7 <4548309+six7@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 9, 2025

@copilot shall we have some logic in still on parse? When users would still have this in their tokens, remove it.

Added cleanup logic in convertToTokenArray function to automatically remove legacy 'id' fields from studio.tokens extensions during token parsing. This ensures backward compatibility for users who still have ID fields in their existing token files. The cleanup removes the ID field and cleans up empty extension objects. Commit: 6e43638

@Copilot Copilot AI changed the title Remove unused 'id' field functionality from studio.tokens extension Remove unused 'id' field functionality from studio.tokens extension and add cleanup logic for legacy tokens Sep 9, 2025
Copilot finished work on behalf of six7 September 9, 2025 07:56
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