Skip to content

Categories: pages carry which types each category is, not each type's form - #427

Merged
TripleU613 merged 1 commit into
mainfrom
lean-category-types
Nov 23, 2026
Merged

TripleU613 merged 1 commit into
mainfrom
lean-category-types

Conversation

@TripleU613

Copy link
Copy Markdown
Owner

Summary

Every page preloads all the categories it may show, and each one carried the full definition of every type it is (category_types): description, plus every field of that type's settings form with labels and defaults. On prod that was 108 KB on every page for 58 categories. Outside the category editor the browser only checks which types a category is (Category#isType, a plugin's categoryTypes.documentation) and shows a type's name and icon. The editor reloads the category through /c/:slug/find_by_slug.json (CategorySerializer), which keeps the full definitions. The site list now sends each type's id, name, title, icon and svg_icon only: 9.7 KB on prod.

It's scoped with instance_of?(SiteCategorySerializer), so CategorySerializer and the admin serializer, which inherit from it, are untouched. jtech_lean_category_types (on by default) switches it off, and changing it clears the cached category list.

Affected module(s)

  • Shared (plugin.rb, settings, locales, docs, lint/CI)

Test plan

  • New spec/requests/lean_category_types_spec.rb:
    • the site data has the short type definitions;
    • find_by_slug (the editor) still has the full ones;
    • switching it off brings them back.
    • The first example fails without the change.
  • Core's simplified_category_creation_spec.rb and new_category_spec.rb give the same results with and without this change. They have 7 failures in the plugin test container either way, unrelated to this change.
  • rubocop and stree clean.

Checklist

  • pnpm lint is clean (no frontend changes)
  • bundle exec rubocop is clean
  • New / changed settings have entries in config/locales/server.en.yml or client.en.yml
  • New / changed behavior has a spec (a bug fix has one that fails without it)
  • Follows the repository rules: no access past core, visibility checked, nothing core already does
  • No Ruby file references a non-existent setting name

🤖 Generated with Claude Code

https://claude.ai/code/session_01BUGDaR7qv2d8CuVp7UGSTs

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T01:42:01.097869Z 27b4888 New commits
🔒 Security Review ✅ Completed 2026-11-23T01:42:34.981750Z 27b4888 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b309afd4f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +14 to +15
on(:site_setting_changed) do |name, _old, _new|
Site.clear_cache if name.to_s == "jtech_lean_category_types"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear the cache when toggling the master switch

When an admin changes jtech_enabled, this handler does not invalidate the serialized category cache: enabling the plugin reaches the callback but fails this name check, while disabling it prevents the plugin-gated on callback from running at all. Consequently, a populated cache can continue serving either full or stripped type definitions for up to its 30-minute lifetime, so the master switch does not take effect promptly. Use an ungated enabled-change handler and clear Site's cache for both switches.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

… form

Every page preloads all the categories it may show, and each carried the
full definition of every type it is: description, and every field of the
type's settings form with labels and defaults. On prod that was 108 KB of
every page for 58 categories. Outside the category editor the browser only
asks which types a category is and shows a type's name and icon; the
editor loads the category again through find_by_slug (CategorySerializer),
which keeps the full definitions. The site's list now sends each type's
id, name, title and icons: 9.7 KB on prod.

jtech_lean_category_types (on) switches it off again; changing it clears
the cached category list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUGDaR7qv2d8CuVp7UGSTs
@TripleU613
TripleU613 merged commit a7aabd5 into main Nov 23, 2026
@TripleU613
TripleU613 deleted the lean-category-types branch November 23, 2026 01:40
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