|
| 1 | +# Coverage Analysis Report: PR #1125 (b05-shell-resolution-v2) |
| 2 | + |
| 3 | +## Methodology |
| 4 | + |
| 5 | +1. Checked out branch `pr/b05-shell-resolution-v2` (HEAD: `35cc3dcf8`). |
| 6 | +2. Base commit for diff: `992585ff8` (merge-base with `origin/main`). |
| 7 | +3. Ran backend tests with coverage: `cd src && npx vitest run --coverage --reporter=verbose integrations/terminal/__tests__/ core/tools/__tests__/ core/prompts/__tests__/ core/webview/__tests__/` |
| 8 | +4. Ran webview tests with coverage: `cd webview-ui && npx vitest run --coverage --reporter=verbose src/components/settings/__tests__/` |
| 9 | +5. Ran packages/types tests with coverage: `cd packages/types && npx vitest run --coverage --reporter=verbose` |
| 10 | +6. Cross-referenced git diff added lines (patch) with lcov/coverage-final.json hit data to identify **new lines only** that are uncovered. |
| 11 | + |
| 12 | +**Key insight**: codecov/patch measures only NEW lines introduced by the PR diff, not total file coverage. The analysis below reflects this. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Coverage Summary - Backend (80% target) |
| 17 | + |
| 18 | +| File | New Lines | Covered | Uncovered | Coverage % | |
| 19 | +| -------------------------------------------------------------- | --------- | ------- | --------- | ---------- | |
| 20 | +| `src/integrations/terminal/TerminalLifecycle.ts` | 600 | 105 | 495 | 17.5% | |
| 21 | +| `src/integrations/terminal/shell/TerminalProfileResolver.ts` | 609 | 115 | 494 | 18.9% | |
| 22 | +| `src/integrations/terminal/shell/ShellResolver.ts` | 554 | 94 | 460 | 17.0% | |
| 23 | +| `src/integrations/terminal/TerminalRegistry.ts` | 555 | 136 | 419 | 24.5% | |
| 24 | +| `src/integrations/terminal/CommandScheduler.ts` | 507 | 121 | 386 | 23.9% | |
| 25 | +| `src/core/tools/ExecuteCommandTool.ts` | 396 | 83 | 313 | 21.0% | |
| 26 | +| `src/integrations/terminal/CommandTrace.ts` | 344 | 46 | 298 | 13.4% | |
| 27 | +| `src/integrations/terminal/Terminal.ts` | 326 | 65 | 261 | 19.9% | |
| 28 | +| `src/core/webview/ClineProvider.ts` | 258 | 11 | 247 | 4.3% | |
| 29 | +| `src/integrations/terminal/shell/CommandEnvironmentService.ts` | 274 | 36 | 238 | 13.1% | |
| 30 | +| `src/integrations/terminal/shell/types.ts` | 155 | 0 | 155 | 0.0% | |
| 31 | +| `src/integrations/terminal/shell/ShellInvocationAdapter.ts` | 168 | 20 | 148 | 11.9% | |
| 32 | +| `src/utils/shell.ts` | 144 | 26 | 118 | 18.1% | |
| 33 | +| `src/integrations/terminal/BaseTerminal.ts` | 128 | 17 | 111 | 13.3% | |
| 34 | +| `src/integrations/terminal/types.ts` | 131 | 21 | 110 | 16.0% | |
| 35 | +| `src/core/prompts/tools/native-tools/execute_command.ts` | 96 | 22 | 74 | 22.9% | |
| 36 | +| `src/integrations/terminal/ExecaTerminal.ts` | 72 | 4 | 68 | 5.6% | |
| 37 | +| `src/integrations/terminal/ExecaTerminalProcess.ts` | 63 | 7 | 56 | 11.1% | |
| 38 | +| `src/core/prompts/sections/rules.ts` | 59 | 11 | 48 | 18.6% | |
| 39 | +| `src/core/webview/webviewMessageHandler.ts` | 41 | 5 | 36 | 12.2% | |
| 40 | +| `src/integrations/terminal/TerminalProcess.ts` | 36 | 7 | 29 | 19.4% | |
| 41 | +| `src/core/prompts/sections/system-info.ts` | 32 | 4 | 28 | 12.5% | |
| 42 | +| `src/core/webview/generateSystemPrompt.ts` | 24 | 4 | 20 | 16.7% | |
| 43 | +| `src/core/prompts/tools/native-tools/index.ts` | 13 | 1 | 12 | 7.7% | |
| 44 | +| `src/core/prompts/system.ts` | 6 | 0 | 6 | 0.0% | |
| 45 | +| `src/core/task/build-tools.ts` | 7 | 0 | 7 | 0.0% | |
| 46 | +| `src/extension.ts` | 5 | 0 | 5 | 0.0% | |
| 47 | +| `src/extension/api.ts` | 4 | 0 | 4 | 0.0% | |
| 48 | +| `packages/types/src/global-settings.ts` | 36 | 35 | 1 | 97.2% | |
| 49 | +| `packages/types/src/terminal.ts` | 11 | 11 | 0 | 100.0% | |
| 50 | +| **Backend Total** | **5654** | **990** | **4664** | **17.5%** | |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Coverage Summary - Webview (70% target) |
| 55 | + |
| 56 | +| File | New Lines | Covered | Uncovered | Coverage % | |
| 57 | +| --------------------------------------------------------- | --------- | ------- | --------- | ---------- | |
| 58 | +| `webview-ui/src/components/settings/TerminalSettings.tsx` | 157 | 23 | 134 | 14.6% | |
| 59 | +| `webview-ui/src/components/settings/SettingsView.tsx` | 31 | 6 | 25 | 19.4% | |
| 60 | +| **Webview Total** | **188** | **29** | **159** | **15.4%** | |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Top 5 Uncovered Files (by impact) |
| 65 | + |
| 66 | +### 1. `src/integrations/terminal/TerminalLifecycle.ts` - 495 uncovered new lines (17.5%) |
| 67 | + |
| 68 | +- **New file** (600 lines added). Only L105-106, L107, L121, L124-130, L134-153, L155-162, L164-170, L179-186, L188-191, L193-196, L198-201, L203-206, L208-211, L213-216, L218-221, L223-229 and ~43 more groups are uncovered. |
| 69 | +- Entire class structure, lifecycle management, and event handling logic untested. |
| 70 | +- **Root cause**: New file with complex lifecycle orchestration. Tests exist (`TerminalLifecycle.spec.ts`, 1043 lines) but coverage is only 17.5% of new lines, suggesting tests cover only a subset of methods. |
| 71 | + |
| 72 | +### 2. `src/integrations/terminal/shell/TerminalProfileResolver.ts` - 494 uncovered new lines (18.9%) |
| 73 | + |
| 74 | +- **New file** (609 lines added). Only L94-96, L115, L178-180, L182, L196, L285, L330, L355, L390, L392, L404, L433, L436, L464, L466, L479, L532, L536 are covered. |
| 75 | +- Profile resolution logic, platform-specific branches, and fallback chains untested. |
| 76 | +- **Root cause**: New file. Tests exist (`ShellResolver.spec.ts` covers some paths) but the resolver has many platform-specific branches not exercised on Windows. |
| 77 | + |
| 78 | +### 3. `src/integrations/terminal/shell/ShellResolver.ts` - 460 uncovered new lines (17.0%) |
| 79 | + |
| 80 | +- **New file** (554 lines added). Only L84-86, L88-89, L96, L98-99, L101-102, L104-105, L107, L165-167, L170, L259, L302, L319, L347, L358, L471-473, L526, L528 are covered. |
| 81 | +- Shell detection, validation, and fallback logic largely untested. |
| 82 | +- **Root cause**: New file with extensive platform branching. Tests exist (`ShellResolver.spec.ts`, 691 lines) but many code paths require specific OS/shell configurations. |
| 83 | + |
| 84 | +### 4. `src/integrations/terminal/TerminalRegistry.ts` - 419 uncovered new lines (24.5%) |
| 85 | + |
| 86 | +- 555 new lines added to existing file. Many new methods for terminal management, shell integration, and registry operations uncovered. |
| 87 | +- **Root cause**: Existing file with massive additions. Tests exist (`TerminalRegistry.spec.ts`, 311+ lines) but coverage at 24.5% indicates many new methods untested. |
| 88 | + |
| 89 | +### 5. `src/integrations/terminal/CommandScheduler.ts` - 386 uncovered new lines (23.9%) |
| 90 | + |
| 91 | +- **New file** (507 lines added). Only L68, L70, L77, L82, L87, L97, L126, L148, L151, L157, L170, L173, L182-183, L185, L193, L216, L220, L225, L233, L241, L272, L385, L411 are covered. |
| 92 | +- Command queuing, scheduling, and execution logic untested. |
| 93 | +- **Root cause**: New file. Tests exist (`CommandScheduler.spec.ts`, 601 lines) but coverage at 23.9% suggests tests focus on a subset of scheduling scenarios. |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## Recommended Tests to Write |
| 98 | + |
| 99 | +### Priority 1: Highest Impact (Backend, 80% target) |
| 100 | + |
| 101 | +The backend patch coverage is **17.5%** - far below the 80% target. To reach 80%, we need to cover approximately **3,523** more new lines (out of 4,664 uncovered). Focus on: |
| 102 | + |
| 103 | +1. **`TerminalLifecycle.ts`** (495 uncovered): Add tests for lifecycle state transitions, terminal creation/disposal, event listener management, and error recovery paths. The existing `TerminalLifecycle.spec.ts` needs expansion to cover the full lifecycle state machine. |
| 104 | + |
| 105 | +2. **`TerminalProfileResolver.ts`** (494 uncovered): Add platform-specific test cases for profile resolution on Windows (PowerShell, cmd), macOS (zsh, bash), and Linux (bash, zsh). Mock `vscode.window.activeTerminal.profile` and `vscode.workspace.getConfiguration('terminal.integrated')` more thoroughly. |
| 106 | + |
| 107 | +3. **`ShellResolver.ts`** (460 uncovered): Add tests for shell detection fallback chains, path validation, and platform-specific shell discovery. Mock `process.platform`, `os.platform()`, and file existence checks. |
| 108 | + |
| 109 | +4. **`TerminalRegistry.ts`** (419 uncovered): Add tests for new registry methods: terminal tracking, shell integration state management, cleanup operations, and multi-terminal coordination. |
| 110 | + |
| 111 | +5. **`CommandScheduler.ts`** (386 uncovered): Add tests for queue management, priority scheduling, concurrent command execution, timeout handling, and cancellation paths. |
| 112 | + |
| 113 | +6. **`ExecuteCommandTool.ts`** (313 uncovered): Add tests for new execute command paths including shell selection, environment setup, output capture, and error handling branches. |
| 114 | + |
| 115 | +7. **`CommandTrace.ts`** (298 uncovered): Add tests for command trace recording, serialization, and query methods. This is a new file with zero meaningful coverage. |
| 116 | + |
| 117 | +8. **`Terminal.ts`** (261 uncovered): Add tests for new terminal operations, shell integration, and process management methods. |
| 118 | + |
| 119 | +9. **`ClineProvider.ts`** (247 uncovered): Add tests for new terminal settings handling, shell selection state management, and webview message dispatch for terminal configuration. |
| 120 | + |
| 121 | +10. **`CommandEnvironmentService.ts`** (238 uncovered): Add tests for environment variable resolution, PATH manipulation, and shell-specific environment setup. |
| 122 | + |
| 123 | +### Priority 2: Webview (70% target) |
| 124 | + |
| 125 | +The webview patch coverage is **15.4%** - far below the 70% target. To reach 70%, we need to cover approximately **103** more new lines (out of 159 uncovered). |
| 126 | + |
| 127 | +1. **`TerminalSettings.tsx`** (134 uncovered): Add tests for: |
| 128 | + - Shell selection dropdown rendering and onChange handlers (L102-103, L105, L115, L157, L201, L235, L255, L259, L263-271) |
| 129 | + - Profile path input validation (L304, L428-429, L466, L504, L533, L561, L588, L612, L636) |
| 130 | + - Form state management for terminal settings |
| 131 | + |
| 132 | +2. **`SettingsView.tsx`** (25 uncovered): Add tests for: |
| 133 | + - Terminal settings section rendering (L255, L278, L305-307, L310-311, L316-318, L321-322, L327-329, L332-333, L338-340, L343, L348-350, L353, L358-360, L363, L368-370, L372-373, L376-377) |
| 134 | + - Settings change handlers for terminal shell selection (L514-515, L517, L542, L544, L607, L662, L665-669, L672-674, L724, L756, L793-794, L798, L801, L806, L809, L918, L952, L1018) |
| 135 | + |
| 136 | +### Priority 3: Types (already high coverage) |
| 137 | + |
| 138 | +- `packages/types/src/global-settings.ts`: 97.2% patch coverage (1 uncovered line: L391). Already passing. |
| 139 | +- `packages/types/src/terminal.ts`: 100% patch coverage. Already passing. |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +## Commands Run |
| 144 | + |
| 145 | +```bash |
| 146 | +# 1. Checkout branch |
| 147 | +git fetch myk1yt |
| 148 | +git checkout pr/b05-shell-resolution-v2 |
| 149 | +git reset --hard myk1yt/pr/b05-shell-resolution-v2 |
| 150 | + |
| 151 | +# 2. Backend tests with coverage |
| 152 | +cd src && npx vitest run --coverage --reporter=verbose integrations/terminal/__tests__/ core/tools/__tests__/ core/prompts/__tests__/ core/webview/__tests__/ |
| 153 | + |
| 154 | +# 3. Webview tests with coverage |
| 155 | +cd webview-ui && npx vitest run --coverage --reporter=verbose src/components/settings/__tests__/ |
| 156 | + |
| 157 | +# 4. packages/types tests with coverage |
| 158 | +cd packages/types && npx vitest run --coverage --reporter=verbose |
| 159 | + |
| 160 | +# 5. Cross-reference diff added lines with coverage data |
| 161 | +git diff 992585ff8...HEAD --unified=0 -- <files> # for each source file |
| 162 | +python cross_ref_b05_coverage.py # custom script to cross-reference |
| 163 | +``` |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +## Key Findings |
| 168 | + |
| 169 | +1. **Backend patch coverage: 17.5%** (target: 80%) - Massive gap of 4,664 uncovered new lines across 28 source files. |
| 170 | +2. **Webview patch coverage: 15.4%** (target: 70%) - Gap of 159 uncovered new lines across 2 source files. |
| 171 | +3. **Types patch coverage: 97.2%** (target: passing) - Only 1 line uncovered in `global-settings.ts`. |
| 172 | +4. **Root cause**: This PR introduces 6 new files (`TerminalLifecycle.ts`, `TerminalProfileResolver.ts`, `ShellResolver.ts`, `CommandScheduler.ts`, `CommandTrace.ts`, `CommandEnvironmentService.ts`) totaling ~2,884 new lines, plus major additions to existing files. While test files exist for most of these, the tests cover only a fraction of the new code paths. |
| 173 | +5. **Platform-specific code**: Many uncovered lines are in platform-specific branches (Windows/macOS/Linux shell detection) that are difficult to test on a single platform. |
| 174 | +6. **Type-only files**: `shell/types.ts` (155 new lines, 0% coverage) is a pure type/interface file with no runtime code - codecov may still count it if it has executable statements (e.g., enum values or const assertions). |
0 commit comments