@plan-diff-worktree
Feature: Plan diff shows worktree branch changes (#9231)
  Verifies that plan diff displays the actual file changes from the
  worktree branch created during plan execute, falling back to
  changeset-based diff when no worktree branch exists.

  Background:
    Given the plan-diff in-memory database is initialized

  Scenario: diff_against_head returns diff when worktree branch exists
    Given a temp git repo with a worktree branch for plan "01TESTDIFF00000000000000" for pdt
    And a file "hello.py" is changed on the worktree branch for pdt
    When I call diff_against_head for plan "01TESTDIFF00000000000000" for pdt
    Then the diff output should contain "hello.py" for pdt
    And the diff output should not be None for pdt

  Scenario: diff_against_head returns None when no branch exists
    Given a temp git repo without a worktree branch for pdt
    When I call diff_against_head for plan "01TESTDIFFNO000000000000" for pdt
    Then the diff output should be None for pdt

  Scenario: _get_worktree_diff returns diff via service resolution
    Given a temp git repo with a worktree branch for plan "01TESTDIFFSVC00000000000" for pdt
    And a file "app.py" is changed on the worktree branch for pdt
    And a mocked service that resolves the git resource for pdt
    When I call _get_worktree_diff for plan "01TESTDIFFSVC00000000000" for pdt
    Then the diff output should contain "app.py" for pdt

  Scenario: _get_worktree_diff returns None when no linked resources
    Given a mocked service with no linked resources for plan diff for pdt
    When I call _get_worktree_diff for plan "01TESTDIFFNONE0000000000" for pdt
    Then the diff output should be None for pdt
