Skip to content

Add persistent host display names - #145

Merged
rodriguecyber merged 1 commit into
Open-Source-Kigali:developfrom
samuelxanda:feat/123-persistent-host-display-names
Aug 25, 2026
Merged

Add persistent host display names#145
rodriguecyber merged 1 commit into
Open-Source-Kigali:developfrom
samuelxanda:feat/123-persistent-host-display-names

Conversation

@samuelxanda

@samuelxanda samuelxanda commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add an optional displayName on the Agent model so admins can give hosts a dashboard-friendly label that survives restarts and agent re-registration.
  • Expose displayName on GET /api/hosts (falls back to hostname when unset) and add admin-only PATCH /api/hosts/:id with non-empty / max-length validation.
  • VIEWER callers get 403; existing hostname consumers 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.ts
  • Apply migration (npm run db:migrate) and restart the server
  • GET /api/hosts as an authenticated user: displayName equals hostname when unset
  • PATCH /api/hosts/:id as ADMIN with { "displayName": "prod-web-1" } returns 200; hostname is unchanged
  • Reconnect the agent and confirm displayName is still prod-web-1
  • Same PATCH as VIEWER returns 403
  • Empty / whitespace / >64 character names return 400

Copilot AI lite review requested due to automatic review settings August 24, 2026 20:28
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
samuelxanda force-pushed the feat/123-persistent-host-display-names branch from 0fb4b29 to db5cea1 Compare August 24, 2026 20:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 displayName to the Agent Prisma model + migration.
  • Return displayName in host DTOs (fallback to hostname) and add PATCH /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 },
});
}
@rodriguecyber
rodriguecyber merged commit a893401 into Open-Source-Kigali:develop Aug 25, 2026
1 check passed
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.

[Backend] Add persistent host display names

3 participants