Skip to content

Move undo/redo and tab editing out of ContentView - #13

Merged
code4teaching merged 31 commits into
core-text-logicfrom
editor-store
Oct 19, 2026
Merged

code4teaching merged 31 commits into
core-text-logicfrom
editor-store

Conversation

@code4teaching

Copy link
Copy Markdown
Owner

Requested by Holger · project thread

Before: ContentView.swift copied the whole tab array at 32 places to change one field of the current tab, and kept the undo/redo stacks and their 80-step limit inline.

After: the undo/redo history lives in VisuStructCore as VisuStructEditHistory (with tests), and editing the current tab goes through DiagramSheetTabsModel+Editing.swift. The app should behave exactly as before.

How: DiagramSheetTab now holds a history instead of two arrays. The model extension offers currentTab, updateCurrentTab, commitDocument, resetHistoryAndDocument, undo, redo, selectAndClearError and setErrorOnCurrentTab. The selection cleanup after undo, redo and delete is now VisuStructDocumentEditing.sanitizedSelection. ContentView keeps the UI side effects (tab title sync, line editor refresh, focus). Step 3 of the plan; stacked on #12.

Check on Mac and iPad: undo and redo after insert, delete, paste and text edits; undo back to an empty diagram; "New" on a tab with a linked file gets an untitled name again.


Generated by Claude Code

- VisuStructCore: VisuStructEditHistory (undo/redo stacks, 80-step limit)
  and VisuStructDocumentEditing.sanitizedSelection, with tests.
- DiagramSheetTab keeps a VisuStructEditHistory instead of two arrays.
- DiagramSheetTabsModel+Editing: currentTab, updateCurrentTab,
  commitDocument, resetHistoryAndDocument, undo, redo,
  selectAndClearError, setErrorOnCurrentTab.
- ContentView uses these instead of copying tabs by hand at each site.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
@code4teaching code4teaching self-assigned this Oct 18, 2026
The engine, play/pause task, input text and the simulation mode flag
move from ContentView @State into an @observable SimulationController.
The step delay and highlight mode are read from UserDefaults at each
step, as the @AppStorage values were before.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
claude and others added 24 commits October 18, 2026 22:24
- Palette/PaletteActionList.swift: palette rows, drag preview and the
  action buttons below; actions come in as closures.
- Simulation/SimulationDetailView.swift: canvas plus state panel layout
  for simulation mode, driven by SimulationController.
- ContentView keeps the action logic (toggleSimulationMode,
  openCodeGenerator) and the simulation canvas.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
- VisuStructCore: VisuStructDocumentEditing.multiwayAncestorPath and
  caseIndex(of:inMultiwayAt:), with tests.
- Inspector/InspectorElementHints.swift: line editor placeholder and
  condition hint line per element type.
- Remove the unused statementIOModeIfApplicable().

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
The four export actions in ContentView each rendered the diagram and
mapped errors themselves. Export/DiagramExporter.swift now does that;
ContentView only stores the share payloads it returns.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
- DiagramCanvasView.swift: inputs, state, layout and body, clipboard.
- DiagramCanvasDropZones.swift: drop bands, tap insert targets and
  applying drops.
- DiagramCanvasRenderer.swift: Canvas drawing of cells, lines and text.

The two new files are extensions of DiagramCanvasView, so members they
share lose their `private`. Code is moved unchanged otherwise.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Carries the portrait simulation layout from main into
SimulationDetailView.swift.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Carries the VoiceOver block labels from main into
DiagramCanvasDropZones.swift.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
# Conflicts:
#	VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/ContentView.swift
Split DiagramCanvasView into view, drop zones and renderer
Bundle PNG, file, PDF and print export in DiagramExporter
Move inspector hints and Fallauswahl path helpers out of ContentView
Extract PaletteActionList and SimulationDetailView from ContentView
Move simulation state and controls into SimulationController
@code4teaching
code4teaching merged commit 7771e9c into core-text-logic Oct 19, 2026
2 checks passed
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.

2 participants