8000 Implement hierarchical task history with parent-child relationships by KJ7LNW · Pull Request #3689 · RooCodeInc/Roo-Code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Implement hierarchical task history with parent-child relationships #3689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

KJ7LNW
Copy link
Collaborator
@KJ7LNW KJ7LNW commented May 17, 2025

Context

This PR implements a hierarchical task history feature that tracks parent-child relationships between tasks, particularly for tasks created using the new_task tool.

Implementation

  • Added parent_task_id field to HistoryItem schema
  • Modified Task class to store parent task ID
  • Updated taskMetadata to include parent task ID in history items
  • Enhanced History UI components to display hierarchical relationships with collapsible sections
  • Added visual indicators for tasks with children
  • Added green styling for completed tasks (those that used attempt_completion)

Screenshots

In the history UI in the right, green means it completed, gray means in-progress, or it had completed and I said something to the model there, and it will turn green again upon <attempt_completion>. This PR allows you to watch the completion status live in a second Roo instance:

image

How to Test

  1. Create this task:

(N=random, depth=3) Output the node value N. Then, if depth > 0: 1. Create a left child new_taskwith a randomly chosen value that is LESS than the current node value N. Create a right childnew_taskwith a randomly chosen value that is GREATER than the current node value. Instruct each child task, to do the same and decrement depth for each call. each child must show their knowledge of the tree and in mermaid diagram with smaller values on the left and larger values on the right at each level, and thenattempt_completion with the tree they are aware of. you must use this EXACT instruction for each sub task ONLY change N and depth

  1. Open the History view

It generates a tree:

image

See also

#1123

Get in Touch

Discord: KJ7LNW

…hips

This change adds support for tracking parent-child relationships between tasks
in the task history, particularly for tasks created using the new_task tool.

Key changes:
- Add parent_task_id field to HistoryItem schema
- Modify Task class to store parent task ID
- Update taskMetadata to include parent task ID in history items
- Enhance History UI components to display hierarchical relationships
- Add visual indicators for tasks with children
- Add green styling for completed tasks

Fixes: cline#3688
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Copy link
changeset-bot bot commented May 17, 2025

⚠️ No Changeset found

Latest commit: 2173da2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Eric Wheeler added 6 commits May 16, 2025 19:43
Implement hierarchical display for tasks in the history view,
allowing parent tasks to be expanded to show child tasks.

- Add `parent_task_id` to `HistoryItem` schema to establish
  parent-child relationships.
- Update frontend to render tasks hierarchically, with child tasks
  indented and collapsible under their parents.

Introduce a `completed` status for tasks:
- Add `completed` boolean flag to `HistoryItem` schema.
- Backend logic in `Task.ts` now sets `completed: true` when an
  `attempt_completion` is processed (e.g., `ask: "completion_result"`
  or `say: "completion_result"` messages) and `completed: false` if
  new messages are added to a completed task.
- Frontend history view now displays completed tasks with a distinct
  text color (`var(--vscode-testing-iconPassed)`).

Enhance UI for child tasks in history:
- Child task entries are now more compact, with reduced padding.
- Token and cost information is omitted for child tasks to save space.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
- Modifies task saving logic to prioritize an existing `parent_task_id`
  from storage, preventing it from being overwritten. A new
  `parent_task_id` is set only if none exists in the stored `HistoryItem`.

- Resolves an issue where new tasks were not appearing in history.
  The `getTaskWithId` method would throw a "Task not found" error for
  new tasks, halting the save process. This error is now handled
  gracefully, allowing new tasks to be correctly added to history.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
This commit introduces several enhancements to the task history UI:

- Refactored the task item display into a reusable `TaskItemHeader` component
  for consistent rendering of task metadata and action buttons.
- Standardized the appearance of action icons (Copy, Export, Delete, Expand/Collapse All)
  for size, color, and opacity.
- Implemented a toggle button (`codicon-list-tree`) to recursively expand and
  collapse all child tasks within a parent task.
- Adjusted spacing and layout for a more compact and visually consistent header.
- Ensured task size (using `prettyBytes`) is displayed for all tasks in the header.
- Removed parentheses from metadata displays (tokens, cost, cache) for a cleaner look.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
This commit implements several key improvements to the task history view:

- Hoisted task item expansion state (`expandedItems`, `bulkExpandedRootItems`)
  and control logic into the `useTaskSearch` hook. This resolves issues
  with `react-virtuoso` where item expansion state was lost upon scrolling
  and unmounting/remounting of virtualized items.
- `TaskDisplayItem` now receives its expansion state and toggle handlers as
  props, simplifying its internal logic.
- Refactored the task item display into a reusable `TaskItemHeader`
  component for consistent rendering of task metadata and action buttons.
- Standardized the appearance of action icons (Copy, Export, Delete,
  Expand/Collapse All) for size, color, and opacity.
- Implemented a toggle button (`codicon-list-tree`) to recursively expand
  and collapse all child tasks within a parent task, with state managed
  by the hoisted logic.
- Adjusted spacing and layout for a more compact and visually consistent
  header.
- Ensured task size (using `prettyBytes`) is displayed for all tasks.
- Removed parentheses from metadata displays (tokens, cost, cache).
- Corrected ESLint `exhaustive-deps` warnings in `useTaskSearch`.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Adjusted padding and margins in the HistoryView component to create a more compact display of task items.
- Standardized vertical padding for all task items.
- Minimized space between task headers and their content.
- Removed extraneous padding within the task item header.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
- Increased horizontal gap between metadata items in the task header.
- Set action buttons in the task header to 50% opacity, transitioning to 100% on hover.
- Updated CopyButton and ExportButton components to accept and apply a className prop, resolving TypeScript errors.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
@KJ7LNW KJ7LNW force-pushed the hierarchical-task-history branch from 4e5d3d2 to 5a9e4b5 Compare May 17, 2025 05:24
Eric Wheeler added 4 commits May 16, 2025 22:44
When a task is deleted, ensure its child tasks are correctly reparented
to the deleted task's own parent. This change also consolidates
the task history update into a single operation.

This addresses an issue where the UI update for reparenting and
deletion could appear delayed by ensuring all modifications to the
task list are processed together before the UI is refreshed.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
When a parent task in the history view is bulk-expanded,
newly added child tasks will now automatically inherit this
expanded state. This ensures that the visibility of new
sub-tasks aligns with the user's current view settings for
the parent, providing a more consistent and intuitive user
experience when navigating hierarchical task histories.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Refactors state update logic to ensure that when task history
is modified (e.g., a new task is created or status changes),
all active ClineProvider instances (sidebar and editor tabs)
receive the updated state and refresh their UI.

The `postStateToWebview()` call is removed from `Task.addToClineMessages()`
and is now handled within `ClineProvider.updateTaskHistory()`, which
iterates over all active instances to broadcast the new state.
This guarantees timely UI updates across all open views.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
…ively

When a new child task (or any of its descendants) is added to the
history view, its initial expansion state will now correctly respect
the 'bulk-expanded' status of its parent or any higher ancestor.

If an ancestor is bulk-expanded, the new task and its own children
will also be expanded automatically. This ensures a consistent and
intuitive user experience when navigating hierarchical task histories,
particularly when new sub-tasks are created under an already expanded
parent tree.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Draft / In Progress] to TEMP in Roo Code Roadmap May 26, 2025
@daniel-lxs daniel-lxs moved this from TEMP to PR [Needs Review] in Roo Code Roadmap May 26, 2025
@hannesrudolph hannesrudolph moved this from PR [Needs Review] to TEMP in Roo Code Roadmap May 26, 2025
@hannesrudolph hannesrudolph moved this from TEMP to PR [Needs Review] in Roo Code Roadmap May 26, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Preliminary Review] to PR [Draft / In Progress] in Roo Code Roadmap May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: PR [Draft / In Progress]
Development

Successfully merging this pull request may close these issues.

2 participants
0