Add persistent host display names - #145
Merged
rodriguecyber merged 1 commit intoAug 25, 2026
Merged
Conversation
Hosts only exposed the agent hostname, so dashboard names could not survive reconnects. Store an optional displayName on Agent and let admins set it. Co-authored-by: Cursor <cursoragent@cursor.com>
samuelxanda
force-pushed
the
feat/123-persistent-host-display-names
branch
from
August 24, 2026 20:31
0fb4b29 to
db5cea1
Compare
There was a problem hiding this comment.
Pull request overview
Adds persistent, operator-defined host display names by extending the Agent model, returning displayName from the hosts list (fallback to hostname), and introducing an admin-only PATCH endpoint to update it with validation and tests.
Changes:
- Add nullable
displayNameto theAgentPrisma model + migration. - Return
displayNamein host DTOs (fallback tohostname) and addPATCH /hosts/:id(ADMIN-only) to update it. - Add unit/controller tests covering fallback behavior, update behavior, role enforcement, and validation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/server/src/hosts/hosts.service.ts | Adds displayName to host DTOs (fallback to hostname) and supports updating it via service method. |
| apps/server/src/hosts/hosts.service.spec.ts | Tests displayName fallback, stored displayName, update path, and missing-host behavior. |
| apps/server/src/hosts/hosts.controller.ts | Adds admin-only PATCH endpoint for updating host displayName. |
| apps/server/src/hosts/hosts.controller.spec.ts | Tests PATCH authorization (ADMIN vs VIEWER), validation, and 404 behavior. |
| apps/server/src/hosts/dto/update-host.dto.ts | Defines validation + trimming transform and max-length constant for displayName updates. |
| apps/server/src/agents/agents.service.ts | Ensures re-registration does not overwrite displayName and adds updateDisplayName() persistence method. |
| apps/server/src/agents/agents.service.spec.ts | Tests re-registration doesn’t overwrite displayName and updateDisplayName() behavior. |
| apps/server/prisma/schema.prisma | Adds displayName field to Agent model. |
| apps/server/prisma/migrations/20260824221500_add_agent_display_name/migration.sql | Adds displayName column to agents table. |
| apps/server/package.json | Adds Jest moduleNameMapper rule for stripping .js in relative imports. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+81
to
+94
| async updateDisplayName( | ||
| id: string, | ||
| displayName: string, | ||
| ): Promise<Agent | null> { | ||
| const existing = await this.findById(id); | ||
| if (!existing) { | ||
| return null; | ||
| } | ||
|
|
||
| return this.prisma.agent.update({ | ||
| where: { id }, | ||
| data: { displayName }, | ||
| }); | ||
| } |
This was referenced Aug 24, 2026
rodriguecyber
approved these changes
Aug 25, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
displayNameon the Agent model so admins can give hosts a dashboard-friendly label that survives restarts and agent re-registration.displayNameonGET /api/hosts(falls back to hostname when unset) and add admin-onlyPATCH /api/hosts/:idwith non-empty / max-length validation.hostnameconsumers keep working.Fixes #123
Test plan
npm run test --workspace=@docksight/server -- --runInBand src/hosts/hosts.service.spec.ts src/hosts/hosts.controller.spec.ts src/agents/agents.service.spec.tsnpm run db:migrate) and restart the serverGET /api/hostsas an authenticated user:displayNameequalshostnamewhen unsetPATCH /api/hosts/:idas ADMIN with{ "displayName": "prod-web-1" }returns 200; hostname is unchangeddisplayNameis stillprod-web-1