Skip to content

Commit 5d349ee

Browse files
Copilothotlong
andcommitted
fix: address code review feedback - improve ID generation uniqueness and add regex documentation
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 1ffac9e commit 5d349ee

5 files changed

Lines changed: 6 additions & 4 deletions

File tree

packages/plugin-designer/src/AppCreationWizard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ let navItemCounter = 0;
120120

121121
function createNavId(prefix: string): string {
122122
navItemCounter += 1;
123-
return `${prefix}_${navItemCounter}`;
123+
return `${prefix}_${Date.now()}_${navItemCounter}`;
124124
}
125125

126126
// ============================================================================

packages/plugin-designer/src/DashboardEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ let widgetCounter = 0;
7070

7171
function createWidgetId(): string {
7272
widgetCounter += 1;
73-
return `widget_${widgetCounter}`;
73+
return `widget_${Date.now()}_${widgetCounter}`;
7474
}
7575

7676
// ============================================================================

packages/plugin-designer/src/NavigationDesigner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let ndCounter = 0;
6565

6666
function createId(prefix: string): string {
6767
ndCounter += 1;
68-
return `${prefix}_${ndCounter}`;
68+
return `${prefix}_${Date.now()}_${ndCounter}`;
6969
}
7070

7171
const NAV_TYPE_META: Record<NavigationItemType, { label: string; color: string; Icon: React.FC<{ className?: string }> }> = {

packages/plugin-designer/src/PageCanvasEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ let canvasCounter = 0;
8080

8181
function createComponentId(): string {
8282
canvasCounter += 1;
83-
return `component_${canvasCounter}`;
83+
return `component_${Date.now()}_${canvasCounter}`;
8484
}
8585

8686
// ============================================================================

packages/types/src/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ export type EditorMode = 'edit' | 'preview' | 'code';
446446

447447
/**
448448
* Validate an app name is snake_case.
449+
* Pattern: starts with lowercase letter, followed by lowercase letters/digits,
450+
* with optional underscore-separated segments (no trailing/leading/double underscores).
449451
*/
450452
export function isValidAppName(name: string): boolean {
451453
return /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/.test(name);

0 commit comments

Comments
 (0)