Skip to content

fix: インタラクティブプロンプト検出時にtmuxバッファ全体がレスポンスとして保存される (#326)#327

Merged
Kewton merged 3 commits intodevelopfrom
feature/326-worktree
Feb 20, 2026
Merged

fix: インタラクティブプロンプト検出時にtmuxバッファ全体がレスポンスとして保存される (#326)#327
Kewton merged 3 commits intodevelopfrom
feature/326-worktree

Conversation

@Kewton
Copy link
Owner

@Kewton Kewton commented Feb 20, 2026

Summary

  • extractResponse()のインタラクティブプロンプト検出時にlastCapturedLine以降の行のみをレスポンスとして返すよう修正し、前の会話内容の混入を防止
  • resolveExtractionStartIndex()ヘルパー関数を抽出してstartIndex決定ロジックを一元化(DRY化)
  • 箇所2(フォールバックプロンプト検出)にstripAnsi()を追加しXSSリスクを軽減

Changes

Bug Fix

  • 箇所1(Claude早期プロンプト検出): stripAnsi(fullOutput)stripAnsi(lines.slice(startIndex).join('\n'))
  • 箇所2(フォールバックプロンプト検出): fullOutputstripAnsi(lines.slice(startIndex).join('\n'))stripAnsi()追加)

Refactoring

  • resolveExtractionStartIndex() ヘルパー関数を@internal exportとして追加(4分岐startIndex決定ロジック)
  • 通常レスポンスパスの既存4分岐インラインロジックをresolveExtractionStartIndex()呼び出しに置換
  • buildPromptExtractionResult() ヘルパー関数で重複コードを排除

Tests

  • tests/unit/lib/resolve-extraction-start-index.test.ts 新規作成(12テストケース)
  • 既存テスト全3647件パス確認

Quality

Check Result
Unit Tests 3647 passed
ESLint 0 errors
TypeScript 0 errors

Test plan

  • resolveExtractionStartIndex()の12テストケース(4分岐 + エッジケース)全パス
  • 既存テスト全3647件パス(動作変更なし確認)
  • ESLint / TypeScript エラー0件

Closes #326

🤖 Generated with Claude Code

Kewton and others added 3 commits February 20, 2026 16:52
…dLine onwards

- Extract resolveExtractionStartIndex() as shared helper for startIndex determination
- Fix Location 1 (Claude early prompt detection) to use lastCapturedLine-based extraction
- Fix Location 2 (fallback prompt detection) to use lastCapturedLine-based extraction
  and add stripAnsi() for XSS risk mitigation
- Refactor normal response path to use the shared helper (DRY)
- Add 12 unit tests covering all 4 branches and edge cases

Resolves #326

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract buildPromptExtractionResult() helper to eliminate duplicate
prompt extraction logic at two call sites (DRY). Enhance JSDoc for
resolveExtractionStartIndex() with detailed parameter docs, branch
descriptions, and design policy references. Restructure test file
with nested describe blocks aligned to the 4-branch design document
terminology. Flatten if-else chain to early-return style for clarity.

Quality Metrics:
- Coverage: maintained (all 3647 tests pass)
- ESLint errors: 0
- TypeScript errors: 0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Kewton Kewton merged commit 27fcdcc into develop Feb 20, 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