Skip to content

feat: add --context-window setting for Vibe Local (#374)#377

Merged
Kewton merged 5 commits intodevelopfrom
feature/374-worktree
Feb 27, 2026
Merged

feat: add --context-window setting for Vibe Local (#374)#377
Kewton merged 5 commits intodevelopfrom
feature/374-worktree

Conversation

@Kewton
Copy link
Owner

@Kewton Kewton commented Feb 27, 2026

Summary

  • Vibe Local CLIツールに --context-window パラメータを追加し、worktree単位でOllamaのコンテキストウィンドウサイズを設定可能にする
  • 既存の vibeLocalModel 実装パターン(DB永続化 → API → UI → CLIオプション)を踏襲
  • 対話モード(tmuxセッション)のみ対象。スケジュール実行(-pモード)はスコープ外

Changes

DB層

  • db-migrations.ts: version 20 マイグレーション(vibe_local_context_window INTEGER DEFAULT NULL
  • db.ts: updateVibeLocalContextWindow() 関数追加、getWorktrees()/getWorktreeById() のSELECT文修正(6箇所)

API層

  • route.ts: PATCH /api/worktrees/[id]vibeLocalContextWindow バリデーション追加(128〜2097152の整数 or null)

CLI層

  • vibe-local.ts: startSession()--context-window ${Number(ctxWindow)} をdefense-in-depthバリデーション付きで追加
  • types.ts: VIBE_LOCAL_CONTEXT_WINDOW_MIN/MAX 定数、isValidVibeLocalContextWindow() 型ガード関数

UI層

  • AgentSettingsPane.tsx: Vibe Local選択時にコンテキストウィンドウ入力欄表示
  • NotesAndLogsPane.tsx: props伝播
  • WorktreeDetailRefactored.tsx: state/callback管理

テスト

  • types.test.ts: 新規43テスト(バリデーション関数 + OLLAMA_MODEL_PATTERN)
  • db-migrations.test.ts: CURRENT_SCHEMA_VERSION期待値を20に更新

Test plan

  • npx tsc --noEmit — TypeScriptエラー 0件
  • npm run lint — ESLintエラー 0件
  • npm run test:unit — 4079テスト全パス(+43件新規)
  • 受入テスト 8/8基準クリア
  • 4段階設計レビュー(設計原則・整合性・影響分析・セキュリティ)完了

Closes #374

🤖 Generated with Claude Code

Kewton and others added 5 commits February 27, 2026 23:48
…truncated re-detection

When extractResponse() early check detects a Codex prompt using the full tmux
output, the detection result is now carried through ExtractionResult.promptDetection
to checkForResponse(). This prevents the second detectPromptWithOptions() call
from failing due to the extracted portion (from lastCapturedLine) potentially
missing the › indicator line.

Root cause: Codex TUI renders prompts progressively. When CODEX_PROMPT_PATTERN
matches the › line before all options are rendered, isCodexOrGeminiComplete fires
and extraction stops at the › line. The response is saved as type=normal with
lineCount=endIndex. On the next poll, the early detection finds the full prompt
but buildPromptExtractionResult only extracts from lastCapturedLine onwards,
potentially excluding the › indicator line from the extracted content.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… buffer reset

Two issues prevented Codex CLI confirmation prompts from being detected:

1. Prompt detector continuation line scan traversed entire command output
   because Codex TUI indents all lines with 2 spaces, matching
   isContinuationLine(). This caused numbered lists in body text to be
   collected as false options, breaking isConsecutiveFromOne() validation.
   Fixed by adding MAX_CONTINUATION_LINES=5 limit.

2. Buffer reset (TUI redraw) caused lineCount < lastCapturedLine, triggering
   the duplicate prevention check incorrectly. Fixed by propagating
   bufferReset flag through ExtractionResult and skipping duplicate checks
   when buffer reset is detected.

Also added logging for silent session-not-running poller stops.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dow size

- Add VIBE_LOCAL_CONTEXT_WINDOW_MIN/MAX constants and isValidVibeLocalContextWindow()
  type guard to types.ts (DRY: shared between API and CLI layers)
- Add vibeLocalContextWindow field to Worktree interface (models.ts)
- Add DB migration v20: vibe_local_context_window INTEGER DEFAULT NULL column
- Add updateVibeLocalContextWindow() DB function; update getWorktrees/getWorktreeById
  SELECT statements (6 modification points)
- Add PATCH API validation for vibeLocalContextWindow with isValidVibeLocalContextWindow()
- Add --context-window CLI argument in vibe-local.ts startSession() with defense-in-depth
  validation and Number() cast for template literal safety
- Add Context Window number input UI in AgentSettingsPane (vibe-local only)
- Add i18n keys (en/ja) for vibeLocalContextWindow and vibeLocalContextWindowDefault
- Props propagation through NotesAndLogsPane and WorktreeDetailRefactored
- Add unit tests for isValidVibeLocalContextWindow() (21 test cases)
- Update db-migrations.test.ts CURRENT_SCHEMA_VERSION expectations to 20
- Update component test props factories

Resolves #374

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ature

- Replace hardcoded min/max values (128/2097152) in AgentSettingsPane
  with VIBE_LOCAL_CONTEXT_WINDOW_MIN/MAX constants (DRY principle)
- Use constant-derived error message in API route validation
- Handle NaN from parseInt in client-side context window input
- Align migration v20 down-message style with v19 pattern
- Add boundary and invariant tests for context window constants
- Add OLLAMA_MODEL_PATTERN validation tests (defense-in-depth coverage)

Quality Metrics:
- TypeScript errors: 0
- ESLint errors: 0
- Tests: 4057 -> 4079 (22 new tests added)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update module descriptions for types.ts, vibe-local.ts, and
AgentSettingsPane.tsx with Issue #374 changes. Add design policy,
review reports, work plan, and TDD results.

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