Skip to content

refactor(model): Decouple Domain Operations From Direct UI Input#578

Open
hcoona wants to merge 1 commit intoYafc-CE:masterfrom
hcoona:dev/shuaizhang/decouple-ui-op
Open

refactor(model): Decouple Domain Operations From Direct UI Input#578
hcoona wants to merge 1 commit intoYafc-CE:masterfrom
hcoona:dev/shuaizhang/decouple-ui-op

Conversation

@hcoona
Copy link
Copy Markdown

@hcoona hcoona commented Feb 28, 2026

Introduce IUndoBatchScheduler to decouple UndoSystem from InputSystem.Instance.DispatchOnGestureFinish logic:

  • Add IUndoBatchScheduler and ImmediateUndoBatchScheduler for headless/test execution in the model layer.
  • Add GestureFinishUndoBatchScheduler in the UI layer to wrap input system behavior.
  • Use explicit dependency injection for the scheduler in UndoSystem and configure UndoSystem.DefaultScheduler during app startup in Program.cs.

Decouple hardware key state from Blueprint.cs:

  • Introduce BlueprintFormat enum (CompressedBase64, RawJson) to make format intent explicit instead of checking InputSystem.Instance.control.
  • Update Blueprint.ToBpString() and BlueprintUtilities to accept the BlueprintFormat parameter.
  • Move UI evaluation (InputSystem.Instance.control) appropriately to UI callers (ProductionTableView, ShoppingListScreen) to drive intent.

Close #577

@hcoona hcoona force-pushed the dev/shuaizhang/decouple-ui-op branch from a7d7219 to 12863a0 Compare February 28, 2026 21:01
@hcoona
Copy link
Copy Markdown
Author

hcoona commented Feb 28, 2026

Tested.

  1. "Shopping list" export with/without Ctrl.
  2. "Production table" export single blueprint with/without Ctrl.
  3. "Export entities to to blueprint" with/without Ctrl.
  4. Drag line and Ctrl+Z/Ctrl+Y.

@hcoona hcoona marked this pull request as ready for review February 28, 2026 21:32
@hcoona hcoona requested a review from shpaass as a code owner February 28, 2026 21:32
@hcoona
Copy link
Copy Markdown
Author

hcoona commented Mar 1, 2026

I'll resolve the conflicts soon.

@shpaass
Copy link
Copy Markdown
Collaborator

shpaass commented Mar 1, 2026

Take your time, there is no rush.

@hcoona hcoona force-pushed the dev/shuaizhang/decouple-ui-op branch from 12863a0 to 2d58994 Compare March 1, 2026 00:17
@hcoona
Copy link
Copy Markdown
Author

hcoona commented Mar 1, 2026

Conflicts resolved and tested.

Comment thread Yafc/Windows/ShoppingListScreen.cs Outdated
@hcoona hcoona force-pushed the dev/shuaizhang/decouple-ui-op branch from 2d58994 to 88b174e Compare March 3, 2026 06:14
@hcoona hcoona requested a review from veger March 3, 2026 06:15
@hcoona hcoona force-pushed the dev/shuaizhang/decouple-ui-op branch from 88b174e to d58f84c Compare March 3, 2026 06:20
@hcoona
Copy link
Copy Markdown
Author

hcoona commented May 1, 2026

Merged upstream/master into this branch and reviewed the integration seams around the PR's decoupling changes.

I specifically checked the post-merge overlap for startup/undo scheduling and blueprint export behavior. The conflict resolution keeps the UI-aware UndoSystem.DefaultScheduler setup before Ui.Start() while also preserving the new upstream fatal logging around UI initialization. I also verified the updated production-table export paths still use BlueprintClipboardContext.RequestedFormat, so the Ctrl-to-raw-JSON behavior remains owned by the UI layer and the model-side blueprint APIs continue to receive an explicit BlueprintFormat.

I did not find any new upstream changes that need additional coverage under this PR's approach, and I did not find a new regression from the merge. The existing project-level Yafc.Model -> Yafc.UI dependency is still pre-existing architecture rather than a new regression introduced by this merge.

Validation: dotnet test .\FactorioCalc.sln --configuration Debug --nologo passes with 419/419 tests.

@hcoona hcoona requested a review from DaleStan as a code owner May 1, 2026 05:21
Introduce explicit undo batch scheduling and blueprint export format selection so model code no longer reads UI interaction state for these operations.

This also incorporates upstream/master and preserves the reviewed merge seam behavior for startup logging, production-table blueprint exports, and line-ending normalization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@hcoona hcoona force-pushed the dev/shuaizhang/decouple-ui-op branch from 123feed to c4f8661 Compare May 1, 2026 05:22
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.

Refactor: Decouple domain operations from direct UI input (InputSystem.Instance)

3 participants