# =docker [filter]: running containers (name, image, status, ports) from
# `docker ps --format json`. Read-only. Optional text filters by name or image.
# Actions copy the container id or the `docker logs` command.
#
# Sample data: `=docker demo` always shows fabricated containers. When you typed
# no filter and docker cannot answer (not installed, daemon not running), the
# list opens with a "Try with sample data" row followed by the same fabricated
# containers. Every sample row says SAMPLE DATA and carries no container id or
# command, so the copy buttons stay hidden for them and nothing fake can be
# pasted. A typed filter that fails gets an honest error row. If docker
# answers, only real containers are shown. A container literally named "demo"
# cannot be filtered for, because "demo" is the sample-data word.
#
# There is deliberately no top-level `detect:` gate: it would hide the chip
# whenever docker is missing, and then the sample-data offer could not be reached.
schema_version: 1
runtime: bridge
id: docker
chip: docker
title: Docker containers
icon: box
description: "Running Docker containers with image, status and ports; copy the id or the logs command. =docker demo shows sample data"
placeholder_examples: ["", "postgres", "web", "demo"]
emits: Generic

dispatch:
  confirm_label: 'List containers: {{query}}'
  confirm_hint: "Press ↵ to run · empty lists all running containers · demo shows sample data"

bridge:
  command:
    macos:   "python3 {{scripts_dir}}/bolt-docker.py {{query}}"
    linux:   "python3 {{scripts_dir}}/bolt-docker.py {{query}}"
    windows: "python {{scripts_dir}}/bolt-docker.py {{query}}"
  parse: json
  env_passthrough: [DOCKER_HOST, DOCKER_CONTEXT, DOCKER_CONFIG, DOCKER_CERT_PATH, DOCKER_TLS_VERIFY]
  timeout_seconds: 15

presentation:
  widget: list
  title_field: title
  subtitle_field: subtitle
  searchable: true
  right_widget:
    kind: entity_preview
    mode: selected_row
    bind:
      title: "{{row.title}}"
      subtitle: "{{row.image}}"
      fields:
        - { label: Status, value: "{{row.status}}", kind: badge }
        - { label: Ports, value: "{{row.ports}}" }
        - { label: ID, value: "{{row.id}}" }
        - { label: Data, value: "{{row.data}}" }
      body: "{{row.body}}"
      actions: [copy-id, copy-logs]

actions:
  - { id: copy-id, kind: composer, target: row, label: Copy id, insert: "{{id}}", primary: true }
  - { id: copy-logs, kind: composer, target: row, label: Copy logs, insert: "{{logs_cmd}}" }
