Skip to content

feat(content): the editor checks the brand's banned phrases - #2397

Merged
gkhngyk merged 11 commits into
ansvisor:mainfrom
cihan-gyk:feature/editor-banned-phrases
Nov 14, 2026
Merged

gkhngyk merged 11 commits into
ansvisor:mainfrom
cihan-gyk:feature/editor-banned-phrases

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Stacked on #2396 (→ #2391 → #2389). Review it after them, or read only the last commit. It builds on their rule model: agentFixable(), "Not checked on this page", and rewrites that keep sections.

The owner allowed changes in the Content Editor folder for this work.

Summary

This follows the owner's rule for banned phrases: "if it was given as input, it must be checked against the brand's list". When a brand has banned phrases in Brand settings › Content rules, the Content Editor now checks the page against them. When the list is empty, nothing new shows anywhere.

  • Rules › Style shows Avoid your brand's banned phrases. The rule is on by default, and the person can turn it off for a draft like any other rule. It is open while the page has a phrase. Phrases match the way Chat's draft check matches them (bannedPhrasesIn): whole words, any case. The rule lists the phrases found and counts like other rules. Content Agent can fix it: Fix open rules includes it through agentFixable(), and its row has a Fix button, as Remove AI traces does.
  • Before you publish › Fix before you publish has a row for it while a phrase is on the page and the rule is on.
  • The Content Agent gets the phrases in its Fix prompt, but only when the brand has some. It drops any suggestion that would bring a banned phrase in, and logs the count. A page rewrite now gets the same check after writing that a new page already gets.

Changes

Web

  • lib/content/rules.ts:
    • ruleSet(…, { bannedPhrases }) adds the brandBanned switch after Banned words, only when the list isn't empty.
    • checkRule reads it with RuleContext.bannedPhrases, using Chat's bannedPhrasesIn. An open rule returns { state: 'bad', code: 'found', count, phrases }.
    • New helper phrasesFound(status).
  • lib/actions/content-drafts.ts › getContentDraft:
    • Reads brands(content_rules) through the draft, in parallel with the draft read, with the member's client. The draft's brand and the brands row policies scope it to the draft's brand and organization.
    • If the read fails, the draft still opens without the rule.
    • No new server action and no admin client.
  • lib/content/drafts.ts: optional ContentDraft.bannedPhrases.
  • Editor folder:
    • _use-draft-rules.ts passes the list to the rule set and the checks.
    • _rules-tab.tsx lists the phrases found and adds the hint and the Fix button.
    • _draft-editor.tsx puts the phrases in the Fix request's detail and passes them to Before you publish.
    • _before-publish.tsx adds the Fix before you publish row.
  • messages/en.json: rule name, hint, "On the page: …", and the Before you publish row.
  • Quality: its to-do lists and the hand-off aren't fed by open rules, so nothing was added there and there is no second check. The new rule is counted in Next step's Fix step and in "Still open: N rules" like every other rule.

Server

  • content-agent.js:
    • fixDraftRules reads the brand's phrases. buildFixPrompt names them only when there are some.
    • New bannedAdded(). keepSuggestions drops a suggestion whose new text adds a phrase the old text didn't have: in its words, in an insert, or across the passage as changed. Drops are logged by count, never with the phrases.
  • content-writer.js:
    • Live-page suggestions use the same drop.
    • rewritePage gets rewriteWithoutBanned, the HTML version of withoutBanned. It checks the rewrite's own words; kept lines are the person's. If it finds a phrase, it rewrites those sentences once. The new version is kept only when every kept line and heading stays; otherwise the rewrite stands, and a phrase left is logged by count.
    • Both checks share one budget-held call, bannedCall.
    • cutToLength and cutPrompt are unchanged.

Help

  • "Write to the Content Editor rules": new section "Your brand's banned phrases".
  • "Use Chat › Content rules": one sentence.
  • Approved articles regenerated.

No migrations, lockfile changes or new dependencies.

How to test

  1. In a brand's settings, under Content rules, add the banned phrases cheap and best price.
  2. Open a draft in the Content Editor and type "Cheap flights at the best price".
    • Rules › Style shows Avoid your brand's banned phrases · 2 found with "On the page: "cheap", "best price"".
    • The rules count goes down by one.
    • Typing "cheaper" doesn't match.
  3. Turn the rule off. It reads Off and stops counting. Turn it back on.
  4. Click Fix on the rule, or Fix open rules. The suggestions say those phrases in other words, and none of them adds a banned phrase.
  5. Click Mark ready. Before you publish › Fix before you publish lists the phrases. Remove them and the row goes away.
  6. Run Rewrite page on a page with a banned phrase. The rewrite offered has none left, unless the single retry couldn't remove it (the server logs a warning).
  7. Empty the brand's list and reload the draft. The rule isn't shown anywhere.

Checks

  • Web typecheck (tsc --noEmit): clean.
  • ESLint and Prettier on the changed files (web and server): clean.
  • Web tests: src/lib/content, the editor folder, src/lib/chat/banned-phrases, src/lib/chat/page-optimize, src/lib/use-server-exports, src/lib/help and src/lib/actions/content-drafts. 146 files, 1953 tests, all passing.
  • Server tests: content-agent, content-writer and content-rules. 204 tests, all passing.

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
…p what the rules ask for

One state per rule (F1): agentFixable() is the open rules less those the
agent never fixes, a setting only the person fills, rules held by what the
page keeps, rules it tried and couldn't close, and rules not checked on
this page. The Rules tab's Fix button, Fix open rules, the agent card's
Run, rulesForNext, the Next step and its steps window all read it. With
nothing left it can fix, the Rules tab says "Content Agent did what it
could. N rules are yours to decide." in place of the button and lists
them, each with Change the page, Change the rule and, for a tried rule,
Ask again (clears its mark and runs Fix for it alone). The steps window
shows Fix open rules as taken by the agent then, as the Rules tab says.

Conflicts first (B1): when the rules can't fit the Length, the next step
is "Raise Length to ~N" (what the rules need, rounded up to 50), set in
one click, with Ask for fewer beside it, before Fix or a rewrite.

Page type first (A2): with no page type, the first step is Set page type,
which opens the header's page type menu.

Next step order: page type, conflict, Fix open rules, then the Length's
rewrite, then Before you publish.

The rewrite within all rules (B2: the cut pass told the rules, the
rewrite-drop warning, the step's new name) is left for a follow-up, to
keep this change to its scope.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
The server's cut pass gets the rules and never drops a section they
require. The agent card says when a rewrite left met rules open, beside
Undo. The Length step reads "Rewrite within all rules".

Follow-up to the one-agent-state change; not opened as a PR yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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
Brings in main (with the agent reliability and score changes) through
PR1's branch. No conflicts; Help needed no regeneration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Brings in main through the PR1 and PR2 branches. Trims Help's "Before
you publish" section back under 150 words and regenerates Help.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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 ansvisor#2396 (-> ansvisor#2391 -> ansvisor#2389).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
gkhngyk
gkhngyk previously approved these changes Nov 14, 2026

@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 (its own commit). Waits on #2389.

…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 previously approved these changes Nov 14, 2026

@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.

@cihan-gyk
cihan-gyk dismissed gkhngyk’s stale review November 14, 2026 11:02

The merge-base changed after approval.

@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.

@gkhngyk
gkhngyk merged commit 6c6a1c4 into ansvisor:main Nov 14, 2026
12 checks passed
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