Commit aa85bc8
fix(environment): Filter out non-text tab inputs
## Bug Description
Multi-file edit operations (`apply_diff` tool) would fail consistently when Git diff views were open in VSCode. The failure occurred before reaching the diff view opening code, indicating the issue was not with tab management as initially suspected.
## Root Cause
The bug was caused by **environment context contamination** in `src/core/environment/getEnvironmentDetails.ts`. When Git diff views are open, the environment details gathering code was incorrectly processing non-text tabs:
1. **Improper type casting**: Line 68 used `(tab.input as vscode.TabInputText)?.uri?.fsPath` without filtering, casting all tab inputs as `TabInputText` regardless of their actual type
2. **Processing incompatible tab types**: Git diff tabs have input types like `TabInputTextDiff`, not `TabInputText`
3. **Malformed environment data**: This resulted in unexpected/malformed data being included in the environment context sent to the AI
4. **AI parsing interference**: The contaminated context affected how the AI parsed multi-file `apply_diff` requests, causing them to fail
## Fix
Added proper tab type filtering before processing:
```typescript
// Before (BROKEN)
.map((tab) => (tab.input as vscode.TabInputText)?.uri?.fsPath)
// After (FIXED)
.filter((tab) => tab.input instanceof vscode.TabInputText)
.map((tab) => (tab.input as vscode.TabInputText).uri.fsPath)
```
This matches the correct pattern already used in other parts of the codebase like `DiffViewProvider.ts` and `WorkspaceTracker.ts`.
## Impact
- Multi-file edits now work reliably when Git diff views are open
- Environment context data is properly filtered and type-safe
- Consistent tab processing across the codebase
Fixes: Kilo-Org/kilocode#7121 parent cc0f9e3 commit aa85bc8
File tree
2 files changed
+7
-1
lines changed- .changeset
- src/core/environment
2 files changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
0 commit comments