Skip to content

Add model-page protocol (v1)#12

Merged
amcritchie merged 1 commit into
releasefrom
feat/model-page-engine-protocol
Jul 8, 2026
Merged

Add model-page protocol (v1)#12
amcritchie merged 1 commit into
releasefrom
feat/model-page-engine-protocol

Conversation

@amcritchie

Copy link
Copy Markdown
Owner

Task: https://mcritchie.studio/tasks/model-page-engine-protocol

Adds a reusable, admin-only model-page protocol to the engine, drawn into every consuming app via Studio.routes:

  • /models/:model/:id — renders one record as pretty JSON plus a copy/paste rails-console command to reload it
  • /models/:model/random — bounces to a random record of that model (fresh sample)

What's here

  • Studio::ModelPage (app/models/studio/model_page.rb) — the protocol object. Ships an empty registry; a host opts in per model in an initializer: Studio::ModelPage.register("release", Release, lookup: :slug). Mirrors the admin-models host-registry pattern — the engine never constantizes host models by name; an unknown key raises UnknownModel (rendered 404).
  • Studio::ModelsController + app/views/studio/models/show.html.erb (engine theme tokens; reuses the components/copy_button partial). Admin-gated via require_admin.
  • Routes added to Studio.routesrandom drawn before the :id catch-all so it isn't swallowed as an identifier. Host-level helpers (studio_model_path, studio_model_random_path).
  • Bumps 0.11.00.12.0 + CHANGELOG entry.

Tests

  • [unit] test/lib/studio/model_page_test.rb — 10 tests (registry, console command, random, JSON), pure-Ruby with a stub host model.
  • [integration] test/integration/model_page_routes_test.rb — routes drawn under the dummy app; random-before-:id ordering asserted against the route table.
  • Full bin/release-check green (wired both new files into its suite list).

Adoption (follow-ups, gated on publishing 0.12)

  • mcritchie-studio registers release and adds a "Model" link on /deployments/all (the app-local proof of this is already operator-approved).
  • turf-monster to follow.

🤖 Generated with Claude Code

Reusable admin-only per-record inspector drawn into every consuming app via
Studio.routes: /models/:model/:id renders a record as pretty JSON plus a
copy/paste rails-console command; /models/:model/random jumps to a random
record. Studio::ModelPage ships an EMPTY registry — hosts opt in per model
with register("release", Release, lookup: :slug) in an initializer. Bumps
0.11.0 -> 0.12.0. Engine suite (bin/release-check) green: 10 unit + 3 route.

Task: https://mcritchie.studio/tasks/model-page-engine-protocol

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@amcritchie amcritchie changed the base branch from main to release July 8, 2026 03:41
@amcritchie amcritchie merged commit 57b8862 into release Jul 8, 2026
1 of 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