From eeee322248b990dc1949c9c65aaa1cd87d695dd3 Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:10:03 +0800 Subject: [PATCH] feat(suite): surface active bundle publishing Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- .../specs/suite-bundle-publishing/spec.md | 10 +- .../add-suite-bundle-publishing/tasks.md | 2 +- .../portal/SkillSuiteBundleController.java | 10 ++ ...llSuiteBundleOperationSummaryResponse.java | 21 ++++ ...SkillSuiteBundleOperationQueryService.java | 59 ++++++++++ .../SkillSuiteBundleControllerTest.java | 17 +++ ...lSuiteBundleOperationQueryServiceTest.java | 39 +++++++ ...iteBundleExecutionOperationRepository.java | 2 + ...killSuiteBundleMemberResultRepository.java | 3 + ...lSuiteBundleMemberResultJpaRepository.java | 10 ++ web/src/api/generated/schema.d.ts | 101 ++++++++++++++++++ web/src/api/types.ts | 4 + .../features/suite/suite-bundle-import.tsx | 8 ++ web/src/i18n/locales/en.json | 4 + web/src/i18n/locales/ru.json | 4 + web/src/i18n/locales/zh.json | 4 + web/src/pages/dashboard/my-suites.test.tsx | 53 +++++++++ web/src/pages/dashboard/my-suites.tsx | 64 ++++++++++- web/src/shared/hooks/use-suite-queries.ts | 11 ++ 19 files changed, 422 insertions(+), 4 deletions(-) create mode 100644 server/skillhub-app/src/main/java/com/iflytek/skillhub/dto/SkillSuiteBundleOperationSummaryResponse.java create mode 100644 web/src/pages/dashboard/my-suites.test.tsx diff --git a/openspec/changes/add-suite-bundle-publishing/specs/suite-bundle-publishing/spec.md b/openspec/changes/add-suite-bundle-publishing/specs/suite-bundle-publishing/spec.md index 8ce0ea3b2..69b9d212b 100644 --- a/openspec/changes/add-suite-bundle-publishing/specs/suite-bundle-publishing/spec.md +++ b/openspec/changes/add-suite-bundle-publishing/specs/suite-bundle-publishing/spec.md @@ -512,7 +512,9 @@ SHALL 支持上传一个 ZIP;浏览器支持安全目录选择时,也可以 确认页面 SHALL 展示将创建的 Skill、将创建的 SkillVersion、复用版本、纯引用和移除成员数量, 每个携带包成员的最终可见性、发布路径和 warning,并说明成员就绪后只生成 Suite 草稿。warning 必须逐成员明确确认。确认后,进度页 SHALL 展示每个成员的创建、扫描、审核、复用、引用、失败或 -阻塞状态,并能通过操作 ID 在刷新或重新登录后恢复。 +阻塞状态,并能通过操作 ID 在刷新或重新登录后恢复。“我的套件” SHALL 展示当前用户发起的非终态 +Bundle 操作,使尚未生成 Suite 草稿的发布过程仍有稳定入口;公开套件专区 SHALL 继续只展示已发布 +Suite,不得把执行操作伪装成已经创建的 Suite。 #### Scenario: 用户确认混合计划 - **WHEN** 预览同时包含创建 Skill、创建版本、复用、引用和移除 @@ -524,6 +526,12 @@ SHALL 支持上传一个 ZIP;浏览器支持安全目录选择时,也可以 - **THEN** 进度页展示 `WAITING_FOR_MEMBERS` 和成员审核入口 - **AND** 不把操作展示为 Suite 已更新 +#### Scenario: 从我的套件继续查看发布 +- **WHEN** 当前用户发起的 Bundle 操作仍为 `RUNNING`、`WAITING_FOR_MEMBERS` 或 `BLOCKED_RETRYABLE` +- **THEN** “我的套件”展示目标坐标、目标版本、整体状态和成员完成数量 +- **AND** 用户可以回到该操作的进度页继续查看或处理 +- **AND** 公开套件专区不展示该未完成操作 + #### Scenario: 操作创建 Suite 草稿 - **WHEN** 操作达到 `SUITE_DRAFT_CREATED` - **THEN** 页面提供新 Suite 草稿入口及后续提交审核说明 diff --git a/openspec/changes/add-suite-bundle-publishing/tasks.md b/openspec/changes/add-suite-bundle-publishing/tasks.md index 611700639..21604f999 100644 --- a/openspec/changes/add-suite-bundle-publishing/tasks.md +++ b/openspec/changes/add-suite-bundle-publishing/tasks.md @@ -21,7 +21,7 @@ - [x] 3.3 `[REQ-SBP-12, REQ-SBP-13]` 记录包和引用结果,并按规范状态矩阵通过领域事件与有界恢复任务完成协调;覆盖 PRIVATE `UPLOADED`、`SCANNING`、`SCAN_FAILED`、`PENDING_REVIEW`、`REJECTED`、外部撤回/删除/下架、`BLOCKED_RETRYABLE` 与 `REPREVIEW_REQUIRED`,验证占用随终态原子释放,重复、延迟、丢失和乱序时按原 ID 收敛或明确要求重新预览。 - [x] 3.4 `[REQ-SBP-12]` 仅在包发布成功、引用最终有效且最终权限/状态检查通过时,原子创建新 Suite 及首个 DRAFT,或为已有 Suite 创建一个 SuiteVersion DRAFT;验证权限撤销、Namespace 冻结、待审核、被拒绝、失败包和失效引用不会产生空 Suite 或部分草稿。 - [x] 3.5 `[REQ-SBP-13, REQ-SBP-15]` 实现带当前授权和响应脱敏的状态读取、原 ID 重试、非破坏性取消、终态占用释放、PreviewSession/暂存对象过期和限定范围补偿清理;验证等待审核的 ExecutionOperation 不随预览过期,已有 SkillVersion 和引用保持不变,清理失败仍有可操作记录。 -- [x] 3.6 `[REQ-SBP-17, REQ-SBP-18]` 在“创建 Suite”和“创建新版本”入口提供手工组合/本地导入选择,并实现准确列出副作用、最终可见性、发布路径和逐成员 warning 确认的确认页及可恢复进度页;展示包/引用状态、Skill 审核链接、阻塞原因、重试/取消和生成的 Suite 草稿,通过正常、等待、可重试阻塞、必须重预览、取消、权限变化、刷新和重新登录用例验证。 +- [x] 3.6 `[REQ-SBP-17, REQ-SBP-18]` 在“创建 Suite”和“创建新版本”入口提供手工组合/本地导入选择,并实现准确列出副作用、最终可见性、发布路径和逐成员 warning 确认的确认页及可恢复进度页;展示包/引用状态、Skill 审核链接、阻塞原因、重试/取消和生成的 Suite 草稿;“我的套件”同时展示当前用户发起的非终态操作并提供继续查看入口。通过正常、等待、可重试阻塞、必须重预览、取消、权限变化、刷新、重新登录和离开导入页后恢复用例验证。 ## 4. 任意成员的所属 Suite diff --git a/server/skillhub-app/src/main/java/com/iflytek/skillhub/controller/portal/SkillSuiteBundleController.java b/server/skillhub-app/src/main/java/com/iflytek/skillhub/controller/portal/SkillSuiteBundleController.java index e7b6553ac..b0c7dc151 100644 --- a/server/skillhub-app/src/main/java/com/iflytek/skillhub/controller/portal/SkillSuiteBundleController.java +++ b/server/skillhub-app/src/main/java/com/iflytek/skillhub/controller/portal/SkillSuiteBundleController.java @@ -8,6 +8,7 @@ import com.iflytek.skillhub.dto.ApiResponseFactory; import com.iflytek.skillhub.dto.SkillSuiteBundleConfirmRequest; import com.iflytek.skillhub.dto.SkillSuiteBundleOperationResponse; import com.iflytek.skillhub.dto.SkillSuiteBundleOperationDetailResponse; +import com.iflytek.skillhub.dto.SkillSuiteBundleOperationSummaryResponse; import com.iflytek.skillhub.dto.SkillSuiteBundlePreviewResponse; import com.iflytek.skillhub.ratelimit.RateLimit; import com.iflytek.skillhub.service.bundle.SkillSuiteBundleConfirmationAppService; @@ -32,6 +33,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.util.List; import java.util.Map; import java.util.Set; @@ -108,6 +110,14 @@ public class SkillSuiteBundleController extends BaseApiController { operationId, userId, roles == null ? Map.of() : roles, platformRoles(principal))); } + @GetMapping("/operations/active") + @Operation(operationId = "listActiveSkillSuiteBundleOperations", summary = "List active Bundle operations started by the current user") + public ApiResponse> listActiveOperations( + @RequestAttribute("userId") String userId + ) { + return ok("response.success.read", operationQueryService.listActive(userId)); + } + @PostMapping("/operations/{operationId}/cancel") @Operation(operationId = "cancelSkillSuiteBundleOperation", summary = "Cancel one active Suite Bundle operation") public ApiResponse cancelOperation( diff --git a/server/skillhub-app/src/main/java/com/iflytek/skillhub/dto/SkillSuiteBundleOperationSummaryResponse.java b/server/skillhub-app/src/main/java/com/iflytek/skillhub/dto/SkillSuiteBundleOperationSummaryResponse.java new file mode 100644 index 000000000..454099cc1 --- /dev/null +++ b/server/skillhub-app/src/main/java/com/iflytek/skillhub/dto/SkillSuiteBundleOperationSummaryResponse.java @@ -0,0 +1,21 @@ +package com.iflytek.skillhub.dto; + +import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMode; +import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleOperationStatus; + +import java.time.Instant; + +/** Active Bundle operation shown before its Suite draft exists. */ +public record SkillSuiteBundleOperationSummaryResponse( + String operationId, + SkillSuiteBundleMode mode, + String targetCoordinate, + String targetVersion, + SkillSuiteBundleOperationStatus status, + String failureCode, + int totalMembers, + int completedMembers, + int waitingMembers, + Instant updatedAt +) { +} diff --git a/server/skillhub-app/src/main/java/com/iflytek/skillhub/service/bundle/SkillSuiteBundleOperationQueryService.java b/server/skillhub-app/src/main/java/com/iflytek/skillhub/service/bundle/SkillSuiteBundleOperationQueryService.java index 8451c0f25..6a1e0fc51 100644 --- a/server/skillhub-app/src/main/java/com/iflytek/skillhub/service/bundle/SkillSuiteBundleOperationQueryService.java +++ b/server/skillhub-app/src/main/java/com/iflytek/skillhub/service/bundle/SkillSuiteBundleOperationQueryService.java @@ -11,11 +11,17 @@ import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleExecutionOperati import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleExecutionOperationRepository; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMemberResult; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMemberResultRepository; +import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMemberResultStatus; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleOperationAuthorizationPolicy; +import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleOperationStatus; import com.iflytek.skillhub.dto.SkillSuiteBundleOperationDetailResponse; +import com.iflytek.skillhub.dto.SkillSuiteBundleOperationSummaryResponse; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -27,6 +33,11 @@ import java.util.stream.Collectors; @Service public class SkillSuiteBundleOperationQueryService { + private static final Set ACTIVE_STATUSES = EnumSet.of( + SkillSuiteBundleOperationStatus.RUNNING, + SkillSuiteBundleOperationStatus.WAITING_FOR_MEMBERS, + SkillSuiteBundleOperationStatus.BLOCKED_RETRYABLE); + private final SkillSuiteBundleExecutionOperationRepository operationRepository; private final SkillSuiteBundleMemberResultRepository memberRepository; private final NamespaceRepository namespaceRepository; @@ -97,6 +108,54 @@ public class SkillSuiteBundleOperationQueryService { operation.getCreatedAt(), operation.getUpdatedAt(), operation.getCompletedAt(), members); } + /** Returns the caller's active operations in bounded batches without exposing member metadata. */ + @Transactional(readOnly = true) + public List listActive(String actorId) { + var operations = operationRepository + .findTop50ByActorIdAndStatusInOrderByUpdatedAtDesc(actorId, ACTIVE_STATUSES); + if (operations.isEmpty()) { + return List.of(); + } + var namespaceIds = operations.stream() + .map(SkillSuiteBundleExecutionOperation::getNamespaceId) + .distinct() + .toList(); + Map namespaceSlugs = namespaceRepository.findByIdIn(namespaceIds).stream() + .collect(Collectors.toMap(namespace -> namespace.getId(), namespace -> namespace.getSlug())); + var operationIds = operations.stream() + .map(SkillSuiteBundleExecutionOperation::getOperationId) + .toList(); + Map> membersByOperation = new HashMap<>(); + memberRepository.findByOperationIdInOrderByOperationIdAscPositionAsc(operationIds) + .forEach(member -> membersByOperation + .computeIfAbsent(member.getOperationId(), ignored -> new ArrayList<>()) + .add(member)); + return operations.stream() + .filter(operation -> namespaceSlugs.containsKey(operation.getNamespaceId())) + .map(operation -> summary( + operation, namespaceSlugs.get(operation.getNamespaceId()), + membersByOperation.getOrDefault(operation.getOperationId(), List.of()))) + .toList(); + } + + private SkillSuiteBundleOperationSummaryResponse summary( + SkillSuiteBundleExecutionOperation operation, + String namespaceSlug, + List members + ) { + int completed = (int) members.stream() + .filter(member -> member.getStatus() == SkillSuiteBundleMemberResultStatus.COMPLETED) + .count(); + int waiting = (int) members.stream() + .filter(member -> member.getStatus() == SkillSuiteBundleMemberResultStatus.WAITING_FOR_MEMBER) + .count(); + return new SkillSuiteBundleOperationSummaryResponse( + operation.getOperationId(), operation.getMode(), + "@" + namespaceSlug + "/" + operation.getTargetSuiteSlug(), + operation.getTargetVersion(), operation.getStatus(), operation.getFailureCode(), + members.size(), completed, waiting, operation.getUpdatedAt()); + } + private boolean canReadMember( Skill skill, Long namespaceId, diff --git a/server/skillhub-app/src/test/java/com/iflytek/skillhub/controller/portal/SkillSuiteBundleControllerTest.java b/server/skillhub-app/src/test/java/com/iflytek/skillhub/controller/portal/SkillSuiteBundleControllerTest.java index 17b8bcf4d..13bf3f1a6 100644 --- a/server/skillhub-app/src/test/java/com/iflytek/skillhub/controller/portal/SkillSuiteBundleControllerTest.java +++ b/server/skillhub-app/src/test/java/com/iflytek/skillhub/controller/portal/SkillSuiteBundleControllerTest.java @@ -6,6 +6,7 @@ import com.iflytek.skillhub.auth.rbac.PlatformPrincipal; import com.iflytek.skillhub.domain.namespace.NamespaceMemberRepository; import com.iflytek.skillhub.dto.SkillSuiteBundleOperationResponse; import com.iflytek.skillhub.dto.SkillSuiteBundleOperationDetailResponse; +import com.iflytek.skillhub.dto.SkillSuiteBundleOperationSummaryResponse; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMode; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleOperationStatus; import com.iflytek.skillhub.dto.SkillSuiteBundlePreviewResponse; @@ -162,6 +163,22 @@ class SkillSuiteBundleControllerTest { .andExpect(jsonPath("$.data.plan").doesNotExist()); } + @Test + void authenticatedCallerCanListTheirActiveOperations() throws Exception { + when(operationQueryService.listActive("actor")).thenReturn(List.of( + new SkillSuiteBundleOperationSummaryResponse( + "operation-1", SkillSuiteBundleMode.CREATE, "@global/suite", "1.0.0", + SkillSuiteBundleOperationStatus.WAITING_FOR_MEMBERS, null, + 2, 1, 1, Instant.parse("2026-09-11T08:00:00Z")))); + + mockMvc.perform(get("/api/v1/suite-bundles/operations/active") + .with(authentication(authToken("actor")))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.data[0].operationId").value("operation-1")) + .andExpect(jsonPath("$.data[0].targetCoordinate").value("@global/suite")) + .andExpect(jsonPath("$.data[0].completedMembers").value(1)); + } + @Test void authenticatedCallerCanCancelAndRetryAnOperation() throws Exception { when(operationCommandService.cancel("operation-1", "actor", Map.of(), Set.of())) diff --git a/server/skillhub-app/src/test/java/com/iflytek/skillhub/service/bundle/SkillSuiteBundleOperationQueryServiceTest.java b/server/skillhub-app/src/test/java/com/iflytek/skillhub/service/bundle/SkillSuiteBundleOperationQueryServiceTest.java index c4ab0f848..82cd0e161 100644 --- a/server/skillhub-app/src/test/java/com/iflytek/skillhub/service/bundle/SkillSuiteBundleOperationQueryServiceTest.java +++ b/server/skillhub-app/src/test/java/com/iflytek/skillhub/service/bundle/SkillSuiteBundleOperationQueryServiceTest.java @@ -15,6 +15,8 @@ import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMemberResult; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMemberResultRepository; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMemberSourceType; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMode; +import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleMemberResultStatus; +import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleOperationStatus; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundlePublishAction; import com.iflytek.skillhub.domain.suite.bundle.SkillSuiteBundleRelationshipChange; import org.junit.jupiter.api.BeforeEach; @@ -29,6 +31,7 @@ import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -133,6 +136,42 @@ class SkillSuiteBundleOperationQueryServiceTest { }); } + @Test + void listsOnlyTheActorsActiveOperationsWithBatchedMemberCounts() { + SkillSuiteBundleExecutionOperation operation = operation(); + operation.markWaitingForMembers(NOW.plusSeconds(1)); + Namespace namespace = mock(Namespace.class); + when(namespace.getId()).thenReturn(1L); + when(namespace.getSlug()).thenReturn("global"); + SkillSuiteBundleMemberResult completed = mock(SkillSuiteBundleMemberResult.class); + when(completed.getOperationId()).thenReturn("operation-1"); + when(completed.getStatus()).thenReturn(SkillSuiteBundleMemberResultStatus.COMPLETED); + SkillSuiteBundleMemberResult waiting = mock(SkillSuiteBundleMemberResult.class); + when(waiting.getOperationId()).thenReturn("operation-1"); + when(waiting.getStatus()).thenReturn(SkillSuiteBundleMemberResultStatus.WAITING_FOR_MEMBER); + when(operationRepository.findTop50ByActorIdAndStatusInOrderByUpdatedAtDesc( + eq("actor"), eq(Set.of( + SkillSuiteBundleOperationStatus.RUNNING, + SkillSuiteBundleOperationStatus.WAITING_FOR_MEMBERS, + SkillSuiteBundleOperationStatus.BLOCKED_RETRYABLE)))) + .thenReturn(List.of(operation)); + when(namespaceRepository.findByIdIn(List.of(1L))).thenReturn(List.of(namespace)); + when(memberRepository.findByOperationIdInOrderByOperationIdAscPositionAsc(List.of("operation-1"))) + .thenReturn(List.of(completed, waiting)); + + var result = service.listActive("actor"); + + assertThat(result).singleElement().satisfies(summary -> { + assertThat(summary.operationId()).isEqualTo("operation-1"); + assertThat(summary.targetCoordinate()).isEqualTo("@global/suite"); + assertThat(summary.status()).isEqualTo(SkillSuiteBundleOperationStatus.WAITING_FOR_MEMBERS); + assertThat(summary.totalMembers()).isEqualTo(2); + assertThat(summary.completedMembers()).isEqualTo(1); + assertThat(summary.waitingMembers()).isEqualTo(1); + }); + verify(memberRepository).findByOperationIdInOrderByOperationIdAscPositionAsc(List.of("operation-1")); + } + private SkillSuiteBundleExecutionOperation operation() { return new SkillSuiteBundleExecutionOperation( "operation-1", "preview-1", "request-1", "actor", SkillSuiteBundleMode.CREATE, diff --git a/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/suite/bundle/SkillSuiteBundleExecutionOperationRepository.java b/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/suite/bundle/SkillSuiteBundleExecutionOperationRepository.java index 51be229d7..b66bd5689 100644 --- a/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/suite/bundle/SkillSuiteBundleExecutionOperationRepository.java +++ b/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/suite/bundle/SkillSuiteBundleExecutionOperationRepository.java @@ -12,6 +12,8 @@ public interface SkillSuiteBundleExecutionOperationRepository { Optional findByActorIdAndClientRequestId( String actorId, String clientRequestId); Optional findByPreviewToken(String previewToken); + List findTop50ByActorIdAndStatusInOrderByUpdatedAtDesc( + String actorId, Collection statuses); List findTop100ByStatusInOrderByUpdatedAtAsc( Collection statuses); List diff --git a/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/suite/bundle/SkillSuiteBundleMemberResultRepository.java b/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/suite/bundle/SkillSuiteBundleMemberResultRepository.java index d0d756832..9a8860204 100644 --- a/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/suite/bundle/SkillSuiteBundleMemberResultRepository.java +++ b/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/suite/bundle/SkillSuiteBundleMemberResultRepository.java @@ -1,11 +1,14 @@ package com.iflytek.skillhub.domain.suite.bundle; +import java.util.Collection; import java.util.List; public interface SkillSuiteBundleMemberResultRepository { List saveAll(List members); void flush(); List findByOperationIdOrderByPosition(String operationId); + List findByOperationIdInOrderByOperationIdAscPositionAsc( + Collection operationIds); List findByOperationIdOrderByPositionForUpdate(String operationId); List findBySkillVersionId(Long skillVersionId); } diff --git a/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/SkillSuiteBundleMemberResultJpaRepository.java b/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/SkillSuiteBundleMemberResultJpaRepository.java index 579d57cb0..33ee1b888 100644 --- a/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/SkillSuiteBundleMemberResultJpaRepository.java +++ b/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/SkillSuiteBundleMemberResultJpaRepository.java @@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.Collection; import java.util.List; @Repository @@ -29,4 +30,13 @@ public interface SkillSuiteBundleMemberResultJpaRepository """) List findByOperationIdOrderByPositionForUpdate( @Param("operationId") String operationId); + + @Override + @Query(""" + SELECT member FROM SkillSuiteBundleMemberResult member + WHERE member.operationId IN :operationIds + ORDER BY member.operationId, member.position + """) + List findByOperationIdInOrderByOperationIdAscPositionAsc( + @Param("operationIds") Collection operationIds); } diff --git a/web/src/api/generated/schema.d.ts b/web/src/api/generated/schema.d.ts index 779acf2e4..56ac3b7da 100644 --- a/web/src/api/generated/schema.d.ts +++ b/web/src/api/generated/schema.d.ts @@ -2742,6 +2742,40 @@ export interface paths { patch?: never; trace?: never; }; + "/api/web/suite-bundles/operations/active": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** List active Bundle operations started by the current user */ + get: operations["listActiveSkillSuiteBundleOperations"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/api/v1/suite-bundles/operations/active": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** List active Bundle operations started by the current user */ + get: operations["listActiveSkillSuiteBundleOperations_1"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; "/api/web/skills": { parameters: { query?: never; @@ -5826,6 +5860,33 @@ export interface components { completedAt?: string; members?: components["schemas"]["OperationMember"][]; }; + ApiResponseListSkillSuiteBundleOperationSummaryResponse: { + /** Format: int32 */ + code?: number; + msg?: string; + data?: components["schemas"]["SkillSuiteBundleOperationSummaryResponse"][]; + /** Format: date-time */ + timestamp?: string; + requestId?: string; + }; + SkillSuiteBundleOperationSummaryResponse: { + operationId?: string; + /** @enum {string} */ + mode?: "CREATE" | "UPDATE"; + targetCoordinate?: string; + targetVersion?: string; + /** @enum {string} */ + status?: "RUNNING" | "WAITING_FOR_MEMBERS" | "BLOCKED_RETRYABLE" | "REPREVIEW_REQUIRED" | "SUITE_DRAFT_CREATED" | "CANCELLED"; + failureCode?: string; + /** Format: int32 */ + totalMembers?: number; + /** Format: int32 */ + completedMembers?: number; + /** Format: int32 */ + waitingMembers?: number; + /** Format: date-time */ + updatedAt?: string; + }; ApiResponseSearchResponse: { /** Format: int32 */ code?: number; @@ -12226,6 +12287,46 @@ export interface operations { }; }; }; + listActiveSkillSuiteBundleOperations: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "*/*": components["schemas"]["ApiResponseListSkillSuiteBundleOperationSummaryResponse"]; + }; + }; + }; + }; + listActiveSkillSuiteBundleOperations_1: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "*/*": components["schemas"]["ApiResponseListSkillSuiteBundleOperationSummaryResponse"]; + }; + }; + }; + }; search: { parameters: { query?: { diff --git a/web/src/api/types.ts b/web/src/api/types.ts index b5d44fe40..13e685f6d 100644 --- a/web/src/api/types.ts +++ b/web/src/api/types.ts @@ -473,6 +473,10 @@ export type SkillSuiteBundlePreviewMember = components['schemas']['PreviewMember export type SkillSuiteBundleRemovedMember = components['schemas']['RemovedMember'] export type SkillSuiteBundleOperation = components['schemas']['SkillSuiteBundleOperationDetailResponse'] export type SkillSuiteBundleOperationResult = components['schemas']['SkillSuiteBundleOperationResponse'] +export type SkillSuiteBundleOperationSummary = RequiredGenerated< + components['schemas']['SkillSuiteBundleOperationSummaryResponse'], + 'failureCode' +> // Publish export interface PublishResult { diff --git a/web/src/features/suite/suite-bundle-import.tsx b/web/src/features/suite/suite-bundle-import.tsx index 2e8dfb4cc..d06011bc7 100644 --- a/web/src/features/suite/suite-bundle-import.tsx +++ b/web/src/features/suite/suite-bundle-import.tsx @@ -44,6 +44,14 @@ export function hasStoredSuiteBundleOperation(mode: BundleMode, coordinate?: str return Boolean(readStoredOperation(operationStorageKey(mode, coordinate))) } +export function rememberSuiteBundleOperation( + mode: BundleMode, + coordinate: string, + operationId: string, +): void { + writeStoredOperation(operationStorageKey(mode, mode === 'UPDATE' ? coordinate : undefined), operationId) +} + function splitCoordinate(coordinate?: string): { namespace: string; slug: string } | null { const match = coordinate?.match(/^@([^/]+)\/(.+)$/) return match ? { namespace: match[1], slug: match[2] } : null diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json index 4e6cccca1..31a5bcff5 100644 --- a/web/src/i18n/locales/en.json +++ b/web/src/i18n/locales/en.json @@ -2019,6 +2019,10 @@ "confirm": "Confirm and start publishing", "chooseAgain": "Choose again", "progressTitle": "Bundle publishing progress", + "activeTitle": "Suites being published", + "activeDescription": "These Bundles are waiting for member Skills before their Suite drafts can be created.", + "memberProgress": "{{completed}} of {{total}} members completed; {{waiting}} waiting for scan or review", + "continueOperation": "View publishing progress", "loadingOperation": "Loading operation status", "operationLoadFailed": "Unable to load the Bundle operation. Check your connection and try again.", "operationTargetMismatch": "The restored Bundle operation does not match this Suite. Its recovery entry was cleared.", diff --git a/web/src/i18n/locales/ru.json b/web/src/i18n/locales/ru.json index 7054dfeb9..143e736d9 100644 --- a/web/src/i18n/locales/ru.json +++ b/web/src/i18n/locales/ru.json @@ -2016,6 +2016,10 @@ "confirm": "Подтвердить и начать публикацию", "chooseAgain": "Выбрать снова", "progressTitle": "Ход публикации Bundle", + "activeTitle": "Публикуемые наборы", + "activeDescription": "Эти Bundle ожидают публикации навыков-участников до создания черновика набора.", + "memberProgress": "Завершено {{completed}} из {{total}} участников; {{waiting}} ожидают проверки", + "continueOperation": "Посмотреть ход публикации", "loadingOperation": "Загрузка состояния операции", "operationLoadFailed": "Не удалось загрузить операцию Bundle. Проверьте подключение и повторите попытку.", "operationTargetMismatch": "Восстановленная операция Bundle не соответствует этому набору. Запись восстановления удалена.", diff --git a/web/src/i18n/locales/zh.json b/web/src/i18n/locales/zh.json index 7acd88761..e1df0cad9 100644 --- a/web/src/i18n/locales/zh.json +++ b/web/src/i18n/locales/zh.json @@ -2018,6 +2018,10 @@ "confirm": "确认并开始发布", "chooseAgain": "重新选择", "progressTitle": "Bundle 发布进度", + "activeTitle": "发布中的套件", + "activeDescription": "这些 Bundle 正在等待成员技能发布完成,完成后才会生成套件草稿。", + "memberProgress": "已完成 {{completed}} / {{total}} 个成员,其中 {{waiting}} 个等待扫描或审核", + "continueOperation": "查看发布进度", "loadingOperation": "正在读取操作状态", "operationLoadFailed": "无法读取 Bundle 操作状态,请检查网络后重试。", "operationTargetMismatch": "恢复的 Bundle 操作与当前套件不匹配,已清除该恢复记录。", diff --git a/web/src/pages/dashboard/my-suites.test.tsx b/web/src/pages/dashboard/my-suites.test.tsx new file mode 100644 index 000000000..aaab42f8b --- /dev/null +++ b/web/src/pages/dashboard/my-suites.test.tsx @@ -0,0 +1,53 @@ +/** @vitest-environment jsdom */ + +import { cleanup, fireEvent, render, screen } from '@testing-library/react' +import { afterEach, describe, expect, it, vi } from 'vitest' +import type { SkillSuiteBundleOperationSummary } from '@/api/types' +import { MySuitesPage } from './my-suites' + +const mocks = vi.hoisted(() => ({ + navigate: vi.fn(), + remember: vi.fn(), + active: [] as SkillSuiteBundleOperationSummary[], +})) + +vi.mock('@tanstack/react-router', () => ({ useNavigate: () => mocks.navigate })) +vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) })) +vi.mock('@/features/suite/suite-bundle-import', () => ({ + rememberSuiteBundleOperation: mocks.remember, +})) +vi.mock('@/shared/hooks/use-suite-queries', () => ({ + useMySuites: () => ({ data: { items: [], total: 0, page: 0, size: 12 }, isLoading: false }), + useActiveSuiteBundleOperations: () => ({ data: mocks.active, isLoading: false }), +})) + +describe('MySuitesPage', () => { + afterEach(() => { + cleanup() + vi.clearAllMocks() + mocks.active = [] + }) + + it('shows an active Bundle before its Suite draft exists and restores its progress', () => { + mocks.active = [{ + operationId: 'operation-1', + mode: 'CREATE', + targetCoordinate: '@global/waiting-suite', + targetVersion: '1.0.0', + status: 'WAITING_FOR_MEMBERS', + failureCode: undefined, + totalMembers: 2, + completedMembers: 1, + waitingMembers: 1, + updatedAt: '2026-09-14T04:00:00Z', + }] + + render() + + expect(screen.getByText('@global/waiting-suite@1.0.0')).not.toBeNull() + expect(screen.getByText('suite.bundle.status.WAITING_FOR_MEMBERS')).not.toBeNull() + fireEvent.click(screen.getByRole('button', { name: 'suite.bundle.continueOperation' })) + expect(mocks.remember).toHaveBeenCalledWith('CREATE', '@global/waiting-suite', 'operation-1') + expect(mocks.navigate).toHaveBeenCalledWith({ to: '/dashboard/suites/new' }) + }) +}) diff --git a/web/src/pages/dashboard/my-suites.tsx b/web/src/pages/dashboard/my-suites.tsx index 9eda4d6db..355993561 100644 --- a/web/src/pages/dashboard/my-suites.tsx +++ b/web/src/pages/dashboard/my-suites.tsx @@ -1,8 +1,8 @@ import { useState } from 'react' import { useNavigate } from '@tanstack/react-router' import { useTranslation } from 'react-i18next' -import { Boxes } from 'lucide-react' -import { useMySuites } from '@/shared/hooks/use-suite-queries' +import { AlertTriangle, Boxes, Loader2 } from 'lucide-react' +import { useActiveSuiteBundleOperations, useMySuites } from '@/shared/hooks/use-suite-queries' import { DashboardPageHeader } from '@/shared/components/dashboard-page-header' import { EmptyState } from '@/shared/components/empty-state' import { Pagination } from '@/shared/components/pagination' @@ -10,6 +10,7 @@ import { Button } from '@/shared/ui/button' import { Card } from '@/shared/ui/card' import { Input } from '@/shared/ui/input' import { suiteStatusLabel } from '@/features/suite/suite-labels' +import { rememberSuiteBundleOperation } from '@/features/suite/suite-bundle-import' const PAGE_SIZE = 12 @@ -19,6 +20,20 @@ export function MySuitesPage() { const [query, setQuery] = useState('') const [page, setPage] = useState(0) const { data, isLoading } = useMySuites(query.trim(), page, PAGE_SIZE) + const { data: activeOperations, isLoading: isLoadingOperations } = useActiveSuiteBundleOperations() + + const continueOperation = (operation: NonNullable[number]) => { + rememberSuiteBundleOperation(operation.mode, operation.targetCoordinate, operation.operationId) + const coordinate = operation.targetCoordinate.match(/^@([^/]+)\/(.+)$/) + if (operation.mode === 'UPDATE' && coordinate) { + navigate({ + to: `/dashboard/suites/${coordinate[1]}/${encodeURIComponent(coordinate[2])}/new-version`, + search: { sourceVersion: undefined }, + }) + return + } + navigate({ to: '/dashboard/suites/new' }) + } return (
@@ -36,6 +51,51 @@ export function MySuitesPage() { setPage(0) }} /> + {isLoadingOperations ? ( +
+ ) : activeOperations?.length ? ( +
+
+

+ {t('suite.bundle.activeTitle')} +

+

{t('suite.bundle.activeDescription')}

+
+
+ {activeOperations.map(operation => ( + +
+
+

+ {operation.targetCoordinate}@{operation.targetVersion} +

+

+ {t(`suite.bundle.status.${operation.status}`)} +

+
+ {operation.status === 'BLOCKED_RETRYABLE' ? ( +
+

+ {t('suite.bundle.memberProgress', { + completed: operation.completedMembers, + total: operation.totalMembers, + waiting: operation.waitingMembers, + })} +

+
+ +
+
+ ))} +
+
+ ) : null} {isLoading ? (
) : data?.items.length ? ( diff --git a/web/src/shared/hooks/use-suite-queries.ts b/web/src/shared/hooks/use-suite-queries.ts index cf6abb6ef..f1afb4f97 100644 --- a/web/src/shared/hooks/use-suite-queries.ts +++ b/web/src/shared/hooks/use-suite-queries.ts @@ -11,6 +11,7 @@ import type { SkillSuiteBundlePreview, SkillSuiteBundleOperation, SkillSuiteBundleOperationResult, + SkillSuiteBundleOperationSummary, } from '@/api/types' import { fetchJson, getCsrfHeaders, suiteApi, WEB_API_PREFIX } from '@/api/client' @@ -166,6 +167,16 @@ export function useSuiteBundleOperation(operationId?: string) { }) } +export function useActiveSuiteBundleOperations() { + return useQuery({ + queryKey: ['suite-bundles', 'operations', 'active'], + queryFn: () => fetchJson( + `${WEB_API_PREFIX}/suite-bundles/operations/active`, + ), + refetchInterval: (query) => query.state.data?.length ? 2_000 : false, + }) +} + function useSuiteBundleCommand(command: 'cancel' | 'retry') { const queryClient = useQueryClient() return useMutation({