Skip to content

fix(agent): honor multi-select canvas category filter in Go /agents listing - #19625

Open
euvre wants to merge 1 commit into
infiniflow:mainfrom
euvre:fix/agent-multi-category-filter
Open

euvre wants to merge 1 commit into
infiniflow:mainfrom
euvre:fix/agent-multi-category-filter

Conversation

@euvre

@euvre euvre commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Supersedes #19553 (that PR was corrupted by the worktree-sweep delivery fault and cannot be reopened after the force-push; this is the same fix at proper paths).

Summary

On the agents list page, selecting a single "canvas category" filter (e.g. workflow, count 8) returned the right cards, but selecting two or three categories at once returned an empty list ("no agents yet"), or — when "compilation operator" was among the selections — left only the compilation template group cards while every agent card disappeared.

The page sends multi-select categories as one comma-joined canvas_category query value (dataflow_canvas,agent_canvas). The Python /v1/agents implementation (from #17843) splits that value and filters with canvas_category IN (...). The Go mirror never got that update: UserCanvasDAO.ListByTenantIDs compared the raw joined string for equality (canvas_category = 'dataflow_canvas,agent_canvas'), which matches no row, so:

  • two categories selected → 0 canvases → empty state;
  • compilation_template_group + agent categories selected → agents query returns 0, only the caller's template groups survive the merge;
  • single category selected → the string has no comma and happens to equal a real value → works, which is why the bug only showed up with multi-select.

Changes

  • internal/dao/user_canvas.go: ListByTenantIDs now takes canvasCategories []string and filters with canvas_category IN ?, mirroring Python UserCanvasService.get_by_tenant_ids.
  • internal/service/agent.go: ListAgents passes the already-split agentCategories list straight to the DAO (the re-join into a comma string and the raw-string fallback are gone); merge/mixed-mode SQL-pagination disabling is unchanged.
  • Tests: TestListAgents_MultiCategoryFilter (service level, through the raw comma-joined query value: 2 categories → union of 3/3, single category → 2/2) and TestUserCanvasDAOListByTenantIDsCategoryUnion (DAO union semantics); existing DAO call sites updated to the new slice parameter.

Verification

  • bash build.sh --test ./internal/dao/... ./internal/service/... passes (unit tier, in-memory SQLite).
  • Semantics re-checked line-by-line against the Python path (api/apps/restful_apis/agent_api.py list_agents + api/db/services/canvas_service.py get_by_tenant_ids): split → IN union, None/empty → unfiltered, groups-only and merge modes untouched.
  • Boundary: no browser end-to-end screenshots this round — the local backend services could not start in this environment (Python API venv missing, Go gateway native deps only rebuilt mid-round), so verification is unit-test + Python-parity based. The changed code path is the Go API listing endpoint only; no frontend change was needed.

…isting

The frontend sends the agents-page canvas-category multi-select as a
comma-joined canvas_category value. The Python handler splits it and
filters with IN, but the Go UserCanvasDAO compared the raw joined string
for equality, so selecting more than one category matched zero canvases:
the list showed the empty state, and in mixed mode only compilation
template groups remained.

Pass the already-split category list from AgentService.ListAgents into
UserCanvasDAO.ListByTenantIDs and match with canvas_category IN (...),
restoring parity with UserCanvasService.get_by_tenant_ids.
@euvre euvre added the ci Continue Integration label Sep 14, 2026
@euvre
euvre requested a review from wangq8 September 14, 2026 11:24
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: fd9dfc25-a030-4203-95f6-564d88f9a58a

📥 Commits

Reviewing files that changed from the base of the PR and between 5fde007 and d411d50.

📒 Files selected for processing (4)
  • internal/dao/user_canvas.go
  • internal/dao/user_canvas_test.go
  • internal/service/agent.go
  • internal/service/agent_test.go

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The DAO now accepts multiple canvas categories and filters with SQL IN. ListAgents forwards filtered category slices directly to the DAO. DAO and service tests verify combined and single-category results.

Changes

Canvas category filtering

Layer / File(s) Summary
DAO category filter
internal/dao/user_canvas.go, internal/dao/user_canvas_test.go
ListByTenantIDs accepts category slices and applies an SQL IN filter. Tests cover combined categories, single categories, and calls without a category filter.
Agent category forwarding
internal/service/agent.go, internal/service/agent_test.go
ListAgents passes filtered agent categories to the DAO. Tests verify combined and single-category results.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Suggested reviewers: jinhai-cn

Merge Risk: ⚪ Minimal · up to d411d

Multi-category filtering is forwarded correctly while empty, groups-only, and merge-mode paths retain their prior behavior. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: fixing multi-select canvas category filtering in the Go /agents listing.
Description check ✅ Passed The description includes the required Summary section and provides clear background, failure behavior, implementation details, tests, verification results, and limitations.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit sorts the canvas rows,
Through category paths the query goes.
Two labels join the searching stream,
One label keeps its narrower theme.
The tests check both paths with care,
And find the right results waiting there.

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

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is an AI review comment.

Summary

Fixes the Go /agents listing so a multi-select canvas_category (comma-joined into a single query value) filters with IN (...) instead of an exact string match, mirroring Python UserCanvasService.get_by_tenant_ids. The change is small and correct: the DAO now takes []string, all call sites (service + tests) are updated, and both single- and multi-category semantics are covered by new tests.

Findings

  • Correctly removes the buggy strings.Join(agentCategories, ",") path; strings is still used elsewhere in the file, so no unused-import issue.
  • The len(canvasCategories) > 0 guard preserves the unfiltered case, and merge/mixed pagination behavior is unchanged, as intended.
  • Tests (TestUserCanvasDAOListByTenantIDsCategoryUnion, TestListAgents_MultiCategoryFilter) assert union semantics through the raw comma-joined query value — good coverage at the service level.

Minor:

  • The doc comment above ListByTenantIDs still says canvasCategory; rename to canvasCategories for consistency.
  • The author notes there was no browser E2E this round. Given the user-visible symptom is exactly "multi-select returns an empty list", a quick manual check on the agents page with 2–3 categories selected before merge would be worthwhile.

Looks good to me once the minor items are addressed.

This is an AI review comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants