Skip to content

refactor(auto-yes-manager): decompose pollAutoYes() into single-responsibility functions#333

Merged
Kewton merged 3 commits intodevelopfrom
feature/323-worktree
Feb 21, 2026
Merged

refactor(auto-yes-manager): decompose pollAutoYes() into single-responsibility functions#333
Kewton merged 3 commits intodevelopfrom
feature/323-worktree

Conversation

@Kewton
Copy link
Owner

@Kewton Kewton commented Feb 21, 2026

Summary

pollAutoYes() (139行・7責務・14条件分岐) を4つの単一責務関数に分割し、タイマー非依存の個別テストを追加するリファクタリング。機能変更なし。

Closes #323

Changes

Added

  • validatePollingContext() - ポーリングコンテキスト検証(@internal export)
  • captureAndCleanOutput() - 出力キャプチャとANSIクリーニング(@internal export)
  • processStopConditionDelta() - 停止条件デルタ処理(@internal export)
  • detectAndRespondToPrompt() - プロンプト検出と応答(@internal export)
  • getPollerState() - プライベートgetterヘルパー
  • 20件の新規ユニットテスト(タイマー非依存)
  • createTestPollerState() テストヘルパーファクトリ

Changed

  • pollAutoYes() を139行から42行のオーケストレーターに置換
  • 6箇所の autoYesPollerStates.get()getPollerState() に統一
  • CLAUDE.md / docs/implementation-history.md にIssue #323エントリ追加

Fixed

  • テストの型アサーションバグ修正('manual' as 'expired''expired'

Test Results

Unit Tests

npm run test:unit
Test Files: 181 passed (181)
Tests: 3675 passed | 7 skipped (3682)

Lint & Type Check

  • ESLint: 0 errors
  • TypeScript: 0 errors

Build

npm run build
Build successful

Checklist

  • Unit tests pass (102 tests for auto-yes-manager, 3675 total)
  • Lint check passes
  • Type check passes
  • Build succeeds
  • No console.log in production code
  • No functional changes (external interface preserved)
  • Acceptance criteria: 10/10 scenarios passed

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Kewton and others added 3 commits February 21, 2026 09:26
…tions

Extract 4 @internal export functions from pollAutoYes() (~139 lines)
to improve testability and SRP compliance:
- validatePollingContext(): Pre-condition checks
- captureAndCleanOutput(): tmux output capture + ANSI cleanup
- processStopConditionDelta(): Stop condition delta-based check
- detectAndRespondToPrompt(): Prompt detection + auto-response

Also add getPollerState() internal helper for consistency with
existing getAutoYesState() accessor pattern.

pollAutoYes() is now a ~30-line orchestrator.
No functional changes - all 82 existing tests pass unchanged.
20 new timer-independent unit tests added (102 total).

Refs #323

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace 'manual' as 'expired' type cast with direct 'expired' value
in validatePollingContext test. The original cast was misleading since
AutoYesStopReason only accepts 'expired' | 'stop_pattern_matched'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Issue #323 (pollAutoYes() refactoring) の pm-auto-issue2dev 全工程の
成果物を追加。Issueレビュー(8段階)→設計方針書→設計レビュー(4段階)
→作業計画→TDD自動開発のレポートファイル一式。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Kewton Kewton merged commit baab372 into develop Feb 21, 2026
5 checks 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