Skip to content

feat: add host rename form for admins - #146

Closed
samuelxanda wants to merge 2 commits into
Open-Source-Kigali:developfrom
samuelxanda:feat/124-host-rename-form
Closed

feat: add host rename form for admins#146
samuelxanda wants to merge 2 commits into
Open-Source-Kigali:developfrom
samuelxanda:feat/124-host-rename-form

Conversation

@samuelxanda

@samuelxanda samuelxanda commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a rename action on the host card menu so admins can set a dashboard-friendly display name. The agent hostname stays visible as secondary metadata, and the hosts query updates without a full page reload.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs
  • Infrastructure / CI
  • Breaking change

Areas touched

  • apps/server (NestJS)
  • apps/web (React / Vite)
  • apps/agent (Go)
  • packages/protocol (shared WebSocket contracts)
  • infrastructure / .github/workflows
  • docs

Related issues

Closes #124

Depends on the API from #123 / #145 (PATCH /api/hosts/:id and displayName on GET /api/hosts).

How to test

  1. npm run test --workspace=@docksight/web -- src/lib/host-name.test.ts src/services/hosts.test.ts
  2. Sign in as ADMIN, open Hosts, use the card menu Rename, set a name, Save.
  3. Confirm the card title, host select, and search show the new name without a reload; hostname remains on the card.
  4. Empty / whitespace names are rejected in the form.
  5. Sign in as VIEWER — the Rename action is hidden.

Checklist

  • Change is focused and stays within the existing modular monolith boundaries.
  • Ran the relevant checks locally (see below).
  • Updated docs under docs/ if module boundaries or the protocol changed.
  • Added an ADR under docs/decisions/ if this is a larger architectural change.

Operators could not set a friendly host name in the dashboard. Add a card-menu form that PATCHes displayName and refreshes the hosts query.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI lite review requested due to automatic review settings August 24, 2026 20:44

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 a frontend-only host “Rename” capability (admin-gated) that uses the backend displayName field to show a dashboard-friendly label while keeping the agent hostname visible as secondary metadata.

Changes:

  • Add displayName to the Host API type plus shared helpers for display/validation (hostDisplayName, validateHostDisplayName).
  • Add PATCH /hosts/:id client support (apiPatch, renameHost) and a React Query mutation hook to update/invalidate the hosts cache.
  • Update Hosts UI surfaces (Host cards, host select, search, details page) to render/search by display name.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
apps/web/src/types/api.ts Adds optional displayName to Host type.
apps/web/src/services/hosts.ts Adds renameHost() PATCH service call.
apps/web/src/services/hosts.test.ts Adds unit test covering renameHost() PATCH payload.
apps/web/src/services/api.ts Extends request client to support PATCH and exposes apiPatch.
apps/web/src/lib/host-name.ts Introduces display-name formatting + validation utilities.
apps/web/src/lib/host-name.test.ts Adds tests for display-name formatting + validation.
apps/web/src/hooks/useRenameHost.ts Adds React Query mutation for rename + cache update/toast.
apps/web/src/hooks/useHostInventory.ts Uses display name in container inventory host label derivation.
apps/web/src/features/hosts/HostsPage.tsx Updates host search to include display name.
apps/web/src/features/hosts/HostDetailsPage.tsx Updates titles/breadcrumbs/metadata to show display name while keeping hostname visible.
apps/web/src/components/RenameHostDialog.tsx Adds modal dialog for renaming (validation + API errors).
apps/web/src/components/layout/Topbar.tsx Updates global host search results to prefer display name and show hostname secondary.
apps/web/src/components/HostSelect.tsx Updates host selector to show display name.
apps/web/src/components/HostCard.tsx Adds admin-only Rename action + dialog and renders display name as card title with hostname secondary.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/web/src/hooks/useRenameHost.ts Outdated
Comment on lines +20 to +22
queryClient.setQueryData<Host[]>(hostsQueryKey, (current) =>
current?.map((host) => (host.id === updated.id ? { ...host, ...updated } : host)),
)
Comment on lines 47 to 53
const all = hosts.flatMap((host, index) =>
(results[index]?.data?.containers ?? []).map((container) => ({
...container,
hostId: host.id,
hostname: host.hostname,
hostname: hostDisplayName(host),
})),
)
@samuelxanda
samuelxanda marked this pull request as draft August 24, 2026 21:09
Avoid clearing the cached host list when React Query has no data yet, and keep the agent hostname searchable in container views.

Co-authored-by: Cursor <cursoragent@cursor.com>
@samuelxanda
samuelxanda marked this pull request as ready for review August 24, 2026 21:36
@samuelxanda

Copy link
Copy Markdown
Contributor Author

Superseded by #149 on branch feat/124-admin-host-rename.

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.

[Frontend] Add host rename form for admins

2 participants