Skip to content

Clear the last workspace's output, problems and undo history on a switch - #39

Merged
burhankhanzada merged 1 commit into
mainfrom
fix/reset-on-workspace-switch
Oct 4, 2026
Merged

burhankhanzada merged 1 commit into
mainfrom
fix/reset-on-workspace-switch

Conversation

@burhankhanzada

Copy link
Copy Markdown
Member

Bug: run the Blink template, go Home, start a blank project, and the Serial Monitor still shows Blink's "Hello World". The bottom panes and the canvas outlive the workspace they show: the logs, Problems and the canvas undo history are app-wide state that nothing reset when another workspace opened. So the new project also listed the old compile errors, and ⌘Z could replay the old circuit's edits onto the new one.

Fix: WorkspaceSessionReset (lib/app/, mounted in bootstrap.dart) watches the workspace path and, when it changes, clears:

  • every log channel: Serial Monitor (and the Serial Plotter, which is drawn from it), SPICE Logs, Debug Console;
  • Problems;
  • the canvas's undo/redo history (new HistoryManager.clear()).

The path changes on every switch: templates and blank projects open in fresh temporary folders, another folder has its own path, and Close Folder sets it to null. It's at the app layer because the state it clears belongs to features that may not import one another (test/architecture/layering_test.dart).

Already handled, left alone:

  • a running simulation stops itself on a workspace change (simulation_bindings.dart);
  • the editor's tabs close as a workspace opens.

The terminal isn't tied to the workspace (its shell doesn't start in the project), and ending it would end whatever is running in it.

Tests (test/app/workspace_session_reset_test.dart):

  • opening another workspace clears all of it;
  • closing the folder clears all of it;
  • working within one workspace keeps it.

With the reset disabled, the two switch tests fail. The full suite passed in pre-push, and dart analyze --fatal-infos is clean.

🤖 Generated with Claude Code

Running Blink, going Home and starting a blank project left Blink's
"Hello World" in the Serial Monitor. The bottom panes and the canvas
outlive the workspace they show: the logs, Problems and the undo
history are app-wide state that nothing reset when another workspace
opened, so the new project also listed the old compile errors, and
⌘Z could replay the old circuit's edits onto the new one.

WorkspaceSessionReset (lib/app/) watches the workspace path and, when
it changes, clears every log channel (Serial Monitor, and the Serial
Plotter drawn from it; SPICE Logs; Debug Console), Problems and the
canvas's undo history. The path changes on every switch: templates and
blank projects open in fresh temporary folders, another folder has its
own path, and Close Folder sets it to null. It lives at the app layer
because the state it clears belongs to features that may not import
one another.

Already reset elsewhere, so left alone: a running simulation stops on a
workspace change, and the editor's tabs close as a workspace opens.
The terminal is not tied to the workspace, and ending its shell would
end whatever runs in it.

Tested: switching or closing clears all of it; working within one
workspace keeps it. With the reset disabled, the switch tests fail.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@burhankhanzada
burhankhanzada merged commit a9d480d into main Oct 4, 2026
21 checks passed
@burhankhanzada
burhankhanzada deleted the fix/reset-on-workspace-switch branch October 4, 2026 16:40
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.

1 participant