background-agents
background-agents copied to clipboard
Share source fields and submit guards between single-skill and collection import
Follow-up to #2403 (collection import for managed skills, #1931).
Duplication between the two import modes
About 55% of the non-trivial lines in SkillCollectionImport (packages/web/src/components/settings/skills-settings/skill-collection-import.tsx) repeat SingleSkillImport (skill-import.tsx):
- repository select and ref input fields, including the loading and error states
- the
mounted/ in-progress (importActive) guards around preview and confirm - the confirm flow: busy state, success and error toasts, and the unmount checks in
finally - assignment toggles wired to
SkillAssignments - the "assignment targets are still loading or failed to load" notice
- the trusted-instructions warning
Suggested shape
- A shared source-fields component for repository, ref, and path (subdirectory or prefix), parameterized by labels and IDs.
- A guarded-submit hook that owns the mounted and in-flight refs, the busy callback, and error toasts. Both modes, and possibly
SkillReimport, can then run confirmation through it.
Smaller cleanups
- Export and reuse the
selectionKeyhelper frombulk-skill-import-review.tsx.skill.source.subdirectory ?? ""is written out 5 times inskill-collection-import.tsx. - The available-and-selected filter (
skill.nameAvailable && selectedRoots.has(...)) is computed in 3 places: inconfirmImport, forselectedCount, and inBulkSkillImportReview. Derive it once. - The duplicate-name check runs in two places: in the collection preview route (
handlePreviewBulkSkillImport,nameCounts) and inSkillStore.createImportedSkills. The store check is the authoritative write-time guard. Consider sharing a single helper so the two can't drift.