Commit 42bd8b9
fix: correctly report sub-task results in Orchestrator mode
The `rootTask` and `parentTask` properties in the `Task` class were
incorrectly initialized, preventing sub-tasks from properly reporting
their results back to the main Orchestrator task. This commit fixes
the initialization to ensure correct task hierarchy and result propagation.
The issue is with how TypeScript handles `readonly` properties when they have explicit initializers. Let me demonstrate:
```typescript
readonly rootTask: Task | undefined
readonly parentTask: Task | undefined
```
```typescript
readonly rootTask: Task | undefined = undefined
readonly parentTask: Task | undefined = undefined
```
When you declare a `readonly` property with an explicit initializer like `= undefined`, TypeScript treats this as a **definitive assignment** that happens at the class field level, **before** the constructor runs.
Here's what happens:
1. Class is instantiated
2. Constructor runs
3. `this.parentTask = parentTask` successfully assigns the parent task
4. Property now contains the actual parent task reference
1. Class is instantiated
2. **TypeScript immediately sets `this.parentTask = undefined` due to the field initializer**
3. Constructor runs
4. `this.parentTask = parentTask` tries to assign, but TypeScript may optimize this away or the field initializer takes precedence
5. Property remains `undefined` even though we tried to assign it
Fixes RooCodeInc#17421 parent 2882d99 commit 42bd8b9
2 files changed
+7
-2
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 | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
| 127 | + | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
0 commit comments