fix: assistant handoff to stepper (incl. disabled launch in galaxy bug) (#1295)#1330
fix: assistant handoff to stepper (incl. disabled launch in galaxy bug) (#1295)#1330frano-m wants to merge 7 commits into
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the assistant → workflow stepper handoff so sequencing accessions and sequencing-source intent (ENA vs upload) survive the boundary and correctly enable “Launch In Galaxy”. It introduces a shared, app-level state container for handoff payloads and updates the stepper to consume and asynchronously resolve ENA accessions into configured sequencing inputs.
Changes:
- Added
WorkflowInputsView/state/reducer + provider, used by the assistant to dispatch{ accessions, sequencingSource }and by the stepper to read/clear per-source state. - Implemented async ENA handoff resolution (
useHandoffSync+ React Query) and sequencing-step utilities to translate array-shaped sequencing selections into file-scalar fields when needed. - Simplified
useConfigureInputsto a pure merge and moved “wipe on assembly change” behavior to the Reference Assembly selection call site viaDEFAULT_CONFIGURED_INPUT.
Reviewed changes
Copilot reviewed 46 out of 46 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/configureWorkflow/sequencingStep/translateForSequencingStep.test.ts | Adds unit coverage for array→scalar translation behavior. |
| tests/configureWorkflow/sequencingStep/deriveInitialView.test.ts | Adds unit coverage for sequencing-step initial toggle derivation. |
| tests/components/assistant/schemaPanel.utils.test.ts | Tests accession extraction + sequencing-source normalization from assistant schema. |
| pages/_app.tsx | Mounts the new WorkflowInputsStateProvider at the app root. |
| app/views/WorkflowsView/components/Workflows/components/Card/card.tsx | Clears assistant-source state when entering the stepper via workflow cards. |
| app/views/WorkflowInputsView/workflowInputsView.tsx | Consumes assistant handoff initial input + runs useHandoffSync; updates step targeting. |
| app/views/WorkflowInputsView/state/types.ts | Defines source-keyed state and context value types. |
| app/views/WorkflowInputsView/state/reducer.ts | Adds reducer wiring for ClearSource/SetSource actions. |
| app/views/WorkflowInputsView/state/provider.tsx | Implements the context provider component. |
| app/views/WorkflowInputsView/state/hooks/UseWorkflowInputsReducer/hook.ts | Wires useReducer to the new reducer/initial state. |
| app/views/WorkflowInputsView/state/hooks/UseSourceState/types.ts | Adds hook return type alias. |
| app/views/WorkflowInputsView/state/hooks/UseSourceState/hook.ts | Adds useSourceState selector with default fallback. |
| app/views/WorkflowInputsView/state/hooks/UseSourceDispatch/types.ts | Defines typed dispatch API for set/clear source actions. |
| app/views/WorkflowInputsView/state/hooks/UseSourceDispatch/hook.ts | Implements useSourceDispatch action helpers. |
| app/views/WorkflowInputsView/state/context.ts | Creates the WorkflowInputsContext with a “dispatch outside provider” throw. |
| app/views/WorkflowInputsView/state/constants.ts | Adds SEQUENCING_SOURCE, SOURCE_KEYS, and default/initial state constants. |
| app/views/WorkflowInputsView/state/actions/types.ts | Defines action union + action-kind enum. |
| app/views/WorkflowInputsView/state/actions/setSource/types.ts | Defines SetSource action/payload types. |
| app/views/WorkflowInputsView/state/actions/setSource/dispatch.ts | Adds SetSource action creator. |
| app/views/WorkflowInputsView/state/actions/setSource/action.ts | Implements reducer helper for SetSource. |
| app/views/WorkflowInputsView/state/actions/clearSource/types.ts | Defines ClearSource action/payload types. |
| app/views/WorkflowInputsView/state/actions/clearSource/dispatch.ts | Adds ClearSource action creator. |
| app/views/WorkflowInputsView/state/actions/clearSource/action.ts | Implements reducer helper for ClearSource (resets to defaults). |
| app/views/WorkflowInputsView/sequencing/utils.ts | Adds helper to find the workflow’s sequencing-step key. |
| app/views/WorkflowInputsView/sequencing/constants.ts | Defines the set of sequencing step keys (array + file-scalar). |
| app/views/WorkflowInputsView/hooks/UseHandoffSync/utils.ts | Adds ENA read-run → configured-input update builder. |
| app/views/WorkflowInputsView/hooks/UseHandoffSync/useHandoffSync.ts | Applies resolved ENA handoff data into configured input (with step translation). |
| app/views/WorkflowInputsView/hooks/UseHandoffSync/query/ena/types.ts | Types the React Query key for ENA handoff queries. |
| app/views/WorkflowInputsView/hooks/UseHandoffSync/query/ena/options/queryFn.ts | Implements queryFn reusing existing ENA fetch utilities. |
| app/views/WorkflowInputsView/hooks/UseHandoffSync/query/ena/hook.ts | Adds useHandoffEnaQuery driven by assistant-source accessions. |
| app/views/WorkflowInputsView/hooks/UseConfigureInputs/useConfigureInputs.ts | Simplifies configure-input state updates to a pure merge; supports initial state. |
| app/views/WorkflowInputsView/hooks/UseConfigureInputs/constants.ts | Adds DEFAULT_CONFIGURED_INPUT used to explicitly wipe config state. |
| app/views/WorkflowInputsView/hooks/UseAssistantHandoff/utils.ts | Derives initial configured input + handoff flag from assistant-source state. |
| app/views/WorkflowInputsView/hooks/UseAssistantHandoff/useAssistantHandoff.ts | Switches handoff source from localStorage to the new state context. |
| app/views/WorkflowInputsView/hooks/UseAssistantHandoff/types.ts | Replaces localStorage handoff types with UseAssistantHandoff shape. |
| app/views/AnalyzeWorkflowsView/components/Main/components/Accordion/components/Workflow/workflow.tsx | Clears assistant-source state before routing to stepper from workflow accordion. |
| app/views/AnalyzeView/components/Main/main.tsx | Clears assistant-source state on “Configure Inputs” / “Custom Analysis” entry buttons. |
| app/components/Entity/components/ConfigureWorkflowInputs/components/Main/types.ts | Removes initialDataSourceView prop plumb-through. |
| app/components/Entity/components/ConfigureWorkflowInputs/components/Main/main.tsx | Removes initialDataSourceView usage. |
| app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/types.ts | Removes initialDataSourceView from stepper props. |
| app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/components/Step/types.ts | Removes initialDataSourceView from step props. |
| app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/components/Step/SequencingStep/utils.ts | Adds getInitialView + translateForSequencingStep. |
| app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/components/Step/SequencingStep/sequencingStep.tsx | Uses new utilities; shows loading while assistant ENA handoff resolves. |
| app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/components/Step/ReferenceAssemblyStep/.../SelectCell/selectCell.tsx | Moves “wipe configured inputs on assembly change” into call site via DEFAULT_CONFIGURED_INPUT. |
| app/components/Assistant/SchemaPanel/utils.ts | Adds accession extraction + sequencing-source normalization from free-text schema. |
| app/components/Assistant/SchemaPanel/schemaPanel.tsx | Dispatches handoff state and uses SPA navigation to preserve provider state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Happy to defer to you all on the React side here -- so just to make sure I'm reading the scope right: the bug itself is just a dropped One thing I'm genuinely not sure about on the new global-state approach -- might just be me misreading the flow: it looks like the assistant source never gets cleared on consume (clearing only happens on the entry buttons' |
…gle from state (#1295) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…1295) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Good call — addressed in 96251ad. The reducer now keys handoffs by
Trade-off you noted upthread: forward-after-back to the same workflow now shows a blank stepper (the handoff was consumed). We landed on accepting that — it matches the rest of the stepper's per-mount semantics ("leave the page, come back fresh") and the only way to get pre-fills back is a fresh assistant session, which is consistent with how localStorage behaved on refresh. |
Summary
Closes #1295.
schema.data_source.value(free-text) butSchemaPanel.handleContinuewrote onlydataSourceto the handoff. The accession was dropped at the boundary, so the sequencing step arrived empty and the launch button was correctly disabled.app/providers/workflowHandoff/. State is keyed byentity → path → inputs(e.g.state.assemblies["/data/assemblies/X/analyze/workflows/Y"] = {accessions, sequencingSource}). The assistant dispatchessetHandofffor the target page; the destination stepper reads viauseHandoffInputs(entity, currentPath)anduseHandoffSyncconsumes (dispatchesclearHandoff) after applying. Single-use semantics.normalizePagePath()(strips query, fragment, and trailing slashes) so they always compare canonical strings regardless of backend format quirks. Read site usesuseCurrentPath()overrouter.asPath.onClearSourcecalls (Configure, Configure Inputs, Select a Workflow, Custom Analysis). The path-keyed lookup + consume-on-apply makes any wrong-target navigation a no-op — no apply, no leak.useConfigureInputs: removed thehasMergedInitialRefdiscriminator (a strict-mode footgun where the effect double-fire wiped the merged initial state). The hook is now a one-line merge. The "wipe on assembly change" UX moved to the call site (SelectCell) via a newDEFAULT_CONFIGURED_INPUTconstant that explicitly spreads the wipe into the dispatch.SequencingSteptoggle now derived fromconfiguredInput(viagetInitialView) rather than internaluseState, so the toggle always reflects current state — important after an assembly re-pick wipes viaDEFAULT_CONFIGURED_INPUT.useHandoffEnaQueryout ofSequencingStep:useHandoffSyncis the sole caller. Loading status travels to deep consumers viaHandoffStatusContext(atproviders/workflowHandoff/contexts/HandoffStatus/). On pages that don't mountuseHandoffSync,SequencingStepreads the default non-loading context — no spurious handoff fetches.Test plan
npm test— 553/553 unit tests passnpx tsc --noEmitcleannpm run build:localsucceedsNotes
clearSequencingData([])seeds both array fields. The launch validator only checks the workflow's actual step, so this is harmless but worth a follow-up.🤖 Generated with Claude Code