Skip to content

fix(web): exclude generic template shadow references from role usage - #1526

Open
chengjoey wants to merge 1 commit into
Tencent:mainfrom
chengjoey:fix/1496-agent-usage-generic-templates
Open

chengjoey wants to merge 1 commit into
Tencent:mainfrom
chengjoey:fix/1496-agent-usage-generic-templates

Conversation

@chengjoey

Copy link
Copy Markdown

What changed

Fixes #1496. Generic LOOP templates are appended to /api/bootstrap by
CatalogRepo.Workflows(). The agent catalog counted their nodes as references
to project roles that reuse a template role id, so an empty project showed
"N 个节点" and disabled Delete, while DELETE /api/agents/:id correctly
allowed it via AgentShadowsTemplateOutside.

The frontend now mirrors the server rule: a project-owned, non-shared role
whose id appears in a generic template only resolves to LOOPs in its own
project. Platform and shared roles still resolve in every LOOP.

Scope

  • Platform core / API / runner (web asset catalog + catalog contract test)

Compatibility

No schema, migration, runner protocol, or bootstrap/API contract changes.
Only the agent catalog usage count and its delete-disable check are affected;
stored roles and LOOPs are untouched. Follow-up (not in this PR): have the
server publish resolved usage details as the single source of truth.

Validation

PASSED: node --test webtest/tests/assets-agents.test.mjs (13/13)
PASSED: npm --prefix webtest test (397/397)
PASSED: npm --prefix webtest run coverage (85.3% >= 85%)
PASSED: go test ./web ./internal/repo -count=1
PASSED: go test ./internal/httpapi -run '<catalog/bootstrap/agent subset>' -count=1 (5/5)
PASSED: go vet ./... ; python3 scripts/check-public.py ; scripts/scan-secrets.sh
NOT RUN: full go test -p=2 ./... (bwrap/Chromium unavailable in the local
container; CI installs bubblewrap), chatbot tests, e2e/public browser suite.
The regression test fails on main with "2 个节点" and passes with this change.

Safety

  • No credentials, internal endpoints, production data, or org-specific infrastructure
  • Preserved user files and unrelated changes
  • No Classic host bundle or third-party content changes

The agent catalog counted nodes from generic LOOP templates (appended by CatalogRepo.Workflows to /api/bootstrap) as references to project roles that reuse a template role id. An empty project showed inflated usage and disabled Delete, while DELETE /api/agents/:id correctly allowed it via AgentShadowsTemplateOutside. Mirror the server rule: a project-owned, non-shared role with a template twin only resolves to LOOPs in its own project; platform and shared roles still resolve everywhere. Refs Tencent#1496.
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.

[Bug]: 角色「引用」计数把通用模板节点算成本项目角色的引用,项目无流程也显示被引用且删除被禁用

1 participant