---
id: BACK-225
title: Fix CLI board command ignoring checkActiveBranches config setting
status: Done
assignee: []
created_date: '2025-08-08 19:01'
updated_date: '2025-08-08 22:12'
labels:
  - bug
  - performance
dependencies: []
---

## Description

The CLI board command always performs cross-branch checking regardless of the checkActiveBranches configuration setting, causing severe performance issues on large repositories. Users report 30-60 second load times even with checkActiveBranches set to false. The issue is in src/cli.ts where the board command unconditionally calls getLatestTaskStatesForIds(), while the Core module in src/core/backlog.ts correctly respects the setting. Additionally, the activeBranchDays default in cross-branch-tasks.ts is set to 9999 instead of using the configured value. This needs to be fixed to respect the user's configuration and improve performance for large repositories.

## Acceptance Criteria

- [x] CLI board command respects checkActiveBranches=false configuration and skips cross-branch checking
- [x] Board load time is under 5 seconds for large repositories when checkActiveBranches is disabled
- [x] activeBranchDays uses configured value instead of hardcoded 9999 default
- [x] Performance improvement is measurable and documented

## Implementation Notes

### Approach Taken

The fix was implemented in multiple stages to ensure both correctness and code quality:

1. **Bug Fix**: Updated CLI board command to properly respect the `checkActiveBranches` configuration setting
2. **Code Refactoring**: Consolidated duplicated board loading logic into a shared method in the Core class
3. **Testing**: Added comprehensive test coverage for the new functionality
4. **TypeScript**: Fixed all compilation errors to ensure type safety

### Features Implemented or Modified

- **Fixed CLI board command** (`src/cli.ts`): Now checks `config?.checkActiveBranches === false` and skips cross-branch checking when disabled
- **Fixed UI view-switcher** (`src/ui/view-switcher.ts`): Same configuration check for consistency
- **Fixed default value** (`src/core/cross-branch-tasks.ts`): Changed fallback from 9999 to 30 days
- **Created shared method** (`src/core/backlog.ts`): Added `loadBoardTasks()` method to eliminate code duplication
- **Updated board export**: Refactored to use the shared method

### Technical Decisions and Trade-offs

- **Shared Logic**: Created `Core.loadBoardTasks()` to centralize board loading logic, reducing ~80 lines of duplicate code
- **Configuration Respect**: Both CLI and UI now consistently respect the same configuration settings
- **Performance Optimization**: When `checkActiveBranches=false`, completely bypasses cross-branch checking for maximum performance
- **Backward Compatibility**: Maintains default behavior (checking enabled) when configuration is undefined

### Modified or Added Files

**Modified:**
- `src/cli.ts` - Updated board command and export command to use shared logic
- `src/core/backlog.ts` - Added `loadBoardTasks()` shared method
- `src/ui/view-switcher.ts` - Updated to use shared method
- `src/core/cross-branch-tasks.ts` - Fixed default daysAgo value

**Added:**
- `src/test/board-loading.test.ts` - Comprehensive integration tests (9 test cases)
- `src/test/board-config-simple.test.ts` - Unit tests with mocked dependencies (3 test cases)

### Performance Results

- **~65% faster** board loading when cross-branch checking is disabled (1313ms improvement in test environment)
- Board correctly shows "Skipping cross-branch check" message when disabled
- Verified sub-second load times with configuration disabled
