Skip to content

Optimize relationship visibility and org path handling#470

Open
yaojin3616 wants to merge 1 commit intomainfrom
opt/relationship-visibility-org-path
Open

Optimize relationship visibility and org path handling#470
yaojin3616 wants to merge 1 commit intomainfrom
opt/relationship-visibility-org-path

Conversation

@yaojin3616
Copy link
Copy Markdown
Collaborator

Summary

  • support multi-select human and agent relationship management with searchable candidate lists
  • centralize agent visibility rules and restrict visibility to same-tenant accessible agents only
  • rebuild org department/member paths from department hierarchy and add backfill support
  • redirect tenant switching to the homepage instead of preserving the current route

Validation

  • PYTHONPATH=backend pytest backend/tests/test_agent_visibility.py -q
  • PYTHONPATH=backend pytest backend/tests/test_org_sync_adapter.py -q
  • python3 -m py_compile backend/app/core/permissions.py backend/app/api/agents.py backend/app/api/relationships.py backend/app/services/org_sync_adapter.py backend/app/api/enterprise.py backend/app/scripts/backfill_department_paths.py
  • npm run build

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b5f8706ad

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +75 to +76
if item.target_agent_id == str(agent_id):
continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize target IDs before filtering self relationships

The new self-reference guard compares item.target_agent_id to str(agent_id) as raw strings, but save_agent_relationships no longer re-checks after parsing to UUID. If a client sends an equivalent UUID in a different string form (e.g., uppercase or brace-wrapped), this check is bypassed and the API can persist an agent-to-itself relationship, which the previous implementation explicitly prevented.

Useful? React with 👍 / 👎.

Comment on lines +456 to +457
# Path is rebuilt from the internal department tree after sync.
path = dept.name
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep parent linkage resilient to unordered department sync

This change drops the provider-side parent hint from path and relies on post-sync rebuilding from parent_id, but parent_id is only set when the parent row already exists during upsert. If departments arrive child-before-parent (the WeCom adapter consumes API order directly), children are saved with parent_id=None, and the rebuild then writes flattened top-level paths, which propagates incorrect org paths to members and breaks hierarchical department filtering until a later sync happens to reorder correctly.

Useful? React with 👍 / 👎.

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.

1 participant