-
Notifications
You must be signed in to change notification settings - Fork 0
feat: friendly component IDs with display names #81
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b25f997
docs: add friendly component IDs design spec
TerrifiedBug f4d3c1d
feat: decouple component display names from backend keys
TerrifiedBug 8e4fad3
fix: use pnpm for nanoid installation, remove erroneous package-lock.…
TerrifiedBug f6e3a37
fix: add Prisma migration file and fix empty displayName fallback
TerrifiedBug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
docs/superpowers/specs/2026-03-10-friendly-component-ids-design.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # Friendly Component IDs | ||
|
|
||
| Decouple pipeline component identity from user-facing display names. Component keys become immutable UUID-based identifiers used only in the backend (YAML, metrics, agent protocol). A new `displayName` field provides the human-readable label users see and edit in the GUI. | ||
|
|
||
| ## Problem | ||
|
|
||
| Today, `componentKey` serves as both the backend identifier (YAML keys, metrics matching, event sampling) and the user-facing label. Renaming a component changes the key, which requires a redeploy and orphans in-flight metrics. Users working in the GUI shouldn't need to trigger infrastructure changes just to rename a component. | ||
|
|
||
| ## Design | ||
|
|
||
| ### Data Model | ||
|
|
||
| Add a nullable `displayName` column to `PipelineNode`: | ||
|
|
||
| ```prisma | ||
| model PipelineNode { | ||
| // existing fields... | ||
| componentKey String // Immutable. Format: {type}_{nanoid(8)} | ||
| displayName String? // User-facing cosmetic name | ||
| // ... | ||
| } | ||
| ``` | ||
|
|
||
| - `componentKey` -- generated once at node creation, never modified. Format: `{componentType}_{nanoid(8)}` using a custom alphanumeric alphabet (`0-9A-Za-z`, no hyphens) to remain compatible with existing componentKey regex `/^[a-zA-Z_][a-zA-Z0-9_]*$/` and YAML key requirements. Examples: `http_server_k7xMp2nQ`, `remap_vT3bL9wR`. | ||
| - `displayName` -- nullable, editable anytime. Defaults to `componentDef.displayName` (e.g., "HTTP Server") on node creation. | ||
| - Display logic throughout the app: `displayName ?? componentKey`. | ||
|
|
||
| ### Component Key Generation & Immutability | ||
|
|
||
| **Node creation** (flow-store `addNode`): | ||
| - `componentKey = {componentDef.type}_{nanoid(8)}` | ||
| - `displayName = componentDef.displayName` | ||
|
|
||
| **Copy/paste & duplicate**: new UUID key generated, display name copied as-is (duplicates are fine -- display names are cosmetic). | ||
|
|
||
| **Immutability enforcement**: | ||
| - Remove `updateNodeKey` action from flow store. | ||
| - No user input path for `componentKey` -- generated once, stored, done. | ||
|
|
||
| **Validation**: | ||
| - `displayName`: permissive -- allow any printable characters (letters, numbers, spaces, hyphens, underscores, slashes, etc.) since some `componentDef.displayName` values may contain characters like `/`. Max 64 chars. | ||
| - `componentKey`: no user validation needed (system-generated). | ||
|
|
||
| ### GUI Changes | ||
|
|
||
| **Node components** (source-node, transform-node, sink-node): | ||
| - Render `displayName ?? componentKey` as the node label. | ||
|
|
||
| **Detail panel**: | ||
| - Current "Component Key" input becomes "Name", bound to `displayName`. | ||
| - Remove "Letters, numbers, and underscores only" hint. | ||
| - Add a small read-only "Component ID" field showing the UUID key (subtle, for debugging). | ||
| - Editing the name sets `isDirty: true` (requires save) but does not require redeploy. | ||
|
|
||
| **Edge connections**: unaffected (use React Flow node `id`, not `componentKey`). | ||
|
|
||
| **Metrics overlay**: unaffected (matched by `componentKey` which is unchanged). | ||
|
|
||
| ### Backend & Persistence | ||
|
|
||
| **Save pipeline**: persists both `componentKey` and `displayName`. Key written once on creation, never updated. Display name updates are a normal save. | ||
|
|
||
| **Deploy pipeline**: `generateVectorYaml()` uses `componentKey` for YAML keys. No changes. | ||
|
|
||
| **Metrics router**: matching logic (`componentId === pn.componentKey`) unchanged. Include `displayName` in frontend responses for GUI labeling. | ||
|
|
||
| **Event sampling**: uses `componentKey` throughout. No changes. | ||
|
|
||
| **Pipeline versions**: `nodesSnapshot` naturally includes `displayName` as part of node data. | ||
|
|
||
| **GitOps**: YAML uses UUID-based keys. Import leaves `displayName` null (falls back to key). No changes to git-sync or webhook handler. | ||
|
|
||
| ### Migration & Backwards Compatibility | ||
|
|
||
| **Database migration**: `ALTER TABLE PipelineNode ADD COLUMN displayName TEXT` (nullable, no default). | ||
|
|
||
| **Existing pipelines**: no data migration. Old components keep `{type}_{timestamp}` keys. `displayName` is `NULL` -- GUI shows `componentKey` as fallback. Users can optionally set display names on old components (just requires save). | ||
|
|
||
| **New components**: get `{type}_{nanoid(8)}` keys and `displayName = componentDef.displayName`. | ||
|
|
||
| **Mixed pipelines**: old timestamp keys and new UUID keys coexist. The system treats keys as opaque strings. | ||
|
|
||
| **Not changing**: pipeline names, agent/heartbeat protocol, metrics store structure, YAML generation logic (beyond key format for new nodes), GitOps sync logic. Note: `displayName` is intentionally not written into YAML output. | ||
|
|
||
| ### Implementation Notes | ||
|
|
||
| Files requiring `displayName` to be threaded through: | ||
|
|
||
| - **Prisma schema**: add `displayName String?` to `PipelineNode` model | ||
| - **FlowNodeData type** (`flow-store.ts`): add `displayName` to the interface | ||
| - **ClipboardData type** (`flow-store.ts`): include `displayName` for copy/paste | ||
| - **computeFlowFingerprint** (`flow-store.ts`): include `displayName` so renames trigger "unsaved changes" | ||
| - **nodeSchema** (`pipeline.ts`): add `displayName: z.string().nullable().optional()` | ||
| - **templateNodeSchema** (`template.ts`): same as above | ||
| - **dbNodesToFlowNodes** (`pipelines/[id]/page.tsx`): map `displayName` from DB row to node data | ||
| - **pasteFromSession** (`flow-store.ts`): generate fresh nanoid key (not collision-appended timestamp), copy displayName as-is | ||
| - **copyPipelineGraph** (`copy-pipeline-graph.ts`): preserve componentKey and displayName on clone/promote | ||
| - **Metrics router responses**: include `displayName` alongside `componentKey` in `getComponentMetrics` and `getNodePipelineRates` responses | ||
|
|
||
| ### Known Trade-offs | ||
|
|
||
| - **GitOps full-graph replacement**: bidirectional GitOps does delete-and-recreate on import, so display names set in the GUI will be lost if the pipeline is overwritten from Git. Acceptable given the current architecture. | ||
| - **No uniqueness enforcement on displayName**: two nodes can share the same display name. Users distinguish them by expanding the Component ID debug field if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20260310000000_add_display_name_to_pipeline_node/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "PipelineNode" ADD COLUMN "displayName" TEXT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Prisma migration file
displayName String?was added to thePipelineNodemodel in the schema, but no corresponding migration was generated and committed underprisma/migrations/.Per the project conventions,
npx prisma migrate dev --name add_display_namemust be run and the resulting migration file committed. Without it:prisma migrate deploy(which the Docker entrypoint runs automatically on startup) finds no pending migration, so thedisplayNamecolumn is never created in the database.displayName(save pipeline, rollback, copy-graph, metrics read, etc.) will fail at runtime with a database error about an unknown column.A migration file named something like
20260310000000_add_pipeline_node_display_namecontaining:must be added before this is merged.
Prompt To Fix With AI