Skip to content

feat: x 이모지 리액션으로 Claude 작업 취소 기능#4

Merged
Chanki-Min merged 7 commits intomainfrom
worktree-STOP-THINK
Mar 9, 2026
Merged

feat: x 이모지 리액션으로 Claude 작업 취소 기능#4
Chanki-Min merged 7 commits intomainfrom
worktree-STOP-THINK

Conversation

@Chanki-Min
Copy link
Copy Markdown
Owner

Summary

요구사항

Slack에서 Claude 작업을 트리거한 후 중간에 멈출 수 없는 문제가 있었습니다. 작업이 오래 걸리거나 잘못된 방향으로 진행될 때 취소할 수 있는 방법이 필요했습니다.

구현

트리거한 메시지에 x 이모지 리액션을 달면 해당 메시지에 연결된 진행 중인 Claude 작업을 즉시 중지합니다. 취소 성공 시 본인에게만 보이는 ephemeral 메시지로 안내합니다.

  • src/slack/cancelMap.ts (신규): Map<messageTs, AbortController> 기반 CancelMap 클래스. 작업 등록/취소/해제 담당
  • src/claude/runner.ts: ClaudeOptionssignal?: AbortSignal 추가. runClauderunClaudeStream 모두 abort 시 proc.kill() 처리
  • src/slack/handler.ts: createMentionHandlercreateAssistant에 cancelMap 연결. createReactionCancelHandler 추가 — x 이모지 + allowedUsers 체크 후 취소 및 ephemeral 전송
  • src/index.ts: CancelMap 인스턴스 생성, reaction_added 이벤트 등록
  • README.md / README.ko.md: reactions:read 스코프, reaction_added 이벤트 추가 안내

동작 방식

사용자가 x 리액션 추가
  → reaction_added 이벤트
  → allowedUsers 체크
  → cancelMap.cancel(ts) → AbortController.abort()
  → runner에서 proc.kill()
  → hourglass 리액션 제거 + ephemeral "작업이 취소되었습니다." 전송

엣지 케이스 처리:

  • 이미 완료된 작업에 x 리액션: cancelMap에 없으므로 무시 (오류 시 시스템이 단 x와 충돌 없음)
  • 동일 ts 중복 register: 이전 컨트롤러 abort 후 교체
  • 스폰과 리스너 등록 사이 경쟁 조건: 리스너 먼저 등록 후 aborted 체크로 해결

Slack 앱 설정 필요

  1. OAuth & Permissionsreactions:read 스코프 추가
  2. Event Subscriptionsreaction_added 이벤트 추가
  3. 앱 재설치

Test

101개 테스트 PASS, 타입체크 통과

  • tests/slack/cancelMap.test.ts: CancelMap 5개 테스트
  • tests/claude/runner.test.ts: AbortSignal pre-abort 테스트 2개 추가
  • tests/slack/handler.test.ts: createReactionCancelHandler 4개 테스트

Chanki-Min and others added 7 commits March 6, 2026 17:54
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a task is cancelled via x reaction, the "Error: cancelled" message
and session info were being posted publicly to the channel. Now both
are sent as ephemeral messages visible only to the requesting user.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Chanki-Min Chanki-Min marked this pull request as ready for review March 9, 2026 05:19
@Chanki-Min Chanki-Min merged commit f41a4ec into main Mar 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant