background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

Share source fields and submit guards between single-skill and collection import

Open open-inspect opened this issue 1 month ago • 0 comments

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 selectionKey helper from bulk-skill-import-review.tsx. skill.source.subdirectory ?? "" is written out 5 times in skill-collection-import.tsx.
  • The available-and-selected filter (skill.nameAvailable && selectedRoots.has(...)) is computed in 3 places: in confirmImport, for selectedCount, and in BulkSkillImportReview. Derive it once.
  • The duplicate-name check runs in two places: in the collection preview route (handlePreviewBulkSkillImport, nameCounts) and in SkillStore.createImportedSkills. The store check is the authoritative write-time guard. Consider sharing a single helper so the two can't drift.

open-inspect avatar Oct 29 '26 07:10 open-inspect