Skip to content

feat(task): auto-flatten subtasks inline when the nesting limit is reached - #22

Open
easonLiangWorldedtech wants to merge 4 commits into
mainfrom
up-3
Open

feat(task): auto-flatten subtasks inline when the nesting limit is reached#22
easonLiangWorldedtech wants to merge 4 commits into
mainfrom
up-3

Conversation

@easonLiangWorldedtech

Copy link
Copy Markdown
Owner

Part 3/8 of the task-tree series (builds on parts 1-2). Two commits: feature + e2e coverage.

Description

When a new_task call would exceed maxNestingDepth and autoFlattenOnLimit is set, the subtask is flattened into the current conversation instead of opening a new tab: the marker records the staged instruction + todos, a directive is pushed to the model, and attempt_completion during the phase ends the phase without completing the task. Nested new_task calls during an active phase are rejected with guidance to complete the inline work first.

Commit 2 adds e2e coverage across the real extension host: a three-level new_task chain where the depth-2 task's own call is flattened — asserts exactly 3 tasks exist, the flattened work completes in-conversation, parents resume correctly, and no fourth tab opens. Hand-written aimock fixtures (no API key needed).

Test Procedure

  • pnpm --dir src exec vitest run core/tools/__tests__/inlineSubtask.spec.ts core/tools/__tests__/newTaskInlineFlatten.spec.ts
  • E2E (mock mode): USE_MOCK=true TEST_FILE=inline-flatten.test.js pnpm --filter @roo-code/vscode-e2e test:run

Pre-Submission Checklist

  • Scope: inline flatten behavior + its e2e coverage
  • Self-review performed
  • Tests added (decision matrix, marker/directive/attempt_completion interception, extension-host e2e)
  • Visual snapshot: not applicable in this part (banner UI lands in part 7)
  • Documentation impact: none required

easonliang28 and others added 4 commits August 17, 2026 10:32
Part 1/8 of the task-tree series (upstream-ready recomposition).

Adds `depth` to HistoryItem and a cycle-safe `backfillTaskDepth()` that
propagates parent depth through the delegation tree, so every task knows its
nesting level. Depth is surfaced for later use by settings validation,
environment details, and history-tree display.

Includes the single-open-invariant spec mock for backfillTaskDepth (folded in
from the series' CI fix) so this PR passes unit tests standalone.

Depth contract hardening:
- Children inherit their live parent's depth authority instead of assuming it,
  so a legacy non-authoritative parent never stamps its placeholder depth onto
  the child as a persisted fact (regression test added).
- computeTaskDepth now processes an ancestor reached after exactly
  MAX_DEPTH_WALK hops; only strictly longer chains are rejected (boundary
  regression test added).
…ound-trip

Part 2/8 of the task-tree series (upstream-ready recomposition).

Adds two global settings that control subtask delegation:

- `maxNestingDepth` (default 2, range 0-5): how many levels a subtask may
  nest. A value of 0 disables delegation entirely — every new_task runs inline.
- `autoFlattenOnLimit` (default true): when the limit is reached, flatten the
  subtask into the current conversation instead of opening a new tab; when
  disabled such requests are rejected so you can continue directly.

Full round trip: global-settings schema + defaults, ExtensionState,
SettingsView control bound to cachedState with save payload, webviewMessageHandler
persistence through ContextProxy, ClineProvider getState/getStateToPostToWebview,
runtime consumers using the shared defaults. Includes focused tests for UI
binding/save, persistence, and the saved value returned to the webview.

Also completes the taskTree translation keys in all 17 non-English locales so
check-translations passes standalone (folded in from the series' CI fix).
…ached (#12)

Co-authored-by: Eason Liang <easonliang28@gmail.com>
Adds a three-level new_task chain e2e (root -> child -> depth-2 task) where the
depth-2 task's own new_task call exceeds maxNestingDepth and is flattened inline.
Asserts exactly 3 tasks exist, the flattened work completes in the depth-2 task's
own conversation, parent/child resume correctly, and the task stack never holds a
fourth task. Hand-written aimock fixtures (no API key needed) use unique
FLATTEN_E2E_ markers with predicate matching to avoid cross-suite collisions.
@easonLiangWorldedtech
easonLiangWorldedtech marked this pull request as ready for review August 17, 2026 02:58
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.

2 participants