Skip to content

Prevent in-flight task messages from recreating deleted tasks #2376

Open

Description

@coderabbitai

Summary

Investigate the shared task message lifecycle when a message write is already in progress during task disposal and deletion.

At PR #1403 head 1471730e6d22d1817e113c3df7d3a11a3ae273db, Task.addToClineMessages() awaits postStateToWebviewThrottled() before emitting the message event and calling saveClineMessages(). If disposal occurs during that await and another panel deletes the task, a late persistence operation may recreate the deleted task. The post-save diagnostics tail has cancellation guards before say() starts, but those guards cannot stop a say() already in progress.

Affected areas

  • src/core/task/Task.ts: say(), ask(), addToClineMessages(), and task disposal.
  • src/core/webview/ClineProvider.ts and task persistence/deletion paths.

Acceptance criteria

  • Define and implement the disposal-versus-persistence contract at the appropriate shared boundary. Prevent a late in-flight message write from recreating a deleted task.
  • Add a regression test that pauses the state post, disposes and deletes the task, then releases the post and checks that the task is not recreated.
  • Verify normal say() and ask() event and persistence behavior, including unanswered ask ordering, remains correct.

Requested by @easonLiangWorldedtech.

Context: #1403
Review discussion: #1403 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions