Skip to content

feat: display pod labels in task list and detail views#110

Open
pingxin403 wants to merge 2 commits into
Project-HAMi:mainfrom
pingxin403:feat/labels-exported-pod
Open

feat: display pod labels in task list and detail views#110
pingxin403 wants to merge 2 commits into
Project-HAMi:mainfrom
pingxin403:feat/labels-exported-pod

Conversation

@pingxin403

@pingxin403 pingxin403 commented Jul 5, 2026

Copy link
Copy Markdown

Description

Add Pod labels display to HAMi-WebUI task management pages.

Backend changes

  • Add Labels map[string]string to biz.Container struct
  • Add map<string, string> labels = 20 to ContainerReply proto
  • Populate labels from pod.Labels in fetchContainerInfo
  • Map labels in service layer (GetAllContainers / GetContainer)
  • Unit tests for labels propagation

Frontend changes

  • Task list: add Tags column showing first 2 labels with +N overflow
  • Task detail: add Labels row in basic info section
  • Add i18n keys (zh/en)

Closes #85

Summary by CodeRabbit

  • New Features
    • Added task label support to the admin UI, including a Labels column in the workload table and label rendering in task details as compact key/value tags.
    • Added localized Labels text for English and Chinese.
  • Bug Fixes
    • Container details now consistently return label key/value pairs in both list and single-container views; when labels are unavailable, the UI shows a -- placeholder.
  • Tests
    • Added service tests covering container label behavior, including cases where labels are nil.

@hami-robot

hami-robot Bot commented Jul 5, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pingxin403

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot

hami-robot Bot commented Jul 5, 2026

Copy link
Copy Markdown

Welcome @pingxin403! It looks like this is your first PR to Project-HAMi/HAMi-WebUI 🎉

@hami-robot hami-robot Bot added the size/L label Jul 5, 2026
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ae30680-99cd-40ac-bdad-b20545ca8dd9

📥 Commits

Reviewing files that changed from the base of the PR and between fc09ba9 and 0a12f83.

📒 Files selected for processing (2)
  • packages/web/projects/vgpu/views/task/admin/index.vue
  • server/internal/data/pod.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • server/internal/data/pod.go
  • packages/web/projects/vgpu/views/task/admin/index.vue

📝 Walkthrough

Walkthrough

Adds container labels to backend responses and shows them in the web task admin views with matching English and Chinese labels.

Changes

Container Labels

Layer / File(s) Summary
Labels data contract and population
server/api/v1/container.proto, server/internal/biz/pod.go, server/internal/data/pod.go
Adds labels to the container response and biz model, and copies pod labels into container data during fetch.
Service label propagation and tests
server/internal/service/container.go, server/internal/service/container_test.go
Copies labels into GetAllContainers and GetContainer replies and adds tests for populated and nil label cases.
Labels display and locale strings
packages/web/projects/vgpu/views/task/admin/Detail.vue, packages/web/projects/vgpu/views/task/admin/index.vue, packages/web/src/locales/en.js, packages/web/src/locales/zh.js
Shows labels in the task detail and admin table views and adds the task.labels translations.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ContainerService
  participant PodRepo
  participant ContainerReply

  Client->>ContainerService: GetContainer / GetAllContainers
  ContainerService->>PodRepo: fetch container(s)
  PodRepo-->>ContainerService: Container with Labels map
  ContainerService->>ContainerReply: assign Labels from Container.Labels
  ContainerService-->>Client: reply with Labels
Loading

Poem

A bunny found some labels bright,
In tags they hop into the light.
From pod to page they flow,
With tidy keys in row by row,
Hop, hop — the labels feel just right. 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly summarizes the pod label display changes in task list and detail views.
Linked Issues check ✅ Passed The PR surfaces pod labels in task list and detail views, matching the request to display labels like exported_pod.
Out of Scope Changes check ✅ Passed All changes support label propagation, display, localization, or tests for the requested feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/web/projects/vgpu/views/task/admin/index.vue

Parsing error: Cannot find module '@vue/babel-plugin-jsx'
Require stack:

  • /node_modules/.pnpm/@babel+core@7.28.5/node_modules/@babel/core/lib/config/files/plugins.js
  • /node_modules/.pnpm/@babel+core@7.28.5/node_modules/@babel/core/lib/config/files/index.js
  • /node_modules/.pnpm/@babel+core@7.28.5/node_modules/@babel/core/lib/index.js
  • /node_modules/.pnpm/@babel+eslint-parser@7.28.5_@babel+core@7.28.5_eslint@8.56.0/node_modules/@babel/eslint-parser/lib/worker/babel-core.cjs
  • /node_modules/.pnpm/@babel+eslint-parser@7.28.5_@babel+core@7.28.5_eslint@8.56.0/node_modules/@babel/eslint-parser/lib/worker/handle-message.cjs
  • /node_modules/.pnpm/@babel+eslint-parser@7.28.5_@babel+core@7.28.5_eslint@8.56.0/node_modules/@babel/eslint-parser/lib/client.cjs
  • /node_modules/.pnpm/@babel+eslint-parser@7.28.5_@babel+core@7.28.5_eslint@8.56.0/node_modules/@babel/eslint-parser/lib/index.cjs
  • /node_modules/.pnpm/vue-eslint-parser@8.3.0_eslint@8.56.0/node_modules/vue-eslint-parser/index.js
  • /node_modules/.pnpm/eslint-plugin-vue@8.7.1_eslint@8.56.0/node_modules/eslint-plugin-vue/lib/utils/index.js
  • /node_modules/.pnpm/eslint-plugin-vue@8.7.1_eslint@8.56.0/node_modules/eslint-plugin-vue/lib/rules/array-bracket-newline.js
  • /node_modules/.pnpm/eslint-plugin-vue@8.7.1_eslint@8.56.0/node_modules/eslint-plugin-vue/lib/index.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs

Make sure that all the Babel plugins and presets you are using
are defined as dependencies or devDependencies in your package.json
file. It's possible that the missing plugin is loaded by a preset
you are using that forgot to add the plugin to its dependencies: you
can workaround this problem by explicitly adding the missing package
to your top-level package.json.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
server/internal/data/pod.go (1)

142-156: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider copying pod.Labels instead of sharing the reference.

pod.Labels is assigned by reference to every biz.Container built from this pod, and pod typically originates from an informer/lister cache. Per client-go convention, objects retrieved from Listers/Informers are cache pointers that must not be mutated without copying first, otherwise the cache is corrupted. Sharing this map across multiple containers (and potentially with the cached object) is safe today only because nothing currently mutates it downstream — if that changes, it becomes a shared-mutation hazard affecting the informer cache and other containers of the same pod.

🛡️ Proposed defensive copy
+		labels := make(map[string]string, len(pod.Labels))
+		for k, v := range pod.Labels {
+			labels[k] = v
+		}
 		c := &biz.Container{
 			Name:             ctr.Name,
 			UUID:             ctrIdMaps[ctr.Name],
 			ContainerIdx:     i,
 			NodeName:         pod.Spec.NodeName,
 			PodName:          pod.Name,
 			PodUID:           string(pod.UID),
 			Image:            ctr.Image,
 			Status:           containerStat[ctr.Name],
 			NodeUID:          r.GetNodeUUID(pod),
 			Namespace:        pod.Namespace,
 			CreateTime:       r.GetCreateTime(pod),
 			ContainerDevices: containerDevices,
-			Labels:           pod.Labels,
+			Labels:           labels,
 		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/internal/data/pod.go` around lines 142 - 156, The Container
construction in pod data handling is reusing pod.Labels by reference, which can
create shared-mutation risk with informer/lister cache objects. In the code that
builds biz.Container inside the pod processing logic, copy the labels map
defensively before assigning it to Labels so each container gets its own map
rather than sharing pod.Labels directly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/web/projects/vgpu/views/task/admin/index.vue`:
- Around line 193-197: Add a stable key to the `<t-tag>` elements rendered by
`visible.map(...)` in the task admin view. The list currently omits `key`, so
update the mapped tag in the same render block to use the item’s identifier
(`k`) consistently, matching the pattern used in `Detail.vue`, so Vue can track
each tag correctly across re-renders.

---

Nitpick comments:
In `@server/internal/data/pod.go`:
- Around line 142-156: The Container construction in pod data handling is
reusing pod.Labels by reference, which can create shared-mutation risk with
informer/lister cache objects. In the code that builds biz.Container inside the
pod processing logic, copy the labels map defensively before assigning it to
Labels so each container gets its own map rather than sharing pod.Labels
directly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 88dd55e3-144c-448c-8c1c-2dcd24a3e3c0

📥 Commits

Reviewing files that changed from the base of the PR and between c59f776 and 6a28db6.

📒 Files selected for processing (9)
  • packages/web/projects/vgpu/views/task/admin/Detail.vue
  • packages/web/projects/vgpu/views/task/admin/index.vue
  • packages/web/src/locales/en.js
  • packages/web/src/locales/zh.js
  • server/api/v1/container.proto
  • server/internal/biz/pod.go
  • server/internal/data/pod.go
  • server/internal/service/container.go
  • server/internal/service/container_test.go

Comment thread packages/web/projects/vgpu/views/task/admin/index.vue
Add Labels field to ContainerReply proto, biz model, and data layer.
Populate labels from pod.Labels in fetchContainerInfo.
Add Tags column to task list (first 2 labels + N overflow).
Add Labels row to task detail basic info.

Closes Project-HAMi#85

Signed-off-by: pingxin403 <pingxin403@users.noreply.github.com>
Address CodeRabbit review comments:
- Copy pod.Labels map to avoid informer cache shared-mutation risk
- Add missing :key to t-tag in task list Labels column

Signed-off-by: pingxin403 <52284317+pingxin403@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to display tags such as exported_pod

1 participant