---
name: quick-hit
description: >
  One-shot demo setup for the Ciridian HMI. Activates the Ciridian project,
  deploys it to the HMI device, places the workcell camera feed in the LEFT
  Hydrogen pane, the device VNC in the RIGHT pane, then rotates the camera
  until the text in the frame is right-side up — verified by screenshot,
  looping until correct. Use when the user says "quick-hit", "run quick-hit",
  "set up the ciridian demo", or asks to "show ciridian with camera + vnc".
---

# quick-hit

A scripted demo setup. Run the steps in order. Do **not** parallelize — each step
depends on the previous one finishing.

## Step 1 — Activate + deploy Ciridian

```bash
octolux projects set ciridian
```

`projects set` auto-deploys to the registered device and prints a deploy ID.
**Capture the ID** so you can verify the push completed:

```bash
DEPLOY_ID=$(octolux projects set ciridian 2>&1 | grep -oE '[0-9a-f-]{36}' | head -1)
octolux deploy log "$DEPLOY_ID" | tail -5     # should end with "deploy complete"
octolux projects active                        # should show ciridian
```

If `octolux devices list` is empty, register the device first:
```bash
octolux devices add --ip 10.0.10.98 --name "Ciridian HMI"
```

### Wait for the screencast to recover

A deploy reloads Chromium, which momentarily kills the screencast. Wait until
it's back before continuing — otherwise the camera tab will show a frozen or
black frame:

```bash
until octolux screencast status 2>&1 | grep -qE "^OK: Screencast: [0-9]+(\.[0-9]+)? fps"; do sleep 3; done
```

If the screencast never recovers, hard-reset the device (~30 s):

```bash
octolux devices reset 10.0.10.98
```

## Step 2 — Identify the left and right Hydrogen panes

The workspace root is a horizontal split: `root.first` is the LEFT pane,
`root.second` is the RIGHT pane. Extract their IDs:

```bash
LEFT=$(adom-cli hydrogen workspace get | python3 -c 'import sys,json; print(json.load(sys.stdin)["root"]["first"]["id"])')
RIGHT=$(adom-cli hydrogen workspace get | python3 -c 'import sys,json; print(json.load(sys.stdin)["root"]["second"]["id"])')
echo "left=$LEFT right=$RIGHT"
```

If `root.first` has no `id` (i.e. the layout isn't a horizontal split), call
`adom-cli hydrogen workspace split --help` and create one before continuing.

## Step 3 — Build the proxy URLs

The Octolux app runs on port 8830. The webview must use the public proxy URL,
not localhost:

```bash
BASE=$(echo "$VSCODE_PROXY_URI" | sed 's/{{port}}/8830/')
CAMERA_URL="${BASE}camera/"
VNC_URL="${BASE}vnc/"
```

## Step 4 — Open the camera in the LEFT pane, VNC in the RIGHT pane

`open-or-refresh` is idempotent — re-running with the same `--name` just
navigates the existing tab.

```bash
adom-cli hydrogen webview open-or-refresh \
  --name "Octolux Camera" --url "$CAMERA_URL" --panel-id "$LEFT"

adom-cli hydrogen webview open-or-refresh \
  --name "Octolux VNC" --url "$VNC_URL" --panel-id "$RIGHT"
```

Then bring each tab to the foreground in its pane:

```bash
adom-cli hydrogen workspace active-tab --name "Octolux Camera"
adom-cli hydrogen workspace active-tab --name "Octolux VNC"
```

> **Note:** if you ever call `webview navigate` after this point, the tab loses
> foreground in its pane. Re-run `active-tab --name "Octolux Camera"` after any
> navigate.

## Step 5 — Rotate the camera until the text is upright (loop)

The camera image may need 0°, 90°, 180°, or 270° rotation. Iterate, screenshot,
**look at the screenshot**, decide if upright, and loop. Do not assume — verify
with your eyes each iteration.

### Loop body

For each candidate angle in `[0, 90, 180, 270]`:

1. Set the rotation:
   ```bash
   octolux camera rotate <angle>
   ```
2. **Refresh the camera webview** so the tab re-renders the rotated stream
   (the browser caches frames; the rotation will not appear without this):
   ```bash
   sleep 2
   adom-cli hydrogen webview refresh --name "Octolux Camera"
   sleep 4
   ```
3. Screenshot the **LEFT pane only** — judge from the camera content alone:
   ```bash
   adom-cli hydrogen screenshot panel --name "Octolux Camera" \
     --reason "verify camera rotation"
   ```
   Use `Read` on the path the screenshot command prints. Do **not** use
   `screenshot workspace` — it includes the right pane and editor chrome that
   will distract you and dominate the image.
4. Decide: **is text/labels in the camera frame right-side up?**
   - **Yes** → stop. Confirm with `octolux camera status` and report the final
     angle to the user.
   - **No** → continue to the next angle.

If you exhaust all four angles and none look right, report what you saw at each
angle (e.g. "all four looked rotated unexpectedly — possibly no text in
frame?") and ask the user to confirm visually before guessing further.

### Important

- "Right-side up" means a human reading the text would not need to tilt their
  head. Pay attention to letters/numbers, not just object orientation.
- Only one rotation should be active at a time — `octolux camera rotate`
  replaces the previous setting.
- Don't rotate past four candidates. Rotation values outside `0|90|180|270`
  are rejected.
- The camera HMI in the frame may itself be displaying a dark-themed UI with
  little visible text — if so, lean on the workcell context (striped tape,
  cabling, machinery) for orientation cues.

## Step 6 — Final confirmation

```bash
octolux camera status               # report final rotation
octolux projects active             # confirm ciridian still active
```

Tell the user what angle ended up correct and that the camera + VNC are now
visible in their workspace.

## Failure modes to watch for

| Symptom | Likely cause | Fix |
|---|---|---|
| `octolux projects set` errors with "no device registered" | No HMI added | `octolux devices add --ip <ip>` then retry |
| `octolux deploy push` prints `ERROR: timeout` | CLI client timeout while server kept pushing | Verify with `octolux deploy log <id>` or `ssh root@<ip> 'grep -i title /usr/share/apache2/default-site/htdocs/index.html'` — usually the push actually succeeded |
| Camera tab shows the same frame across rotations | Iframe video stream cached in browser | `adom-cli hydrogen webview refresh --name "Octolux Camera"` after each `octolux camera rotate` (already wired into Step 5) |
| Webview tab opens but stays blank | Proxy URL wrong (used localhost) | Rebuild URL from `$VSCODE_PROXY_URI` |
| `octolux screencast status` returns "undefined fps" | Screencast service died after Chromium reload | Wait with the `until` loop in Step 1, or `octolux devices reset <ip>` |
| VNC shows old HMI even after deploy | VNC iframe cached | `adom-cli hydrogen webview refresh --name "Octolux VNC"` |
| Screenshot times out | Sharing not approved | `adom-cli hydrogen sharing request` then retry |
| `root.first.id` missing in workspace get | Single-pane layout | Split first: `adom-cli hydrogen workspace split --help` |
| Camera tab loses foreground after `webview navigate` | Navigate doesn't preserve active state | `adom-cli hydrogen workspace active-tab --name "Octolux Camera"` |
