admin: filter plugin jobs and activities by volume id (#13077)

* admin: keep the volume id on tracked plugin jobs

Volume-scoped jobs carry their volume in the volume_id parameter, but
the in-memory job list drops parameters, so nothing could select a
volume's jobs without reading every job detail file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: filter plugin jobs and activities by volume id

/api/plugin/jobs and /api/plugin/activities accept volume_id, applied
before the limit like the lane filter. Activities follow the tracked
jobs of that volume.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: volume id filter on the plugin monitor

A Volume ID box next to the execution state filter narrows the queue,
execution jobs and activities to that volume's jobs, fetched with the
volume_id API filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: keep detection scans visible under the volume filter

Detection activities belong to no job, so the volume-filtered activity
window had none of them and the Detection Jobs table went empty. That
table now reads its own job-type window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: accept zero-padded volume ids in the monitor filter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: drop a monitor refresh that finishes after a newer one

Two refreshes of the same scope can finish out of order; the older one
then replaced the newer rows, with empty lists when its volume-filtered
fetch failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: keep rows committed for the scope when a plugin monitor refresh fails

A failed request fell back to the rows captured when the refresh started,
so a refresh overlapping one that had already committed the new scope's
rows cleared them. Resolve the fallback when the refresh commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: validate the monitor volume id before fetching

Out-of-range ids went to the APIs and came back 400. The filter is now
applied only from a valid change event, so the periodic refresh no longer
reads a value still being typed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: volume id filter on the job queue view

The queue renders the volume-scoped rows, but the only filter box sat on
the execution view, so an active filter was invisible and could not be
cleared there. Both views now carry a box kept in sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: reject unparsable volume id text instead of clearing the filter

A number input holding text like "1e" reports an empty value with
validity.badInput set; treat it as invalid rather than as a cleared box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 authored and GitHub committed 2026-11-27 18:42:11 -08:00
1 parent ec34160a1a
commit 40a95a8ef5
7 files changed
+271 -18

No files matched your search

+58 -3
View File
@@ -70,6 +70,47 @@ func filterActivitiesByLane(activities []plugin.JobActivity, laneFilter string)
return filtered
}
func parseVolumeIDFilter(raw string) (uint32, error) {
raw = strings.TrimSpace(raw)
if raw == "" {
return 0, nil
}
value, err := strconv.ParseUint(raw, 10, 32)
if err != nil || value == 0 {
return 0, fmt.Errorf("invalid volume_id %q", raw)
}
return uint32(value), nil
}
func filterTrackedJobsByVolume(jobs []plugin.TrackedJob, volumeID uint32) []plugin.TrackedJob {
if volumeID == 0 {
return jobs
}
filtered := make([]plugin.TrackedJob, 0, len(jobs))
for _, job := range jobs {
if job.VolumeID == volumeID {
filtered = append(filtered, job)
}
}
return filtered
}
func filterActivitiesByJobs(activities []plugin.JobActivity, jobs []plugin.TrackedJob) []plugin.JobActivity {
jobIDs := make(map[string]struct{}, len(jobs))
for _, job := range jobs {
jobIDs[job.JobID] = struct{}{}
}
filtered := make([]plugin.JobActivity, 0, len(activities))
for _, activity := range activities {
if _, ok := jobIDs[activity.JobID]; ok {
filtered = append(filtered, activity)
}
}
return filtered
}
// GetPluginStatusAPI returns plugin status.
func (s *AdminServer) GetPluginStatusAPI(w http.ResponseWriter, r *http.Request) {
plugin := s.GetPlugin()
@@ -153,10 +194,15 @@ func (s *AdminServer) GetPluginJobsAPI(w http.ResponseWriter, r *http.Request) {
jobType := strings.TrimSpace(query.Get("job_type"))
state := strings.TrimSpace(query.Get("state"))
laneFilter := strings.TrimSpace(query.Get("lane"))
volumeID, err := parseVolumeIDFilter(query.Get("volume_id"))
if err != nil {
writeJSONError(w, http.StatusBadRequest, err.Error())
return
}
limit := parsePositiveInt(query.Get("limit"), 200)
// Apply the lane before the limit, or a busy lane's newest rows crowd out a quiet lane.
// Apply the filters before the limit, or a busy lane's newest rows crowd out a quiet lane.
listLimit := limit
if laneFilter != "" {
if laneFilter != "" || volumeID != 0 {
listLimit = 0
}
jobs := s.ListPluginJobs(jobType, state, listLimit)
@@ -165,6 +211,7 @@ func (s *AdminServer) GetPluginJobsAPI(w http.ResponseWriter, r *http.Request) {
return
}
jobs = filterTrackedJobsByLane(jobs, laneFilter)
jobs = filterTrackedJobsByVolume(jobs, volumeID)
if len(jobs) > limit {
jobs = jobs[:limit]
}
@@ -261,9 +308,14 @@ func (s *AdminServer) GetPluginActivitiesAPI(w http.ResponseWriter, r *http.Requ
query := r.URL.Query()
jobType := strings.TrimSpace(query.Get("job_type"))
laneFilter := strings.TrimSpace(query.Get("lane"))
volumeID, err := parseVolumeIDFilter(query.Get("volume_id"))
if err != nil {
writeJSONError(w, http.StatusBadRequest, err.Error())
return
}
limit := parsePositiveInt(query.Get("limit"), 500)
listLimit := limit
if laneFilter != "" {
if laneFilter != "" || volumeID != 0 {
listLimit = 0
}
activities := s.ListPluginActivities(jobType, listLimit)
@@ -272,6 +324,9 @@ func (s *AdminServer) GetPluginActivitiesAPI(w http.ResponseWriter, r *http.Requ
return
}
activities = filterActivitiesByLane(activities, laneFilter)
if volumeID != 0 {
activities = filterActivitiesByJobs(activities, filterTrackedJobsByVolume(s.ListPluginJobs(jobType, "", 0), volumeID))
}
if len(activities) > limit {
activities = activities[:limit]
}