From adb8d3f91404af1dc65442f5add7239a1f27bff7 Mon Sep 17 00:00:00 2001 From: flemming-it Date: Fri, 17 Jul 2026 01:05:10 +0200 Subject: [PATCH] feat(flows): native file dialog for flow file inputs Wires the editor's new onPickFile host callback to file_picker (withData: the editor receives name + bytes, never a raw path). Pins chain_studio_flow_editor to v0.23.0. No more typing absolute paths to feed a flow a file. Signed-off-by: flemming-it --- lib/pages/flows.dart | 15 +++++++++++++++ pubspec.lock | 2 +- pubspec.yaml | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/pages/flows.dart b/lib/pages/flows.dart index d11bf13..f1bd9c4 100644 --- a/lib/pages/flows.dart +++ b/lib/pages/flows.dart @@ -11,6 +11,7 @@ // need to know what's inside the editor any more. import 'package:chain_studio_flow_editor/chain_studio_flow_editor.dart'; +import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import '../data/error_presentation.dart'; @@ -95,6 +96,17 @@ class _FlowsPageState extends State { /// Hub's install API and returns the refreshed capability /// list so the editor can re-analyze without waiting for the /// parent widget rebuild. + /// Native picker for a flow file input. `withData` loads the + /// bytes directly so the editor never touches the path itself + /// (sandbox-friendly: the picker grants access to exactly the + /// chosen file). + Future _pickFlowInputFile() async { + final picked = await FilePicker.pickFiles(withData: true); + final f = picked?.files.single; + if (f == null || f.bytes == null) return null; + return PickedFileData(fileName: f.name, bytes: f.bytes!); + } + Future?> _onInstallCapability(String capability) async { // The analyzer hands us the full `use:` value (e.g. `debug.echo@^0`). // The hub resolves install sources by bare capability name; the @@ -167,6 +179,9 @@ class _FlowsPageState extends State { onInstallCapability: _onInstallCapability, onAddModuleSource: _onAddModuleSource, activeProject: Workspace.instance.activeSlug, + // Native file dialog for the Run tab's file inputs — + // nobody should have to type an absolute path by hand. + onPickFile: _pickFlowInputFile, // The file wins for the run; accepting the switch only // aligns the workspace view to the file's project. onSwitchToFileProject: (slug) => diff --git a/pubspec.lock b/pubspec.lock index 720d556..d9b5bd8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -46,7 +46,7 @@ packages: path: "../fai_chain_studio_flow_editor" relative: true source: path - version: "0.22.0" + version: "0.23.0" characters: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index edc2065..a8f2fd2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,7 +45,7 @@ dependencies: # Tag-pinned so a CI (override-free) build is reproducible and an # editor push can't retroactively change what a Studio release # builds against. Bump this in lockstep with the editor tag. - ref: v0.22.0 + ref: v0.23.0 dev_dependencies: flutter_test: