bug: Stage 1 CGATS Dataset Import invokes Save Dialog and leaves uninitialized target state #211

Closed
opened 2026-09-06 12:35:16 +01:00 by gronod · 1 comment
Owner

Summary

In Stage 1 (Generate Target), clicking "Import Dataset..." (btn-import-dataset) erroneously invokes select_target_file, opening a "Save Target File (.ti1)" dialog instead of an "Open File" dialog for measurement datasets (.ti3, .txt, .cgats, .csv). Additionally, importing does not initialize wizardState.basename or cwd if they are currently blank, leaving Stage 4 profiling in a broken state after navigation.

Details & Root Cause

In src/js/cgats_interop.js (lines 23–45):

async handleImport() {
  try {
    const filePath = await invoke('select_target_file');
    if (!filePath) return;

    const summary = await invoke('import_measurement_dataset', {
      filePath,
      targetCwd: this.appState.cwd,
      targetBasename: this.appState.basename,
    });

    this.appState.showNotice(`Successfully imported dataset (${summary.patch_count} patches)`, 'success');
    
    await this.appState.updateGating();
    this.appState.currentStage = 4;
    this.appState.applyStageDOM(4);
  } catch (e) {
    this.appState.showNotice(`Failed to import dataset: ${e}`, 'error');
  }
}
  1. select_target_file in src-tauri/src/commands.rs executes builder.save_file() configured with .add_filter("ArgyllCMS Target", &["ti1"]).
  2. this.appState.cwd and this.appState.basename are empty strings if the user has not previously entered a target name in Stage 1. Calling import_measurement_dataset with empty strings fails or outputs .ti3 into the current working directory, and wizardState.setTarget is never called. When jumping to Stage 4, profileBasename is empty and run_colprof cannot locate the target.
  3. cgats_interop.js also attaches a click listener to btn-export-dataset, which is not present in src/index.html.

Steps to Reproduce

  1. Launch ICCery (starts on Stage 1).
  2. Click "Import Dataset...".
  3. Notice the native dialog is a file SAVE dialog prompting for a .ti1 target name rather than an OPEN dialog for existing CGATS/TI3 data.
  4. If a file is selected, the application navigates to Stage 4 with an empty profile basename.

Proposed Remediation

  1. Add a Tauri command select_dataset_file in src-tauri/src/commands.rs using app.dialog().file().add_filter("Measurement Dataset", &["ti3", "txt", "cgats", "csv"]).pick_file(...).
  2. Register select_dataset_file in src-tauri/src/lib.rs.
  3. In cgats_interop.js, call select_dataset_file, derive default basename and cwd from the chosen file path if appState.cwd/appState.basename are empty, call wizardState.setTarget(basename, cwd) upon successful import, and remove or implement the missing export button.
### Summary In Stage 1 (Generate Target), clicking "Import Dataset..." (`btn-import-dataset`) erroneously invokes `select_target_file`, opening a "Save Target File (.ti1)" dialog instead of an "Open File" dialog for measurement datasets (`.ti3`, `.txt`, `.cgats`, `.csv`). Additionally, importing does not initialize `wizardState.basename` or `cwd` if they are currently blank, leaving Stage 4 profiling in a broken state after navigation. ### Details & Root Cause In `src/js/cgats_interop.js` (lines 23–45): ```javascript async handleImport() { try { const filePath = await invoke('select_target_file'); if (!filePath) return; const summary = await invoke('import_measurement_dataset', { filePath, targetCwd: this.appState.cwd, targetBasename: this.appState.basename, }); this.appState.showNotice(`Successfully imported dataset (${summary.patch_count} patches)`, 'success'); await this.appState.updateGating(); this.appState.currentStage = 4; this.appState.applyStageDOM(4); } catch (e) { this.appState.showNotice(`Failed to import dataset: ${e}`, 'error'); } } ``` 1. `select_target_file` in `src-tauri/src/commands.rs` executes `builder.save_file()` configured with `.add_filter("ArgyllCMS Target", &["ti1"])`. 2. `this.appState.cwd` and `this.appState.basename` are empty strings if the user has not previously entered a target name in Stage 1. Calling `import_measurement_dataset` with empty strings fails or outputs `.ti3` into the current working directory, and `wizardState.setTarget` is never called. When jumping to Stage 4, `profileBasename` is empty and `run_colprof` cannot locate the target. 3. `cgats_interop.js` also attaches a click listener to `btn-export-dataset`, which is not present in `src/index.html`. ### Steps to Reproduce 1. Launch ICCery (starts on Stage 1). 2. Click "Import Dataset...". 3. Notice the native dialog is a file SAVE dialog prompting for a `.ti1` target name rather than an OPEN dialog for existing CGATS/TI3 data. 4. If a file is selected, the application navigates to Stage 4 with an empty profile basename. ### Proposed Remediation 1. Add a Tauri command `select_dataset_file` in `src-tauri/src/commands.rs` using `app.dialog().file().add_filter("Measurement Dataset", &["ti3", "txt", "cgats", "csv"]).pick_file(...)`. 2. Register `select_dataset_file` in `src-tauri/src/lib.rs`. 3. In `cgats_interop.js`, call `select_dataset_file`, derive default basename and cwd from the chosen file path if `appState.cwd`/`appState.basename` are empty, call `wizardState.setTarget(basename, cwd)` upon successful import, and remove or implement the missing export button.
gronod added the Kind/Bug
Priority
High
2
labels 2026-09-06 12:35:16 +01:00
Author
Owner

Resolved in commit 9f2ff01 on development (released as part of v0.8.3).

  • Implemented select_dataset_file Tauri command in src-tauri/src/commands.rs with filters for Measurement Dataset (*.ti3, *.txt, *.cgats, *.csv).
  • Registered select_dataset_file in the Tauri invoke handler in src-tauri/src/lib.rs.
  • Updated src/js/cgats_interop.js to invoke select_dataset_file, extract the parent directory and file stem, synchronize targetCwd and targetBasename in wizardState.setTarget(...), update Stage 1 input fields (#targetBasename and #selectedPathDisplay), and guard top-level globals for safe module evaluation.
  • Successfully verified on development: all 91 Rust unit tests and 68 frontend unit tests passing. Bumped version to v0.8.3.
Resolved in commit `9f2ff01` on `development` (released as part of `v0.8.3`). - Implemented `select_dataset_file` Tauri command in `src-tauri/src/commands.rs` with filters for `Measurement Dataset (*.ti3, *.txt, *.cgats, *.csv)`. - Registered `select_dataset_file` in the Tauri invoke handler in `src-tauri/src/lib.rs`. - Updated `src/js/cgats_interop.js` to invoke `select_dataset_file`, extract the parent directory and file stem, synchronize `targetCwd` and `targetBasename` in `wizardState.setTarget(...)`, update Stage 1 input fields (`#targetBasename` and `#selectedPathDisplay`), and guard top-level globals for safe module evaluation. - Successfully verified on `development`: all 91 Rust unit tests and 68 frontend unit tests passing. Bumped version to `v0.8.3`.
Sign in to join this conversation.