Where it lives
A new screen that lets people change its view imports the shared button. It does not draw its own.
The guard scripts
Two scripts fail the build when a second control appears. allternit-ai:scripts/check-view-switch.mjs. It runs as part of pnpm typecheck, so a pull request with a second control does not pass. Rules:
- A file that calls
useOverviewLayout(must renderViewSwitchButtonorOverviewLayoutSwitch, or have an allow entry naming the file that renders it. - Outside
src/components/view-switch/, no code calls a layout setter with a literal view name, no menu has a section labelled “Layout”, and no option list holds both grid and list. - At most one view button per file.
scripts/check-view-switch.sh. Run it with bash scripts/check-view-switch.sh. It exits 0 when there are no hits. On iOS it bans a Picker or segmented control over layout values and a ForEach over the layout cases. On Android it bans LibraryLayoutSwitch, a PillRow or loop over the layout entries, and a local LayoutSwitch.
Both scripts have an allow table: a file, the rule it is excused from, and a reason. An entry must say why it is allowed. A permanent entry is a screen that is not a List, Grid or Deck view (for example the browser’s split-pane layout). A temporary entry names the step that removes it. Add an entry only with a real reason, and delete it as soon as the screen moves to the shared button.