-
Notifications
You must be signed in to change notification settings - Fork 3k
improvement(code-quality): centralize regex checks, normalization #2554
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR centralizes regex patterns and name normalization utilities into Key improvements:
Migration pattern:
All changes maintain backward compatibility and improve code quality without altering functionality. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Client/UI
participant Store as Workflow Store
participant Copilot as Copilot Tool
participant Utils as executor/constants
participant Executor as Execution Engine
Note over Utils: Centralized utilities:<br/>normalizeName()<br/>PATTERNS (UUID, ENV_VAR)<br/>isCustomTool(), isMcpTool()<br/>escapeRegExp()
Client->>Store: updateBlockName(id, name)
Store->>Utils: normalizeName(name)
Utils-->>Store: normalized name
Store->>Store: Check if normalized name empty
alt Empty normalized name
Store-->>Client: {success: false}
else Valid name
Store->>Store: Find duplicate in blocks
alt Duplicate found
Store-->>Client: {success: false}
else No duplicate
Store->>Store: Update block name
Store->>Utils: normalizeName() for references
Store-->>Client: {success: true}
end
end
Copilot->>Copilot: edit-workflow operation
Copilot->>Utils: normalizeName(params.name)
Utils-->>Copilot: normalized name
alt Empty normalized name
Copilot->>Copilot: logSkippedItem('missing_required_params')
else Has duplicate
Copilot->>Copilot: logSkippedItem('duplicate_block_name')
else Valid
Copilot->>Copilot: Apply operation
end
Client->>Executor: Execute workflow
Executor->>Executor: collectBlockData()
loop For each block
Executor->>Utils: normalizeName(block.name)
Utils-->>Executor: normalized name
Executor->>Executor: blockNameMapping[normalized] = blockId
end
Executor->>Executor: Resolve variable reference
Executor->>Executor: Direct O(1) lookup in blockNameMapping
Note over Executor: Before: O(n) loop through mapping<br/>After: O(1) direct access
|
Summary
lib/, executor/, app/api/ → import from @/executor/constants
stores/ → import from @/stores/workflows/utils (re-exports normalizeName)
Type of Change
Testing
Tested manually
Checklist