Skip to content

feat: skill support auth scope - #2174

Merged
jsers merged 12 commits into
mainfrom
task/skill-auth-scope-teams-fc7805
Jul 14, 2026
Merged

feat: skill support auth scope#2174
jsers merged 12 commits into
mainfrom
task/skill-auth-scope-teams-fc7805

Conversation

@710leo

@710leo 710leo commented Jul 13, 2026

Copy link
Copy Markdown
Member
image

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added team-based authorization settings for Skills, including required team gating and public/private visibility selection.
    • Extended Skill create/upload/replace/Git update flows to capture and submit authorization (team selection + visibility), with prefilled values during replace/update.
  • Bug Fixes

    • Prevented enabling/disabling Skills without configured team authorization.
    • Preserved existing visibility when non-admin users edit.
  • Refactor

    • Removed the legacy resource browsing/file viewing and related interfaces.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dadc6716-c9c4-4319-b291-eb72ffbf1daf

📥 Commits

Reviewing files that changed from the base of the PR and between 82ea882 and 5186d0f.

📒 Files selected for processing (6)
  • src/pages/aiConfig/skills/pages/Form.tsx
  • src/pages/aiConfig/skills/pages/GitInstallModal.tsx
  • src/pages/aiConfig/skills/pages/GitReplaceConfigModal.tsx
  • src/pages/aiConfig/skills/pages/GitUpdateModal.tsx
  • src/pages/aiConfig/skills/pages/List.tsx
  • src/pages/aiConfig/skills/pages/UploadSkillModal.tsx
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/pages/aiConfig/skills/pages/GitInstallModal.tsx
  • src/pages/aiConfig/skills/pages/GitReplaceConfigModal.tsx
  • src/pages/aiConfig/skills/pages/GitUpdateModal.tsx
  • src/pages/aiConfig/skills/pages/List.tsx
  • src/pages/aiConfig/skills/pages/UploadSkillModal.tsx

📝 Walkthrough

Walkthrough

Skill management now supports team authorization and public/private scope across locale strings, forms, upload and Git import flows, permission-gated actions, and API payloads. Skill resource view components are removed.

Changes

Skill authorization

Layer / File(s) Summary
Authorization contracts and permission rules
src/pages/aiConfig/skills/types.ts, src/pages/aiConfig/skills/utils/*, src/pages/aiConfig/skills/locale/*
Shared authorization fields, edit permissions, privacy resolution, tests, and localized team/scope labels are added.
Authorization form controls
src/pages/aiConfig/skills/pages/SkillAuthFields.tsx, src/pages/aiConfig/skills/pages/Form.tsx, src/pages/aiConfig/skills/pages/UploadSkillModal.tsx, src/pages/aiConfig/skills/pages/GitForm.tsx, src/pages/aiConfig/skills/pages/SkillSidebar.tsx
Team options are fetched and rendered in required multi-select fields; admin users receive public/private scope controls, and upload/Git forms accept authorization values.
Authorization payloads and modal state
src/pages/aiConfig/skills/services.ts, src/pages/aiConfig/skills/pages/{AddModal,GitInstallModal,GitReplaceConfigModal,GitUpdateModal}.tsx
Import requests include authorization data, modal forms prefill authorization values, and submitted privacy values are normalized.
Skill editing and permission-gated actions
src/pages/aiConfig/skills/pages/List.tsx, src/pages/aiConfig/skills/pages/SkillDetailPanel.tsx
Import, update, replacement, enablement, deletion, and visibility controls use authorization data and edit-permission checks.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SkillSidebar
  participant UploadSkillModal
  participant SkillAuthFields
  participant getTeamInfoList
  participant importItem
  SkillSidebar->>UploadSkillModal: open upload modal
  UploadSkillModal->>SkillAuthFields: render authorization fields
  SkillAuthFields->>getTeamInfoList: fetch team options
  getTeamInfoList-->>SkillAuthFields: return user groups
  UploadSkillModal->>importItem: submit file and authorization values
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding Skill authorization scope support with management-team and visibility options.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/skill-auth-scope-teams-fc7805

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

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)
src/pages/aiConfig/skills/utils/permission.test.ts (1)

4-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider as const for test fixture objects.

As per coding guidelines, "In test data, prioritize as const for type narrowing to prevent string/numeric widening and catch typos in IDE." Adding as const to the admin and alice fixture objects would narrow the literal types and provide IDE-level typo detection.

♻️ Optional: add `as const` to fixtures
-  const admin = { admin: true, username: 'root' };
-  const alice = { admin: false, username: 'alice' };
+  const admin = { admin: true, username: 'root' } as const;
+  const alice = { admin: false, username: 'alice' } as const;
🤖 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 `@src/pages/aiConfig/skills/utils/permission.test.ts` around lines 4 - 5,
Update the admin and alice test fixture objects in permission.test.ts to use as
const, preserving their existing values while narrowing the admin and username
properties to literal types.

Source: Coding guidelines

🤖 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 `@src/pages/aiConfig/skills/pages/List.tsx`:
- Around line 439-441: Update the onImport callback in List.tsx to return the
promise from handleUpdateImport(selectedSkillData.id, file, auth). Preserve the
existing arguments so UploadSkillModal can await completion and receive upload
failures instead of closing immediately or creating an unhandled rejection.

---

Nitpick comments:
In `@src/pages/aiConfig/skills/utils/permission.test.ts`:
- Around line 4-5: Update the admin and alice test fixture objects in
permission.test.ts to use as const, preserving their existing values while
narrowing the admin and username properties to literal types.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4e68a6b-527a-4b75-9a4a-be6fe8098f5d

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd6927 and 859e938.

📒 Files selected for processing (21)
  • src/pages/aiConfig/skills/locale/en_US.ts
  • src/pages/aiConfig/skills/locale/ja_JP.ts
  • src/pages/aiConfig/skills/locale/ru_RU.ts
  • src/pages/aiConfig/skills/locale/zh_CN.ts
  • src/pages/aiConfig/skills/locale/zh_HK.ts
  • src/pages/aiConfig/skills/pages/EditModal.tsx
  • src/pages/aiConfig/skills/pages/Form.tsx
  • src/pages/aiConfig/skills/pages/GitForm.tsx
  • src/pages/aiConfig/skills/pages/GitReplaceConfigModal.tsx
  • src/pages/aiConfig/skills/pages/GitUpdateModal.tsx
  • src/pages/aiConfig/skills/pages/List.tsx
  • src/pages/aiConfig/skills/pages/ResourceModal.tsx
  • src/pages/aiConfig/skills/pages/ResourcesTable.tsx
  • src/pages/aiConfig/skills/pages/SkillAuthFields.tsx
  • src/pages/aiConfig/skills/pages/SkillDetailPanel.tsx
  • src/pages/aiConfig/skills/pages/SkillSidebar.tsx
  • src/pages/aiConfig/skills/pages/UploadSkillModal.tsx
  • src/pages/aiConfig/skills/services.ts
  • src/pages/aiConfig/skills/types.ts
  • src/pages/aiConfig/skills/utils/permission.test.ts
  • src/pages/aiConfig/skills/utils/permission.ts
💤 Files with no reviewable changes (2)
  • src/pages/aiConfig/skills/pages/ResourceModal.tsx
  • src/pages/aiConfig/skills/pages/ResourcesTable.tsx

Comment on lines +439 to 441
onImport={(file, auth) => {
handleUpdateImport(selectedSkillData.id, file, auth);
}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

onImport callback doesn't return the promise from handleUpdateImport — modal closes immediately.

The arrow function uses a block body without return, so onImport resolves to undefined. In UploadSkillModal's beforeUpload, await onSubmit(file, auth) resolves immediately and onCancel() fires — the modal closes before the upload completes. If handleUpdateImport fails, its throw _error becomes an unhandled rejection and the user cannot retry without reopening the modal and reselecting the file.

This contrasts with SkillSidebar (L420) and the empty-state modal (L385), where handleImport is passed directly and the promise is correctly awaited.

🐛 Proposed fix
-                      onImport={(file, auth) => {
-                        handleUpdateImport(selectedSkillData.id, file, auth);
-                      }}
+                      onImport={(file, auth) => handleUpdateImport(selectedSkillData.id, file, auth)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onImport={(file, auth) => {
handleUpdateImport(selectedSkillData.id, file, auth);
}}
onImport={(file, auth) => handleUpdateImport(selectedSkillData.id, file, auth)}
🤖 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 `@src/pages/aiConfig/skills/pages/List.tsx` around lines 439 - 441, Update the
onImport callback in List.tsx to return the promise from
handleUpdateImport(selectedSkillData.id, file, auth). Preserve the existing
arguments so UploadSkillModal can await completion and receive upload failures
instead of closing immediately or creating an unhandled rejection.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/pages/aiConfig/skills/pages/AddModal.tsx (1)

26-33: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Handle asynchronous errors and clean up form state.

The form validation and API request lack error handling, which can lead to unhandled promise rejections if validation fails or the network errors out. Additionally, the modal form state is not explicitly cleaned up on unmount or cancellation. As per coding guidelines, async requests must include error handling, and temporary container components must explicitly clean up form data on unmount.

🛠 Proposed fix
-      onCancel={onCancel}
-      onOk={() => {
-        form.validateFields().then((values) => {
-          postItem(adjustSubmitValues({ ...values, private: resolveSubmitPrivate(values.private) })).then(() => {
-            onOk();
-          });
-        });
-      }}
+      destroyOnClose
+      onCancel={() => {
+        form.resetFields();
+        onCancel();
+      }}
+      onOk={async () => {
+        try {
+          const values = await form.validateFields();
+          await postItem(adjustSubmitValues({ ...values, private: resolveSubmitPrivate(values.private) }));
+          onOk();
+        } catch (error) {
+          console.error(error);
+        }
+      }}
🤖 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 `@src/pages/aiConfig/skills/pages/AddModal.tsx` around lines 26 - 33, Update
the AddModal submit flow around form.validateFields and postItem to handle
validation and request failures without unhandled promise rejections, using the
component’s established error-handling pattern. Also explicitly reset or destroy
the form state when the modal is cancelled and when the component unmounts,
using the existing onCancel lifecycle and form instance.

Source: Coding guidelines

src/pages/aiConfig/skills/pages/EditModal.tsx (1)

52-62: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Handle asynchronous errors in form validation and submission.

The form validation and API request lack error handling, which can lead to unhandled promise rejections if validation fails or the request errors out. As per coding guidelines, async requests must include error handling.

🛠 Proposed fix
-      onOk={() => {
-        if (id) {
-          form.validateFields().then((values) => {
-            // 非 admin 未挂载「可见范围」字段,validateFields 不含 private;其当前值已由
-            // setFieldsValue(data) 存进 form store,用 getFieldValue 取出沿用,避免编辑改变可见性。
-            putItem(id, adjustSubmitValues({ ...values, private: resolveSubmitPrivate(values.private, form.getFieldValue('private')) })).then(() => {
-              onOk();
-            });
-          });
-        }
-      }}
+      onOk={async () => {
+        if (id) {
+          try {
+            const values = await form.validateFields();
+            // 非 admin 未挂载「可见范围」字段,validateFields 不含 private;其当前值已由
+            // setFieldsValue(data) 存进 form store,用 getFieldValue 取出沿用,避免编辑改变可见性。
+            await putItem(id, adjustSubmitValues({ ...values, private: resolveSubmitPrivate(values.private, form.getFieldValue('private')) }));
+            onOk();
+          } catch (error) {
+            console.error(error);
+          }
+        }
+      }}
🤖 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 `@src/pages/aiConfig/skills/pages/EditModal.tsx` around lines 52 - 62, Update
the onOk handler in EditModal to handle rejections from both
form.validateFields() and putItem(), using the existing project error-handling
pattern to surface or log failures. Ensure validation errors do not trigger
submission or the success callback, and API failures do not leave unhandled
promise rejections.

Source: Coding guidelines

🧹 Nitpick comments (1)
src/pages/aiConfig/skills/utils/permission.test.ts (1)

4-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Narrow types in test data using as const.

To prevent type widening (e.g., inferring boolean instead of true) and improve IDE typo detection, use as const when defining test data objects. As per coding guidelines, prioritize using as const in test data to narrow types.

🛠 Proposed fix
-  const admin = { admin: true, username: 'root' };
-  const alice = { admin: false, username: 'alice' };
+  const admin = { admin: true, username: 'root' } as const;
+  const alice = { admin: false, username: 'alice' } as const;
🤖 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 `@src/pages/aiConfig/skills/utils/permission.test.ts` around lines 4 - 5,
Update the admin and alice test data objects to use as const, preserving their
literal property types and improving typo detection without changing the values
or surrounding test logic.

Source: Coding guidelines

🤖 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.

Outside diff comments:
In `@src/pages/aiConfig/skills/pages/AddModal.tsx`:
- Around line 26-33: Update the AddModal submit flow around form.validateFields
and postItem to handle validation and request failures without unhandled promise
rejections, using the component’s established error-handling pattern. Also
explicitly reset or destroy the form state when the modal is cancelled and when
the component unmounts, using the existing onCancel lifecycle and form instance.

In `@src/pages/aiConfig/skills/pages/EditModal.tsx`:
- Around line 52-62: Update the onOk handler in EditModal to handle rejections
from both form.validateFields() and putItem(), using the existing project
error-handling pattern to surface or log failures. Ensure validation errors do
not trigger submission or the success callback, and API failures do not leave
unhandled promise rejections.

---

Nitpick comments:
In `@src/pages/aiConfig/skills/utils/permission.test.ts`:
- Around line 4-5: Update the admin and alice test data objects to use as const,
preserving their literal property types and improving typo detection without
changing the values or surrounding test logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8948bfee-714f-4edc-b5e9-5ff7358dcb34

📥 Commits

Reviewing files that changed from the base of the PR and between 859e938 and f58009f.

📒 Files selected for processing (18)
  • src/pages/aiConfig/skills/locale/en_US.ts
  • src/pages/aiConfig/skills/locale/ja_JP.ts
  • src/pages/aiConfig/skills/locale/ru_RU.ts
  • src/pages/aiConfig/skills/locale/zh_CN.ts
  • src/pages/aiConfig/skills/locale/zh_HK.ts
  • src/pages/aiConfig/skills/pages/AddModal.tsx
  • src/pages/aiConfig/skills/pages/EditModal.tsx
  • src/pages/aiConfig/skills/pages/Form.tsx
  • src/pages/aiConfig/skills/pages/GitInstallModal.tsx
  • src/pages/aiConfig/skills/pages/GitReplaceConfigModal.tsx
  • src/pages/aiConfig/skills/pages/GitUpdateModal.tsx
  • src/pages/aiConfig/skills/pages/List.tsx
  • src/pages/aiConfig/skills/pages/SkillAuthFields.tsx
  • src/pages/aiConfig/skills/pages/UploadSkillModal.tsx
  • src/pages/aiConfig/skills/services.ts
  • src/pages/aiConfig/skills/types.ts
  • src/pages/aiConfig/skills/utils/permission.test.ts
  • src/pages/aiConfig/skills/utils/permission.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/pages/aiConfig/skills/locale/zh_CN.ts
  • src/pages/aiConfig/skills/types.ts
  • src/pages/aiConfig/skills/locale/ja_JP.ts
  • src/pages/aiConfig/skills/utils/permission.ts
  • src/pages/aiConfig/skills/pages/SkillAuthFields.tsx
  • src/pages/aiConfig/skills/pages/GitReplaceConfigModal.tsx
  • src/pages/aiConfig/skills/locale/ru_RU.ts
  • src/pages/aiConfig/skills/services.ts
  • src/pages/aiConfig/skills/pages/UploadSkillModal.tsx
  • src/pages/aiConfig/skills/pages/List.tsx

710leo added 3 commits July 14, 2026 15:38
Form.tsx inlined its own managing-team select + admin-only visibility radio,
duplicating SkillAuthFields. Swap the inline block for <SkillAuthFields /> so the
team field rules and admin gating live in one place; behavior is unchanged
(AddModal/EditModal still fall back via resolveSubmitPrivate for non-admins).
…-teams-fc7805

# Conflicts:
#	src/pages/aiConfig/skills/pages/ResourcesTable.tsx
const fieldNames = profile.admin ? ['git_ref_type', 'git_ref', 'user_group_ids', 'private'] : ['git_ref_type', 'git_ref', 'user_group_ids'];
values = (await form.validateFields(fieldNames)) as Pick<GitInstallPayload, 'git_ref_type' | 'git_ref' | 'user_group_ids' | 'private'>;
} catch {
return;

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.

catch 得有点动作,哪怕是把错误打印出来,不然上面 try 代码块里出错了,会毫无头绪

validateFields 与 getItem 详情降级的 catch 静默吞错,出问题时毫无排查线索;
按 PR 评论意见统一补 console.error。
@jsers
jsers merged commit e9a6bca into main Jul 14, 2026
1 check passed
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.

2 participants