feat(editor): graph-pulse on errors + store-aware install / add-source

Three connected improvements to the analyzer-driven diagnostics:

  - **Pulsing halo on broken graph nodes**. Every step / pseudo-
    node (inputs / outputs) carrying an analyzer issue now
    breathes a red (error) or amber (warning) halo on the graph
    tab — operator sees the problem on the canvas without
    flipping to text. Honours prefers-reduced-motion: reduce-
    motion users get a static halo at the same intensity. The
    canvas reads severity via a new `stepIssueSeverity` map on
    FlowEditorController; pseudo-nodes use `__inputs__` /
    `__outputs__` sentinel ids.

  - **Store-aware install button**. The analyzer now takes a
    second closure, `storeCapabilities`, listing what the public
    store can install. Unknown-capability issues only carry the
    "Install …" quick-fix when the bare cap is in that list;
    otherwise the issue carries an "Add source for …" fix
    instead. Resolves the asymmetry the operator reported: the
    Store didn't show `htw.digiscout/onet.lookup` but the editor
    happily offered to install it (and would have failed). The
    install path no longer lies about itself.

  - **Did-you-mean suggestion**. When the unknown cap is within
    edit-distance two of an installed or store cap (different
    spelling — distance-0 stays hidden because that's an install
    case, not a typo), the analyzer emits a `ReplaceLineValueFix`
    suggesting the closest match. Preserves the version
    constraint by reusing the installed spec when present
    (e.g. `text.echi@^0.1` → `text.echo@^0.1`).

New public surface:

  - `AddModuleSourceFix` + `AddModuleSourceCallback`
  - `FlowEditorPage.storeCapabilities` + `onAddModuleSource`
  - `FlowAnalyzer.stepSeverity` + the `kInputsNodeId` /
    `kOutputsNodeId` sentinels
  - `FlowIssueSeverity` enum + `FlowNode.issueSeverity`

Tests:
  - Install fix only when in store
  - AddModuleSourceFix as fallback when not in store
  - Did-you-mean replaces install when a near miss exists
  - stepSeverity populated for both step ids and pseudo-nodes

All 36 editor tests green. Bumped to 0.18.0.

Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
flemming-it 2026-06-09 00:21:48 +02:00
parent f43c1ac6cf
commit efdfa7dd79
10 changed files with 497 additions and 45 deletions

View file

@ -50,7 +50,7 @@ class ReplaceLineValueFix extends QuickFix {
}
/// Ask the host (Studio) to install the named capability via
/// the Hub. The editor delegates to the
/// the Hub's store-backed install. The editor delegates to the
/// [InstallCapabilityCallback] passed into `FlowEditorPage`
/// and reanalyzes the document once the host returns.
@immutable
@ -66,6 +66,28 @@ class InstallCapabilityFix extends QuickFix {
}) : super(label);
}
/// Ask the host to register a new module source for an unknown
/// capability used when the capability isn't in the public
/// store. The host's handler typically prompts the operator
/// for a local path (`fai install --link`) or a URL
/// (`fai install <url>`), then installs and reanalyzes.
///
/// This is the recovery path for private modules: the public
/// store doesn't know about `htw.digiscout/onet-lookup`, but
/// the operator can point the hub at the local clone.
@immutable
class AddModuleSourceFix extends QuickFix {
/// The capability the operator wrote the host uses it to
/// pre-fill its prompt ("Where can `<capability>` be
/// installed from?").
final String capability;
const AddModuleSourceFix({
required this.capability,
required String label,
}) : super(label);
}
/// Host-side install handler signature. Returns the new
/// installed-capability list after the install completes (used
/// by the editor to refresh its analyzer without round-tripping
@ -75,6 +97,13 @@ class InstallCapabilityFix extends QuickFix {
typedef InstallCapabilityCallback =
Future<List<String>?> Function(String capability);
/// Host-side "add module source" handler. Receives the bare
/// capability spec the operator typed; expected to prompt the
/// operator for a local path / URL and then install it.
/// Same return contract as [InstallCapabilityCallback].
typedef AddModuleSourceCallback =
Future<List<String>?> Function(String capability);
/// Hover-tooltip request the controller emits one of these
/// via a ValueNotifier when the pointer enters an issue range,
/// and clears it when the pointer leaves both the range and the