Repository navigation
fix: 명세 불일치 — 실행 취소는 관리자 전용 제한 + 상태 전달을 SSE로 전환 - #40
Merged
Merged
Conversation
기명서 Execution "실행 취소·중지": "체험자는 QUEUED·ASSIGNED 에서만 취소할 수 있다. RUNNING 이후 중지는 관리자 기능으로 처리한다." 인데, 지금까지 구현은 RUNNING 중에도 체험자가 '실행 중지' 버튼으로 멈출 수 있어 명세와 어긋났다. - features/execution: CANCELLABLE_STATUSES(queued·assigned)· isCancellableStatus 추가 (기존 TERMINAL_STATUSES 패턴과 동일) - mocks.ts: 취소 요청이 QUEUED·ASSIGNED 일 때만 실제로 취소 처리 — RUNNING 이면 상태를 그대로 반환한다(서버가 최종 기준이라는 기존 원칙과 동일하게, 체험자용 엔드포인트가 자체적으로 거부) - RunReadyWorkspace: RUNNING 중엔 '실행 중지' 버튼 대신 비활성 '실행 중…' 표시 — 취소 가능한(QUEUED·ASSIGNED) 구간에만 버튼을 보여준다 '실행 상태 전달'(명세: SSE, 구현: 폴링)은 이번에 같이 고치지 않았다 — 실제 백엔드가 없어 SSE 계약을 알 수 없고, 이미 코드에 "SSE 우선 검토했으나 지금은 폴링"이라는 의도적 결정이 남아있어 더 큰 논의가 필요해 보류. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
노션 DB 감사 중 발견한 Execution 명세 불일치 2건.
1. 실행 취소·중지
"체험자는 QUEUED·ASSIGNED 에서만 취소할 수 있다. RUNNING 이후 중지는 관리자 기능으로 처리한다." — 인데 지금까지 구현은 RUNNING 중에도 체험자가 '실행 중지' 버튼으로 멈출 수 있었다.
2. 실행 상태 전달
"Server → Web 실시간 갱신은 SSE를 사용한다. 연결이 끊기면 재연결 후 현재 상태를 다시 조회해 화면을 복구한다." — 인데 지금까지는 600ms 간격 폴링이었다(코드에 "SSE 우선 검토, 지금은 폴링"이라는 의도적 보류 코멘트가 남아있었음).
변경
실행 취소·중지
features/execution/model/types.ts:CANCELLABLE_STATUSES(queued·assigned)·isCancellableStatus추가 (기존TERMINAL_STATUSES패턴과 동일)mocks.ts: 취소 요청이 QUEUED·ASSIGNED 일 때만 실제로 취소 처리 — RUNNING 이면 상태를 그대로 반환RunReadyWorkspace.tsx: RUNNING 중엔 '실행 중지' 버튼 대신 비활성 '실행 중…' 표시실행 상태 전달
features/execution/lib/executionStream.ts(신규): SSE 구독 함수. 네이티브EventSource대신fetch+ReadableStream을 직접 읽는다 — 테스트 환경(jsdom)엔EventSource가 없어 폴리필 없이는 검증할 수 없고,fetch기반이라야 MSW로 그대로 테스트할 수 있다. 연결이 끊기면 지수 백오프(500ms~5s)로 재연결한다.mocks.ts:GET /api/executions/:id/stream추가 — 연결 즉시 현재 상태부터 보내고(재연결 시 "현재 상태를 다시 조회"를 만족), 상태가 실제로 바뀔 때만 push. 종료 상태에서 스트림을 닫아 재연결하지 않는다.hooks.ts:useExecutionState가 폴링 대신 SSE 구독으로 쿼리 캐시를 갱신. 초기 1회 REST 조회는 유지(마운트 직후·refetch()즉시 호출용).테스트
executionApi.test.ts: RUNNING 에서 취소해도 상태가 안 바뀌는 것 확인executionStream.test.ts(신규): 초기 상태 즉시 수신, 상태 전환 push 확인(대기→배정→진행→완료), 완료 시 스트림 종료, 취소 시 프레임 수신ExperienceView.test.tsx: 배정 대기 중 취소 동작 유지, RUNNING 중엔 중지 버튼이 없고 '처음으로'로 로컬 초기화만 되는 것 확인typecheck/lint/build/format:check클린🤖 Generated with Claude Code