Skip to content

feat(settings): add maxNestingDepth and autoFlattenOnLimit settings round-trip - #11

Merged
easonLiangWorldedtech merged 1 commit into
main-task-treefrom
pr-2-settings-roundtrip
Aug 16, 2026
Merged

feat(settings): add maxNestingDepth and autoFlattenOnLimit settings round-trip#11
easonLiangWorldedtech merged 1 commit into
main-task-treefrom
pr-2-settings-roundtrip

Conversation

@easonLiangWorldedtech

Copy link
Copy Markdown
Owner

feat(settings): add maxNestingDepth and autoFlattenOnLimit settings round-trip

Part of the Task Tree unified subtask management plan (issue #9, P1.2). This PR wires two new persisted settings through the complete AGENTS.md round trip so that later PRs (auto-flatten inline mode) can read them from both the extension host and the webview.

Settings

Setting Type Default Range / semantics
maxNestingDepth number 2 integer 0–5; root = 0. 0 disables delegation entirely (all subtasks run inline).
autoFlattenOnLimit boolean true when the nesting limit is reached, execute the subtask inline in the current conversation instead of opening a child tab. When false, such calls are rejected so work continues directly.

Round-trip (per AGENTS.md persisted-setting checklist)

  1. Schema + defaultspackages/types/src/global-settings.ts: DEFAULT_MAX_NESTING_DEPTH = 2, DEFAULT_AUTO_FLATTEN_ON_LIMIT = true; schema fields maxNestingDepth: z.number().int().min(0).max(5).optional() and autoFlattenOnLimit: z.boolean().optional(). Old data stays compatible (both optional).
  2. ExtensionStatepackages/types/src/vscode-extension-host.ts: both fields added as optional.
  3. SettingsView bindingwebview-ui/.../SettingsView.tsx destructures from local cachedState (not live state), includes both in the handleSubmit() payload, and passes them to ContextManagementSettings, which renders a 0–5 slider (max-nesting-depth-slider) and a checkbox (auto-flatten-on-limit-checkbox) with i18n keys under settings:taskTree.*.
  4. Persistence + normalizationwebviewMessageHandler.ts: maxNestingDepth is normalized to an integer clamped 0–5 (non-numeric falls back to the default); autoFlattenOnLimit is coerced to a boolean; unset values are skipped so they never clobber stored state. Final value persisted via generic contextProxy.setValue().
  5. Provider round tripClineProvider.getState() returns both with defaults (?? DEFAULT_...); getStateToPostToWebview() destructures and passes them through, completing storage → webview so a saved control never visually reverts.

Tests (true / false / unset covered)

  • webview-ui/.../ContextManagementSettings.spec.tsx: slider renders default 2 when unset, explicit value passthrough, change callback; checkbox checked by default, unchecked when explicitly false, toggle callback.
  • src/core/webview/__tests__/ClineProvider.spec.ts (taskTree settings round-trip): getState() defaults (unset → 2 / true); handler clamping (3→3, 9→5, -1→0, non-numeric→default) and skip-when-unset; boolean normalization (false stays false, truthy coerces to true) and skip-when-unset; getStateToPostToWebview() saved-value passthrough and defaults when unset.

Verification

  • pnpm run check-types — 14/14 packages pass
  • ContextManagementSettings.spec.tsx — 35/35 (incl. 6 new)
  • ClineProvider.spec.ts — 132/132 (incl. 4 new round-trip tests)
  • SettingsView.change-detection + SettingsView.unsaved-changes — 15/15
  • Full turbo lint (--max-warnings=0) clean; no eslint suppression count increases

Out of scope (later PRs)

Runtime consumption of these settings (auto-flatten inline mode, depth enforcement in new_task) lands in the follow-up PRs per issue #9. This PR is purely the settings plumbing.

@easonLiangWorldedtech
easonLiangWorldedtech merged commit c3bb627 into main-task-tree Aug 16, 2026
8 of 12 checks passed
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