Skip to content

Verify cross-task dirty buffer safety after a refused rollback #2436

Open

Description

@coderabbitai

Summary

Investigate whether a later task can save unapproved streamed content after a prior task's rollback fails and the prior task is disposed.

The earlier review found that a rollback failure could leave a dirty document open, and that a later DiffViewProvider.open() could save a dirty document. This cross-task risk predates PR #1930; it has not been verified with a two-task test. PR #1930 does not contain the disposal release discussed below.

The requester identifies the later stacked unit, PR #2435, as the relevant place to assess the disposal drop. At commit 4baf005673f482d9d911de87ff0890644765193a, src/core/task/Task.ts calls writeToFileTool.releaseTaskRollbackFailure(this) during disposal, and src/core/tools/WriteToFileTool.ts defines the release. src/integrations/editor/DiffViewProvider.ts manages the editor buffer and its opening and rollback behavior.

Required work

  • Add a test with two distinct tasks that share a document. Make task A's rollback fail or be refused, keep the document dirty, and dispose task A. Then have task B open the same path.
  • Check whether task B saves the unapproved streamed content before approval. Use a document double or extension-host coverage that preserves the dirty state across task disposal.
  • If the test confirms the risk, add protection at the appropriate cross-task boundary and a regression test. Do not retain a disposed task solely to keep a per-task marker alive. Keep protection until safe recovery or an explicit user decision makes it unnecessary.

Acceptance criteria

  • The test records the buffer and persisted contents before and after task B opens the path, and distinguishes unapproved streamed content from the original content.
  • The test demonstrates that task B cannot silently persist unapproved content before approval, or documents why the scenario cannot occur with the real document lifecycle.
  • If a fix is required, tests cover recovery and cleanup of its protection without retaining disposed task state.

Context

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