Feature: Restore interactive flow

  The restore flow guides the user through selecting a snapshot,
  optionally choosing specific files, setting a target directory,
  and choosing overwrite behaviour. Each step is skipped when the
  resolved configuration already provides the needed value.

  Background:
    Given the user has selected the "restore" command

  Rule: A snapshot is selected from the repository or entered manually

    Scenario: Snapshots loaded from the repository
      Given the repository is accessible
      When the snapshot selection screen is reached
      Then a spinner is shown while snapshots are fetched
      And the fetched snapshots are presented in a filterable list

    Scenario: Snapshot listing fails
      Given the repository is not accessible
      When the snapshot selection screen is reached
      Then an error notice is displayed
      And the user is offered a text input for manual snapshot ID entry

    Scenario: No snapshots in the repository
      Given the repository contains no snapshots
      When the snapshot selection screen is reached
      Then a notice indicates the repository is empty
      And the user is offered a text input for manual snapshot ID entry

    Scenario: Snapshot ID already provided
      Given a snapshot ID is already resolved
      Then the snapshot selection screen is not shown

  Rule: The user may select specific files to restore from the snapshot

    Scenario: File listing loaded from the snapshot
      Given a snapshot has been selected
      When the file selection screen is reached
      Then a spinner is shown while the file listing is fetched
      And a file picker is presented for the snapshot's contents

    Scenario: Full restore when all files are selected
      Given the file picker is showing
      When the user confirms with all files selected
      Then no include paths are added to the restore command

    Scenario: Partial restore when specific files are selected
      Given the file picker is showing
      When the user selects specific files and confirms
      Then the selected paths are added as include paths

    Scenario: File listing fetch fails
      Given a snapshot has been selected
      When the file listing cannot be fetched
      Then a notice is displayed
      And the file picker is skipped
      And the flow proceeds with a full restore

    Scenario: File selection already configured
      Given include paths are already resolved
      Then the file selection screen is not shown

  Rule: A target directory is specified for the restored files

    Scenario: Target directory prompted
      Given no target directory is resolved
      When the target directory screen is reached
      Then a text input prompts for the restore destination

    Scenario: Target directory already configured
      Given a target directory is already resolved
      Then the target directory screen is not shown

  Rule: The overwrite behaviour is chosen before restoring

    Scenario: Overwrite behaviour prompted
      Given no overwrite behaviour is resolved
      When the overwrite screen is reached
      Then a selector presents the available overwrite options

    Scenario: Overwrite behaviour already configured
      Given an overwrite behaviour is already resolved
      Then the overwrite screen is not shown
