Skip to content

feat(tutorial): protect what a stage sets up, and limit what it offers - #96

Merged
Rn86222 merged 8 commits into
mainfrom
feat/protect-stage-pins
Nov 19, 2026
Merged

Rn86222 merged 8 commits into
mainfrom
feat/protect-stage-pins

Conversation

@Rn86222

@Rn86222 Rn86222 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The tutorial's Check finds a stage's pins by name, and with no one at the booth to help, a player who deleted or renamed one could only recover by resetting the whole stage. This PR keeps what a stage sets up in place and narrows what a stage offers. Everything is an option of the editor; the free mode passes none, so it behaves as before.

  • Protected nodes (isProtectedNode): a stage's own Input and Output nodes cannot be deleted or moved into a new component, and their pins cannot be renamed (the rename button on the node is hidden).
  • Telling why: with such nodes selected, the context menu shows Delete with a note naming them. When nothing else can go, Delete is greyed out ("A and Out cannot be deleted, as the stage uses them"). Otherwise Delete removes the rest ("A is kept, as the stage uses it"). The menu has a maximum width and the note wraps.
  • Properties (hasProperties): the properties button is hidden on a stage's own component, as its pins are protected and its name is the stage's title. Components the player made keep it.
  • Creating components (canCreateComponents): each stage says whether "Create a new component..." is offered. The two current stages do not offer it, since grouping nodes into a box cannot be undone and they do not need it.
  • What can be placed (isOffered + canPlaceComponent): the side panel and drops on the canvas now share one check. Before, a drop placed whatever id it carried, so a component dragged from another tab could be missing from this store, could include the edited component, or could be a part the stage does not offer. In a stage, the stage's parts and the player's own components are offered. Inside a component the player made, Input and Output are offered too, so a stage that allows new components lets the player give them pins.

Not in this PR

  • A save made before this change, in which a stage's pin was renamed or deleted, can only be fixed with "Reset this stage". The missing-pin message already points there.
  • In the Japanese UI, some characters are drawn with a system font instead of Noto Sans JP. This comes from the font order set in feat(i18n): switch the interface between English and Japanese #93 and will be fixed separately.

Testing

  • npx vitest run (173 tests), npx tsc -p . and npx biome check src pass. New tests cover:
    • protected nodes left out of deleting and moving, the notes naming them, and no menu in play mode
    • nothing protected by default, and no "Create a new component" when the editor is told not to offer it
    • the placement check: unknown ids, the edited component, components including it, and parts not offered
    • a stage's pins and parts, with Input and Output offered inside the player's own components
    • a stage still passing once its circuit is grouped into a component of the player's own
    • the notes for one, two and three names in English and Japanese
  • Checked in the browser:
    • Stage 1: the greyed Delete and its note, deleting a gate with A kept, no "Create a new component", no rename or properties buttons, and drops from another tab ignored.
    • Free mode: deleting, renaming, creating components and the properties dialog work as before.

🤖 Generated with Claude Code

Rn86222 and others added 8 commits November 19, 2026 20:30
…named

The check finds a stage's pins by name, and a player who deleted one could only get
it back by resetting the whole stage. The editor now takes nodes to protect: the
context menu leaves them out of deleting and of creating a new component, and their
pins cannot be renamed on the node or in the properties dialog. A stage protects its
Input and Output nodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A drop placed any component id it carried, so one dragged from another tab could
name a component missing from this store, one that includes the edited component, or
in a stage a part the stage does not offer, such as an Input that would then be
protected. The side panel and the drop now share one check.

Also drops comments that restated the code, and covers protecting nothing by default
and protecting an Input next to a gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its pins can no longer be renamed, which leaves only its name, the stage's title, to
change there. Components the player made keep the button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Right-clicking a selection with a stage's Input or Output nodes now shows Delete with
a note naming them: greyed out with "cannot be deleted" when nothing else can go,
or "stay" when the rest of the selection is deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Menu items do not wrap, so a note naming many nodes would stretch the menu without
end. The menu now has a maximum width and the note wraps within it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grouping nodes into a new component turns them into a box that cannot be undone,
which the first stages do not need. A stage now says whether it allows that, and the
first two do not. Inside a component the player made, the stage also offers Input
and Output nodes, so a stage that allows new components lets them get more pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the properties dialog's protected pins, which it can no longer be opened for,
and a condition that could not matter. One type now describes which components are
offered, the context menu splits the selection in one pass, and the Delete item keeps
the height of the others. The notes on kept nodes read better in English and use 、
in Japanese, like the other lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also keeps the divider above Edit when only protected nodes are selected, which the
editor's option allows for any node, not only Input and Output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee with  Cloudflare Pages  Cloudflare Pages

Latest commit: 485e3e1
Status: ✅  Deploy successful!
Preview URL: https://c68f4476.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev
Branch Preview URL: https://feat-protect-stage-pins.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev

View logs

@Rn86222
Rn86222 merged commit 887fda8 into main Nov 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.

1 participant