feat(suite): surface active bundle publishing

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
XiaoSeS 2026-09-14 14:10:03 +08:00
parent eec7d14cfa
commit eeee322248
19 changed files with 422 additions and 4 deletions

View file

@ -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 草稿入口及后续提交审核说明

View file

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

View file

@ -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<List<SkillSuiteBundleOperationSummaryResponse>> 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<SkillSuiteBundleOperationResponse> cancelOperation(

View file

@ -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
) {
}

View file

@ -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<SkillSuiteBundleOperationStatus> 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<SkillSuiteBundleOperationSummaryResponse> 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<Long, String> namespaceSlugs = namespaceRepository.findByIdIn(namespaceIds).stream()
.collect(Collectors.toMap(namespace -> namespace.getId(), namespace -> namespace.getSlug()));
var operationIds = operations.stream()
.map(SkillSuiteBundleExecutionOperation::getOperationId)
.toList();
Map<String, List<SkillSuiteBundleMemberResult>> 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<SkillSuiteBundleMemberResult> 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,

View file

@ -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()))

View file

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

View file

@ -12,6 +12,8 @@ public interface SkillSuiteBundleExecutionOperationRepository {
Optional<SkillSuiteBundleExecutionOperation> findByActorIdAndClientRequestId(
String actorId, String clientRequestId);
Optional<SkillSuiteBundleExecutionOperation> findByPreviewToken(String previewToken);
List<SkillSuiteBundleExecutionOperation> findTop50ByActorIdAndStatusInOrderByUpdatedAtDesc(
String actorId, Collection<SkillSuiteBundleOperationStatus> statuses);
List<SkillSuiteBundleExecutionOperation> findTop100ByStatusInOrderByUpdatedAtAsc(
Collection<SkillSuiteBundleOperationStatus> statuses);
List<SkillSuiteBundleExecutionOperation>

View file

@ -1,11 +1,14 @@
package com.iflytek.skillhub.domain.suite.bundle;
import java.util.Collection;
import java.util.List;
public interface SkillSuiteBundleMemberResultRepository {
List<SkillSuiteBundleMemberResult> saveAll(List<SkillSuiteBundleMemberResult> members);
void flush();
List<SkillSuiteBundleMemberResult> findByOperationIdOrderByPosition(String operationId);
List<SkillSuiteBundleMemberResult> findByOperationIdInOrderByOperationIdAscPositionAsc(
Collection<String> operationIds);
List<SkillSuiteBundleMemberResult> findByOperationIdOrderByPositionForUpdate(String operationId);
List<SkillSuiteBundleMemberResult> findBySkillVersionId(Long skillVersionId);
}

View file

@ -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<SkillSuiteBundleMemberResult> findByOperationIdOrderByPositionForUpdate(
@Param("operationId") String operationId);
@Override
@Query("""
SELECT member FROM SkillSuiteBundleMemberResult member
WHERE member.operationId IN :operationIds
ORDER BY member.operationId, member.position
""")
List<SkillSuiteBundleMemberResult> findByOperationIdInOrderByOperationIdAscPositionAsc(
@Param("operationIds") Collection<String> operationIds);
}

View file

@ -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?: {

View file

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

View file

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

View file

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

View file

@ -2016,6 +2016,10 @@
"confirm": "Подтвердить и начать публикацию",
"chooseAgain": "Выбрать снова",
"progressTitle": "Ход публикации Bundle",
"activeTitle": "Публикуемые наборы",
"activeDescription": "Эти Bundle ожидают публикации навыков-участников до создания черновика набора.",
"memberProgress": "Завершено {{completed}} из {{total}} участников; {{waiting}} ожидают проверки",
"continueOperation": "Посмотреть ход публикации",
"loadingOperation": "Загрузка состояния операции",
"operationLoadFailed": "Не удалось загрузить операцию Bundle. Проверьте подключение и повторите попытку.",
"operationTargetMismatch": "Восстановленная операция Bundle не соответствует этому набору. Запись восстановления удалена.",

View file

@ -2018,6 +2018,10 @@
"confirm": "确认并开始发布",
"chooseAgain": "重新选择",
"progressTitle": "Bundle 发布进度",
"activeTitle": "发布中的套件",
"activeDescription": "这些 Bundle 正在等待成员技能发布完成,完成后才会生成套件草稿。",
"memberProgress": "已完成 {{completed}} / {{total}} 个成员,其中 {{waiting}} 个等待扫描或审核",
"continueOperation": "查看发布进度",
"loadingOperation": "正在读取操作状态",
"operationLoadFailed": "无法读取 Bundle 操作状态,请检查网络后重试。",
"operationTargetMismatch": "恢复的 Bundle 操作与当前套件不匹配,已清除该恢复记录。",

View file

@ -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(<MySuitesPage />)
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' })
})
})

View file

@ -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<typeof activeOperations>[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 (
<div className="space-y-8 animate-fade-up">
@ -36,6 +51,51 @@ export function MySuitesPage() {
setPage(0)
}}
/>
{isLoadingOperations ? (
<div className="h-28 animate-shimmer rounded-xl" />
) : activeOperations?.length ? (
<section className="space-y-3" aria-labelledby="active-suite-operations-title">
<div>
<h2 id="active-suite-operations-title" className="text-lg font-semibold">
{t('suite.bundle.activeTitle')}
</h2>
<p className="text-sm text-muted-foreground">{t('suite.bundle.activeDescription')}</p>
</div>
<div className="grid gap-4 md:grid-cols-2">
{activeOperations.map(operation => (
<Card key={operation.operationId} className="p-5">
<div className="flex items-start justify-between gap-4">
<div className="min-w-0">
<p className="truncate font-mono text-sm font-semibold">
{operation.targetCoordinate}@{operation.targetVersion}
</p>
<p className="mt-2 text-sm text-muted-foreground">
{t(`suite.bundle.status.${operation.status}`)}
</p>
</div>
{operation.status === 'BLOCKED_RETRYABLE' ? (
<AlertTriangle className="h-5 w-5 shrink-0 text-amber-600" aria-hidden="true" />
) : (
<Loader2 className="h-5 w-5 shrink-0 animate-spin text-primary" aria-hidden="true" />
)}
</div>
<p className="mt-3 text-xs text-muted-foreground">
{t('suite.bundle.memberProgress', {
completed: operation.completedMembers,
total: operation.totalMembers,
waiting: operation.waitingMembers,
})}
</p>
<div className="mt-4">
<Button variant="outline" size="sm" onClick={() => continueOperation(operation)}>
{t('suite.bundle.continueOperation')}
</Button>
</div>
</Card>
))}
</div>
</section>
) : null}
{isLoading ? (
<div className="h-40 animate-shimmer rounded-xl" />
) : data?.items.length ? (

View file

@ -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<SkillSuiteBundleOperationSummary[]>(
`${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({