Skip to content

fix(content): the rule set follows the page type, and rules a page can't meet are set apart - #2389

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/editor-rules-follow-page-type
Nov 14, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/editor-rules-follow-page-type

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

An article with no page type got the Product page rule set pinned. With no page type, the Rules tab's picker lists Product page first for ecommerce, and a picked set stayed pinned even after a page type was set. The article then showed product rules (Specs table, feed, sizes) and a 1,200-character Length, and Content Agent looped between Fix open rules and Rewrite trying to meet them. Some default rule sets also contradicted themselves: their structure rules needed about 1,650 characters while their Length allowed 1,440.

The owner allowed this change in the editor folder.

Changes

  • The rule set follows the page type (A1).
    • On a page with no type, picking a set now sets the page type through pickPageType, so nothing is pinned.
    • A set picked while the page has a type is saved with that type (new optional rules.setFor). It holds only while the page keeps that type. Changing the page type brings back that type's own set.
    • Every reader now goes through one helper, ruleSetType(): the editor, Chat's rules read, the agent's request, content-drafts' suggest action and Quality's type rules.
    • Existing pins saved before this change have no setFor, so they stop applying. That fixes the reported article without anyone touching it. It also means a person who deliberately picked a different set earlier gets their page type's set back.
  • No default rule set contradicts itself (G1). Product, Category, Collection and Sizing guide now ask for 2 fan-out H2s, 3 FAQ questions and 2 fan-out FAQ questions (at least about 950 characters), which fits their Length. Their Length is unchanged, so existing product pages aren't suddenly "too short". A new test checks that no default set, for any page type or none, has a Length conflict.
  • Rules a page can't meet are set apart (H). They go in a last group, "Not checked on this page", which is never counted and never sent to the agent:
    • another type's rule (new otherType status): "Product page rule. This page isn't a product page." with Set page type, which opens the header's menu;
    • Needs feed: "Needs your product feed. Connect a catalog, or turn this rule off.";
    • No sizes: "No sizes on this page, so not checked.";
    • Specs table on a product page with no specs (new needsSpecs status): "Needs your product's specs. Content Agent won't invent them.";
    • fan-out rules on pages with no prompts, and empty Keywords. The "Add prompts" link still works.
  • Rewrite stops sending those rules (A3). Rewrite page and Chat's page optimize drop them. AI-check rules such as Tone and Language still go.
  • Help: two sentences added to "Write to the Content Editor rules" › The Rules tab. Help regenerated.

How to test

  1. Open an article with no page type. It shows the shared rules, not Product page, and no specs, feed or sizes rules are counted.
  2. Pick a rule set with no page type. The page type is set to match.
  3. Set a page type. The Rules tab follows it.
  4. On a product page with no feed, those rules sit under "Not checked on this page".
  5. Run the tests:
cd web && yarn vitest run src/lib/content "src/app/[locale]/(dashboard)/dashboard/content/editor" src/lib/chat/page-optimize

Checks

  • Web typecheck: passes.
  • ESLint and Prettier on the changed files: pass.
  • Tests: 132 files, 1,762 tests pass across src/lib/content, the editor folder, page-optimize, use-server-exports and Help.
  • lib/actions/content-drafts.ts still exports async functions only.
  • No migrations, lockfile changes or new dependencies.

Generated by Claude Code

…n't meet are set apart

- A rule set picked while the page has no type sets the page type (through
  the header's page type path); a set picked for another type holds only
  while the page keeps the type it was picked on (rules.setFor), so setting
  or changing the page type brings back the page type's own set. Every
  reader (editor, Chat's rules read, the agent's request, Quality's type
  rules) goes through ruleSetType.
- Rules the page can't meet (another type's rule, no feed, no sizes, a
  product page with no specs, no fan-outs...) go under "Not checked on this
  page": never counted, and Rewrite and Chat's optimize no longer send them.
- Product, Category, Collection and Sizing-guide sets ask for 2 fan-out
  H2s, 3 FAQ questions and 2 fan-out questions, so no default set has a
  Length conflict (tested for every page type).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ruleSetType() now honours a pinned set only when setFor === pageType, but existing pins were saved without setFor, so every draft where someone picked another type's set silently falls back (a draft with set but no page_type gets no type rules at all), and the next edit writes set: null, erasing the choice and the customised rules. Please keep legacy pins without setFor (or backfill setFor). Also, this conflicts with #2390 in _rules-tab.tsx, content-quality-rules.md and approved-articles.json (additive, keep both).

Keeps both PR1's "Not checked on this page" note and main's missing
fan-outs line in the rule row. The Rules tab Help section went over 150
words with both, so the fan-out paragraph is its own section now. Help
is regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
@gkhngyk

gkhngyk commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Still open at 812df5b (only the main merge is new): ruleSetType ignores legacy pins without setFor and the next edit writes set: null. #2391, #2396, #2397 and #2403 are stacked on this, so they wait on it.

…set on an unrelated edit

- A set saved before setFor existed (rules.set with no setFor) holds
  whatever the page type, with or without one, as it did before ansvisor#2389:
  ruleSetType returns it, and rulesPageType checks its type rules as its
  own (editor, Chat's rules read, Quality's type rules), so they aren't
  set apart as another type's. Its customised rules stay.
- A set with setFor still holds only while the page keeps that type.
- Only the person's own set pick writes set (and setFor, which a legacy
  pin gains then); a rule's change, a toggle, the Length, Reset or the
  page type changed from the header keep set, setFor and the custom rules
  as stored, so nothing writes set: null behind the person's back.
- Help: the set follows the page type, except a set picked for another
  type (while the page keeps its type) and one picked before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for the fix.

@gkhngyk
gkhngyk merged commit a0079c1 into ansvisor:main Nov 14, 2026
12 checks passed
gkhngyk pushed a commit that referenced this pull request Nov 14, 2026
When a brand has banned phrases in Brand settings › Content rules, the
Content Editor's Rules tab shows "Avoid your brand's banned phrases" in
Style: on by default, turned off per draft like other rules, open while
the page has one (whole words, any case, as Chat's check), listing them,
counted, fixable by Content Agent, and under Before you publish › Fix
before you publish. With an empty list nothing new shows.

- getContentDraft reads the list through the draft (its brand, under the
  member's row policies), in parallel; a failed read leaves the rule out.
- Content Agent: Fix open rules is told the phrases only when there are
  some; a suggestion (Fix or a live page's) that brings one in is dropped
  and counted in the log. The page rewrite gets the after-write pass a
  new page has: those sentences once more, kept only when every kept
  line and heading stays. cutToLength and cutPrompt are unchanged.

Stacked on #2396 (-> #2391 -> #2389).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
gkhngyk pushed a commit that referenced this pull request Nov 14, 2026
…ge with the status, panel toggle in the panel

The Content Editor's header and side panel, as the owner approved them.

- No jump: getContentDraft also says whether the agent card shows as the
  editor opens (the latest batch, unless a restore since closed it with
  none open, the editor's own rule) and the author's name, read with the
  member's client and failing soft. The editor keeps the card's place from
  the first paint with a skeleton of the same box (tile, two lines,
  buttons) until its batch is read; nothing when it doesn't show or the
  read failed. The suggestions card is one line, about 56 px: the tile
  with its count, "6 suggestions", then what they change truncating
  ("..., +5 more · 9 → 12/16 rules"), with a warning, See sources and the
  action's link kept in sight, and Review, Reject all, Accept all.
- Steady chips: Rules and Quality keep a minimum width while they read
  ("Rules ···", "Quality ···"); the author chip shows from the draft's
  read until the menu is read; the Action line is a chip at the row's
  end, "From Action AC-…", its hint and label saying Mark ready completes
  its task.
- Next is the dots and "Next"; the step's name is in its label and title.
- AI usage moves to the status group after Saved, as a 16 px ring with
  "AI 4.7%", amber and red as before; its popover and tooltip stay.
- Hide side panel moves to the right end of the panel's tab row; the
  closed panel's rail gets Show side panel on top.
- Help: the editor's header and side panel, and Next in Quality.

Stacked on #2397 (-> #2396 -> #2391 -> #2389).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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.

3 participants