name: image-normalize-persist-atomic
description: >-
  Fix 4: pasted images persist atomically into the session store and
  leave no `*.tmp` orphans behind, even when multiple images are pasted
  in quick succession.
terminal:
  rows: 40
  cols: 120
mock:
  response: "SCRIPTED_IMAGE_RESPONSE received image attachments."
  fixture_images:
    - name: img_a
      extension: png
    - name: img_b
      extension: png
    - name: img_c
      extension: png
steps:
  - action: wait_for_text
    text: Quit
    timeout_ms: 20000
  - action: paste_image_paths
    images: [img_a]
  - action: assert_contains
    text: "Image #1"
  - action: paste_image_paths
    images: [img_b]
  - action: assert_contains
    text: "Image #2"
  - action: paste_image_paths
    images: [img_c]
  - action: assert_contains
    text: "Image #3"
  - action: keys
    keys: "<Right>"
  - action: keys
    keys: "<Esc>"
  - action: drop_text_prompt
    text: " Describe the images."
  - action: keys
    keys: "<Enter>"
  - action: wait_for_text
    text: SCRIPTED_IMAGE_RESPONSE
    timeout_ms: 30000
  - action: assert_chat_completion
  - action: assert_request_image_count
    min: 3
  # Fix 4: persist_to_session is atomic — no leftover *.tmp files.
  - action: assert_no_temp_artifacts
  - action: screenshot
    name: persist-atomic
    note: Three images pasted and persisted with no .tmp orphans left behind.
  - action: assert_not_contains
    text: panicked
