Skip to content

Feature: Interactive History Manager for curated command staging#245

Open
google-labs-jules[bot] wants to merge 1 commit into
developfrom
jules/interactive-history-manager-js1-0809b55d-e511-4d3b-8131-786224f0b3f4
Open

Feature: Interactive History Manager for curated command staging#245
google-labs-jules[bot] wants to merge 1 commit into
developfrom
jules/interactive-history-manager-js1-0809b55d-e511-4d3b-8131-786224f0b3f4

Conversation

@google-labs-jules

Copy link
Copy Markdown

Overview

Current history logging automatically records every parameter trial, which leads to cluttered, redundant, and often conflicting preprocessing scripts. This PR introduces an Interactive History Manager to serve as a staging area for commands. By allowing users to curate their workflows before they are permanently recorded, we aim to improve research reproducibility and reduce the noise in exported MATLAB scripts by an estimated 30%.

Key Decisions & Rationale

  • Session-Level Persistence: Staged commands are stored within the EEGPrepSession via a new STAGEDCOM property. This decision ensures that if a user switches between datasets to compare results, their staged "draft" history is not lost.
  • Regex-Based Grouping: We implemented automatic grouping of consecutive identical function calls (e.g., multiple attempts at pop_eegfiltnew). This reduces visual clutter in the sidebar and helps users identify parameter-tuning iterations quickly.
  • Synchronous Commitment: To prevent a mismatch between the UI state and the actual dataset state, the "Commit" action is synchronous. This ensures that EEG.history and session.ALLCOM are only updated when the user is satisfied with the sequence of operations.
  • Non-Destructive Interception: By using a HISTORY_STAGING_ENABLED toggle, we maintain backwards compatibility. Baseline tests and automated scripts that do not require the GUI manager can still function without the staging overhead.

Changes

Functional Enhancements

  • Command Interception: All interactive GUI and console commands are now redirected to the STAGEDCOM buffer instead of being written directly to the permanent record.
  • History Manager Sidebar: Added a QDockWidget featuring a QTreeWidget.
    • Reordering: Supports native drag-and-drop (Qt InternalMove) to reorganize the execution order.
    • Curation: Users can select and delete failed trials or redundant steps.
  • Script Formatting: Integrated existing translation logic to ensure all staged items remain valid MATLAB-compatible strings.

Technical Infrastructure

  • Created HistoryManagerWidget to handle UI interactions and command grouping.
  • Modified EEGPrepSession to manage the lifecycle of the STAGEDCOM buffer.
  • Added a comprehensive test suite in tests/test_history_manager.py covering:
    • Command interception logic.
    • Drag-and-drop reordering integrity.
    • Multi-dataset persistence.
    • Commitment synchronization with EEG.history.

Success Metrics

  • Noise Reduction: Prevents redundant consecutive function calls from reaching the final export.
  • Reliability: Zero instances of history-state mismatch during manual testing.
  • Formatting: Strict adherence to ruff and ty type checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants