@session
Feature: Session CLI uncovered branches
  As a developer
  I want full branch coverage for session CLI commands
  So that edge cases are tested

  Scenario: session cli branch - _get_session_service constructs service when _service is None
    Given session cli branch the module-level _service is None
    When session cli branch I call _get_session_service with mocked container
    Then session cli branch a PersistentSessionService is returned

  Scenario: session cli branch - _reset_session_service sets _service to None
    Given session cli branch the module-level _service holds a mock
    When session cli branch I call _reset_session_service
    Then session cli branch the module-level _service is None again

  Scenario: session cli branch - create command catches SessionNotFoundError
    Given session cli branch a mock session service that raises SessionNotFoundError on create
    When session cli branch I invoke the create command
    Then session cli branch the exit code is 1
    And session cli branch the output contains "Error:"

  Scenario: session cli branch - show command with no messages
    Given session cli branch a mock session service returning a session with no messages
    When session cli branch I invoke the show command for that session
    Then session cli branch the exit code is 0
    And session cli branch the output contains "Session Summary"
    And session cli branch the output does not contain "Recent Messages"

  Scenario: session cli branch - show command with linked plan ids
    Given session cli branch a mock session service returning a session with linked plans
    When session cli branch I invoke the show command for the linked-plans session
    Then session cli branch the exit code is 0
    And session cli branch the output contains "Linked Plans"

  Scenario: session cli branch - show command with long message content truncated
    Given session cli branch a mock session service returning a session with a long message
    When session cli branch I invoke the show command for the long-message session
    Then session cli branch the exit code is 0
    And session cli branch the output contains "Recent Messages"

  Scenario: session cli branch - delete command aborted via confirmation prompt
    Given session cli branch a mock session service for delete
    When session cli branch I invoke the delete command without --yes and answer no
    Then session cli branch the delete is aborted

  Scenario: session cli branch - export command catches SessionExportError
    Given session cli branch a mock session service that raises SessionExportError on export
    When session cli branch I invoke the export command
    Then session cli branch the export exit code is 1
    And session cli branch the export output contains "Export error:"

  Scenario: session cli branch - tell command with stream=True
    Given session cli branch a mock session service for tell
    When session cli branch I invoke the tell command with --stream
    Then session cli branch the exit code is 0
    And session cli branch the streamed output contains the assistant response
