Skip to content

Make history script workspace synchronization atomic #180

Closed

Description

@suraj-ranganath

🤖 GUI Run script passes only a partial workspace into pop_runscript and copies fields back manually. ALLCOM, LASTCOM, and CURRENTSTUDY are outside the transaction, so scripts can leave GUI and console state inconsistent.

Relevant code:

  • src/eegprep/functions/guifunc/menu_actions.py:902 - partial script namespace
  • src/eegprep/functions/guifunc/menu_actions.py:909 - manual copy-back
  • src/eegprep/functions/popfunc/pop_runscript.py:18 - in-process Python script execution

Acceptance criteria:

  • Run script receives the same core workspace names as eegprep-console.
  • Script changes are applied through the session-owned workspace state path.
  • Tests cover EEG, ALLEEG, CURRENTSET, STUDY, CURRENTSTUDY, LASTCOM, and ALLCOM synchronization.

Activity

  1. added
    bug
    on Jun 10, 2026
  2. claude commented on Jun 10, 2026

    @claude
    Contributor

    🤖 Plan:

    Research

    _run_script builds a partial namespace (EEG, ALLEEG, CURRENTSET, STUDY) — missing ALLCOM, LASTCOM, CURRENTSTUDY — and then writes results back with direct attribute assignment rather than through session helpers, so a script that sets CURRENTSET = 2 does not refresh EEG from ALLEEG and a script that sets STUDY = ... does not update CURRENTSTUDY. The console workspace (EEGPrepConsoleWorkspace.after_execute) already routes the same fields through session.retrieve / store_current / set_study / add_history for the matching WORKSPACE_NAMES tuple.

    Relevant code

    • src/eegprep/functions/guifunc/menu_actions.py#L889-L914 — partial namespace + manual copy-back
    • src/eegprep/functions/popfunc/pop_runscript.py#L11-L25 — exec against the namespace dict
    • src/eegprep/functions/adminfunc/console.py#L26 — WORKSPACE_NAMES canonical list
    • src/eegprep/functions/adminfunc/console.py#L335-L397 — session-owned sync path used by the console
    • src/eegprep/functions/guifunc/session.py#L174-L287 — store_current / retrieve / set_study / add_history

    Proposed Fix

    Expand the script namespace to all seven WORKSPACE_NAMES and replace the direct-assign copy-back with a small helper that mirrors the console sync rules: session.ALLEEG accepts the list, a changed CURRENTSET goes through session.retrieve (so EEG follows), a rebound EEG goes through session.store_current, STUDY goes through session.set_study (so CURRENTSTUDY follows), and any new ALLCOM / LASTCOM entries go through session.add_history before the final pop_runscript LASTCOM is appended. Add tests/test_gui_main_window.py coverage that exercises each of EEG, ALLEEG, CURRENTSET, STUDY, CURRENTSTUDY, LASTCOM, ALLCOM in one script call.

    Status

    PR #188 opened. All target tests pass locally; monitoring CI.

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

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions