fix(chartread): enable ARGYLL_NOT_INTERACTIVE for stdin piping & fix instlist JSON parsing #134

Closed
opened 2026-08-29 13:21:24 +01:00 by gronod · 0 comments
Owner

Bug Description

In Stage 3 (Measure Target / chartread):

  1. Instrument Autodetection Failure: The instlist command outputs JSON formatted devices ({"event": "instruments", "devices": [{"port": 1, "name": "libusb0-0001 (X-Rite i1 Pro 2)", "type": "X-Rite i1 Pro 2"}]}), but src/js/chartread.js only parses legacy plain-text regex (1: 'i1Pro' on 'USB'), failing to populate detected instruments.
  2. Calibrate Button Ineffective (Ignored Stdin / Console Keystroke Block): When starting chartread, Argyll prompts Place the instrument on its reflective white reference S/N ..., and then hit any key to continue. Clicking the [✓ Calibrate] button does not advance the process because on Windows, ArgyllCMS tools by default read interactive keystrokes directly from the console buffer (_getch() / ReadConsoleInput()), completely bypassing the piped standard input stream (stdin).

Root Cause Analysis

  1. Console vs Pipe Mode in ArgyllCMS: Without the environment variable ARGYLL_NOT_INTERACTIVE=1, Argyll tools poll raw Windows console events rather than reading piped stdin. In headless/GUI child processes with CREATE_NO_WINDOW and piped stdin, input sent via stdin.write_all() is never consumed by Argyll.
  2. JSON Parser Missing in chartread.js: instlist in our Argyll build outputs JSON events (event === "instruments"). The frontend regex parser does not decode the JSON structure.

Steps to Reproduce

  1. Open Stage 3 and click ↻ Detect -> Dropdown displays "No instruments found via instlist" despite a connected i1 Pro 2.
  2. Click Start Measurement -> chartread spawns and outputs white reference calibration prompt.
  3. Click ✓ Calibrate -> Nothing happens; chartread remains blocked waiting for a console keypress.

Remediation & Implementation Details

  1. Backend (src-tauri/src/process_manager.rs):
    • Add command.env("ARGYLL_NOT_INTERACTIVE", "1"); to ProcessManager::spawn so all Argyll sub-processes switch from raw console polling to standard piped stdin stream reads.
  2. Frontend (src/js/chartread.js):
    • Update detect_instruments stdout listener to accumulate output and parse JSON devices: [{ port, name, type }] (with fallback to legacy regex line matching).
    • Update calibration prompt matchers to detect white reference, place the instrument, and hit any key to continue.
    • Ensure send_stdin cleanly flushes " \n" to advance calibration and strip read prompts.
### Bug Description In Stage 3 (Measure Target / `chartread`): 1. **Instrument Autodetection Failure**: The `instlist` command outputs JSON formatted devices (`{"event": "instruments", "devices": [{"port": 1, "name": "libusb0-0001 (X-Rite i1 Pro 2)", "type": "X-Rite i1 Pro 2"}]}`), but `src/js/chartread.js` only parses legacy plain-text regex (`1: 'i1Pro' on 'USB'`), failing to populate detected instruments. 2. **Calibrate Button Ineffective (Ignored Stdin / Console Keystroke Block)**: When starting `chartread`, Argyll prompts `Place the instrument on its reflective white reference S/N ..., and then hit any key to continue`. Clicking the `[✓ Calibrate]` button does not advance the process because on Windows, ArgyllCMS tools by default read interactive keystrokes directly from the console buffer (`_getch()` / `ReadConsoleInput()`), completely bypassing the piped standard input stream (`stdin`). --- ### Root Cause Analysis 1. **Console vs Pipe Mode in ArgyllCMS**: Without the environment variable `ARGYLL_NOT_INTERACTIVE=1`, Argyll tools poll raw Windows console events rather than reading piped stdin. In headless/GUI child processes with `CREATE_NO_WINDOW` and piped stdin, input sent via `stdin.write_all()` is never consumed by Argyll. 2. **JSON Parser Missing in `chartread.js`**: `instlist` in our Argyll build outputs JSON events (`event === "instruments"`). The frontend regex parser does not decode the JSON structure. --- ### Steps to Reproduce 1. Open Stage 3 and click `↻ Detect` -> Dropdown displays "No instruments found via instlist" despite a connected i1 Pro 2. 2. Click `Start Measurement` -> `chartread` spawns and outputs white reference calibration prompt. 3. Click `✓ Calibrate` -> Nothing happens; `chartread` remains blocked waiting for a console keypress. --- ### Remediation & Implementation Details 1. **Backend (`src-tauri/src/process_manager.rs`)**: - Add `command.env("ARGYLL_NOT_INTERACTIVE", "1");` to `ProcessManager::spawn` so all Argyll sub-processes switch from raw console polling to standard piped stdin stream reads. 2. **Frontend (`src/js/chartread.js`)**: - Update `detect_instruments` stdout listener to accumulate output and parse JSON `devices: [{ port, name, type }]` (with fallback to legacy regex line matching). - Update calibration prompt matchers to detect `white reference`, `place the instrument`, and `hit any key to continue`. - Ensure `send_stdin` cleanly flushes `" \n"` to advance calibration and strip read prompts.
gronod added this to the Milestone 11: Enterprise Colour Workflow (v0.6.0) milestone 2026-08-29 13:21:24 +01:00
Sign in to join this conversation.