feat: auto-restore session from settings upload#1225
Open
Conversation
When a dataset and settings YAML are uploaded together (or sequentially), the app now auto-advances through the Data tab pipeline (mapping → filtering → preview → PKNCA object creation), navigates to the saved tab, and auto-runs NCA if the previous session was on the NCA tab. - Preserve tab metadata in settings_override flow - Auto-trigger mapping submission when settings are detected - Auto-advance through filtering and preview steps - Navigate to saved tab after data processing completes - Auto-run NCA when target tab is 'nca' - Return skipped mappings from .process_imported_mapping for error detection - Show warning notifications on partial mapping failure - Safety timeouts: 15s for data pipeline, 10s for NCA auto-run - No regressions: all auto-replay logic gated behind settings detection Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
later::later() callbacks run outside a reactive context, so reading reactiveVals without isolate() causes 'Operation not allowed without an active reactive context' error. Co-authored-by: Ona <no-reply@ona.com>
shinyjs::delay() runs inside a reactive context, eliminating the need for isolate() wrappers. It is already a dependency and purpose-built for deferred execution in Shiny apps. Co-authored-by: Ona <no-reply@ona.com>
…oading popup - Add nca_ran flag to settings export payload (both zip and download) - Set session$userData$nca_ran when NCA results are calculated - Gate auto-run NCA on nca_ran flag (not just tab == 'nca') - Suppress 'Calculating NCA results...' popup during auto-replay - Dismiss 'Restoring session...' popup after auto-replay NCA completes Co-authored-by: Ona <no-reply@ona.com>
…ameters When settings are from a different dataset, the analyte/profile may not match, causing 'Invalid parameters' before tryCatch runs. The early return now resets auto_nca_running and dismisses the popup. Co-authored-by: Ona <no-reply@ona.com>
…dition The previous check in the adnca_mapped observer could fire before .process_imported_mapping had set mapping_skipped. Moving the primary check into the shinyjs::delay callback (after selectize inputs have flushed) ensures mapping_skipped is already populated. The original check remains as a safety net. Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
- .abort_auto_replay(): shared abort pattern used in 3 places - .restore_duplicate_exclusions(): duplicate key matching logic Co-authored-by: Ona <no-reply@ona.com>
tab_data.R: - .setup_step_navigation(): next/prev/restart button observers - .setup_auto_replay(): all auto-replay observers (steps 1,3,4 + timeout) - .simplify_volume_units(): volume unit simplification from pknca_data data_mapping.R: - .apply_single_mapping(): per-variable validation and selectize update Co-authored-by: Ona <no-reply@ona.com>
…plexity Move step 1 body and filter-pending flag setup into .start_auto_replay(). Replace auto_replay_filter_pending reactiveVal with session$userData to eliminate a separate observer. Co-authored-by: Ona <no-reply@ona.com>
The delay callback already checks auto_replay() before aborting, making the outer guard unnecessary. Co-authored-by: Ona <no-reply@ona.com>
Collaborator
|
LGTM! I tested many cases and seems to work fine. My only concern is with the manual delay: I feel like this can cause trouble if the data is big or there are many settings. But maybe using an observer is not worthy? So I will leave it to your criteria 😄 |
Gero1999
approved these changes
Apr 15, 2026
96863c0 to
ea1d8b0
Compare
…igger Use settings %>% debounce(500) instead of shinyjs::delay(1500) to wait for the NCA settings cascade to settle before auto-running NCA. This adapts to dataset size rather than relying on a fixed timer. Co-authored-by: Ona <no-reply@ona.com>
The previous observe() fired immediately when auto_nca_pending became TRUE if processed_pknca_data already existed, before the imported settings cascade had settled. Use a settled flag set by the debounced settings observer, and check from both observeEvent handlers to handle either firing order. Co-authored-by: Ona <no-reply@ona.com>
…rigger Debouncing settings alone was insufficient — processed_pknca_data depends on raw settings (not final_settings) and fires with intermediate values during the cascade. Debouncing the data object directly (1000ms) waits for the entire cascade to settle at the output level. Co-authored-by: Ona <no-reply@ona.com>
Add session$userData$auto_replay_active flag so child modules can check whether auto-replay is in progress. Suppress 'All intervals were filtered' (nca_setup.R) and 'Remember to submit filters' (data_filtering.R) during the settings cascade. Flag is cleared at every auto-replay exit point. Co-authored-by: Ona <no-reply@ona.com>
…xity Extract .setup_filter_import and .setup_filter_reminder from data_filtering_server to bring cyclomatic complexity under the lintr threshold of 15. Co-authored-by: Ona <no-reply@ona.com>
Collaborator
Author
|
@Gero1999 thanks, I refactored to take your advice, PTAL |
bachapman
approved these changes
Apr 15, 2026
Collaborator
bachapman
left a comment
There was a problem hiding this comment.
Great job, works well for me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Closes #722
Description
When a dataset and settings YAML are uploaded together, the app now auto-restores the previous session instead of requiring manual clicks through each step.
What happens on upload with settings:
nca_ranflag in settings)Error handling:
No regressions: All auto-replay logic is gated behind settings detection. Manual upload workflow is unaffected.
Definition of Done
How to test
Contributor checklist
.scsschange was done, rundata-raw/compile_css.RNotes to reviewer
nca_ranflag is a new boolean field in the settings YAML payload. Old settings files without this field default toFALSE(no auto-run).