Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(content): leave rules held by quoted passages to the person, so the agent and Next step move on (#1516)

Cihan85f9eb6c1254
diff --git a/web/messages/en.json b/web/messages/en.json
index 42b18dde0..8f10df362 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -4451,7 +4451,7 @@
"stepOf": "Step {n} of {total}",
"allDone": "Every step is done",
"path": "All steps",
- "skip": "Skip",
+ "skip": "Skip this step",
"skipped": "· skipped",
"working": "Content Agent is working",
"stop": "Stop",
@@ -4482,7 +4482,8 @@
"writeMine": "The page is empty: write it, and the next step follows from what you write.",
"import": "The live page didn't come in. I write a first draft from your sources, or you write it yourself.",
"length": "{count, number} characters against a Length of {target, number}. Small fixes won't get there, so rewrite it in one go.",
- "fixRules": "{count, plural, one {# rule is} other {# rules are}} still open. Small, reviewable changes for them.",
+ "fixRules": "{count, plural, one {# rule is} other {# rules are}} still open for the agent. Small, reviewable changes for them.",
+ "fixRulesOthers": "{count, plural, one {# more is} other {# more are}} yours to decide in the Rules tab.",
"proofTrust": "Trust is {trust}, under {gate}. The Quality tab names what raises it.",
"proofTrustTodo": "Trust is {trust}, under {gate}. Only you can do this first: {todo}.",
"proofTodo": "Only you can do this: {todo}.",
@@ -5273,6 +5274,9 @@
"rewriteCitedToo": "Rewrite, cited passages too",
"rewriteCitedTooHint": "That rewrites the passages AI answers quote as well, so they may stop being quoted. You compare it with the page before anything changes.",
"lengthConflict": "The fan-out H2s, FAQ questions and summary these rules still ask for take about {need, number} characters, more than Length allows (up to {max, number}). Raise Length, or ask for fewer.",
+ "heldAll": "What's left open is kept by AI citations, and yours to decide: the agent leaves passages AI answers quote as they are.",
+ "heldLength": "Only the Length is left open, and a rewrite can't reach it. Raise the Length, or leave it.",
+ "heldSentence": "Kept by AI citations · yours to decide: the long sentences are in passages AI answers quote, which the agent keeps. Shorten them yourself (Edit anyway), or leave them quoted.",
"fixTrace": "Fix",
"fixTraceHint": "Content Agent rewrites only these phrases, for you to review",
"agent": {
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_cited-passages.test.ts b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_cited-passages.test.ts
index 8c6ee4101..65d4efc6a 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_cited-passages.test.ts
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_cited-passages.test.ts
@@ -8,6 +8,8 @@ import {
citedPassagesKey,
keptCharacters,
lockedPassageCount,
+ htmlWithoutLocked,
+ lockedKeysLeft,
lockedPassagesLeft,
rewriteFloor,
type HeldEdit,
@@ -156,6 +158,28 @@ describe('rewriteFloor', () => {
});
});
+describe('htmlWithoutLocked', () => {
+ it('reads the page without the passages still locked, by their words', () => {
+ const lock = (unlocked: string[] = []) =>
+ editor.view.dispatch(
+ editor.state.tr.setMeta(citedPassagesKey, {
+ labels: new Map([[passageKey(QUOTED), 'Cited by ChatGPT 3×']]),
+ unlocked: new Set(unlocked),
+ }),
+ );
+ lock();
+ expect(lockedKeysLeft(editor.state)).toEqual([passageKey(QUOTED)]);
+ const html = `<h1>T</h1><p>${QUOTED}</p><ul><li><p>${QUOTED}</p></li></ul><p>Free words.</p>`;
+ expect(htmlWithoutLocked(html, new Set(lockedKeysLeft(editor.state)))).toBe(
+ '<h1>T</h1><ul></ul><p>Free words.</p>',
+ );
+ // Unlocked by the person: the agent may change it, so it stays.
+ lock([passageKey(QUOTED)]);
+ expect(lockedKeysLeft(editor.state)).toEqual([]);
+ expect(htmlWithoutLocked(html, new Set())).toBe(html);
+ });
+});
+
describe('locked passages', () => {
it('marks the quoted passage and counts it, and how many a rewrite keeps', () => {
expect(lockedPassageCount(editor.state)).toBe(1);
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_cited-passages.ts b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_cited-passages.ts
index 186bfe58f..2607f58c8 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_cited-passages.ts
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_cited-passages.ts
@@ -247,6 +247,27 @@ export function rewriteFloor(
return { kept, floor: kept + floor };
}
+/** The keys of the quoted passages still locked (not unlocked by the person), sorted. */
+export function lockedKeysLeft(state: EditorState): string[] {
+ const locks = citedLocks(state);
+ return [...locks.labels.keys()].filter((key) => !locks.unlocked.has(key)).sort();
+}
+
+/**
+ * The page's HTML without the passages it keeps locked (their blocks, by
+ * the key their words make): what the agent may change, for a rule read as
+ * the rules read the page (readPage), so a rule met without them is held by
+ * them alone.
+ */
+export function htmlWithoutLocked(html: string, keys: ReadonlySet<string>): string {
+ if (!keys.size) return html;
+ const doc = new DOMParser().parseFromString(html, 'text/html');
+ for (const el of doc.body.querySelectorAll('p, li, h1, h2, h3, h4, h5, h6')) {
+ if (keys.has(passageKey(el.textContent ?? ''))) el.remove();
+ }
+ return doc.body.innerHTML;
+}
+
/** The quoted passages a rewrite keeps now (locked, not unlocked): how many, and their characters. */
export function lockedPassagesLeft(state: EditorState): { count: number; chars: number } {
const locks = citedLocks(state);
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
index 48682e270..7dd815723 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
@@ -168,7 +168,12 @@ import {
openRulesForAgent,
lengthBand,
rewriteAdvice,
+ NO_RULE_CONTEXT,
+ checkRule,
+ heldMessage,
keptOutOfReach,
+ lengthOutOfReach,
+ readPage,
type ActiveRule,
type LastRewrite,
type RewriteReach,
@@ -196,6 +201,8 @@ import {
citedLocks,
citedPassagesKey,
lockedPassageCount,
+ htmlWithoutLocked,
+ lockedKeysLeft,
lockedPassagesLeft,
rewriteFloor,
type HeldEdit,
@@ -1834,6 +1841,32 @@ export function DraftEditor({
};
}, [draft.id, shownRewriteId]);
const reach: RewriteReach = { kept: keptChars, floor: floorChars, last: lastRewrite };
+ // Open rules no run can close on this page (editor test 2026-10-25): every
+ // long sentence inside a passage AI answers quote, a Length out of a
+ // rewrite's reach. They leave the agent's work and Next step; the Rules tab
+ // says they're the person's to decide.
+ // The Sentence rule read as the rules read the page, without the locked
+ // passages: met then, every long sentence is in one.
+ const sentenceRule = rules.rules.find(({ rule }) => rule.key === 'sentence' && rule.on)?.rule;
+ const sentenceOpen = rules.rules.some(
+ ({ rule, status }) => rule.key === 'sentence' && rule.on && status.state === 'bad',
+ );
+ const lockedNow = editor && citedRead ? lockedKeysLeft(editor.state).join('\n') : '';
+ const sentenceHeld = useMemo(() => {
+ if (!sentenceRule || !sentenceOpen || !lockedNow) return false;
+ const rest = readPage(htmlWithoutLocked(pageHtml, new Set(lockedNow.split('\n'))), 0);
+ return checkRule(sentenceRule, rest, NO_RULE_CONTEXT).state === 'ok';
+ }, [sentenceRule, sentenceOpen, lockedNow, pageHtml]);
+ const lengthHeld = lengthOutOfReach(rules.rules, reach) !== null;
+ const heldKey = `${sentenceHeld ? 's' : ''}${lengthHeld ? 'l' : ''}`;
+ const heldRules = useMemo(
+ () =>
+ new Set([
+ ...(heldKey.includes('s') ? ['sentence'] : []),
+ ...(heldKey.includes('l') ? ['length'] : []),
+ ]),
+ [heldKey],
+ );
// The rules as the agent card counts its gain: met now, and the ones still open.
const cardRules = useMemo(
() => ({
@@ -2106,10 +2139,15 @@ export function DraftEditor({
toast(t('suggestions.decideFirst', { count: openSuggestions }));
return;
}
- const { forAgent: open, notForAgent } = openRulesForAgent(rules.rules, only);
+ const {
+ forAgent: open,
+ notForAgent,
+ held: heldOpen,
+ } = openRulesForAgent(rules.rules, only, heldRules);
if (open.length === 0) {
// Only rules it can't fix are open: say what to do instead.
if (notForAgent.length) toast(t(`suggestions.${notForAgentMessage(notForAgent)}`));
+ else if (heldOpen.length) toast(tRules(heldMessage(heldOpen)));
return;
}
const pageText = editor.getText({ blockSeparator: '\n' });
@@ -2394,6 +2432,7 @@ export function DraftEditor({
run: (only) => void fixRules(only),
running: fixRunning,
blocked: agentFixBlocked(fixRunning),
+ held: heldRules,
};
const handOffCard: HandOff | null =
sourcesOn && quality
@@ -2434,12 +2473,14 @@ export function DraftEditor({
});
// The card's Run Agent says why it won't run, as the Rules card does: also
// when the only rules left open are ones the agent doesn't fix (one H1).
- const agentRules = openRulesForAgent(rules.rules);
+ const agentRules = openRulesForAgent(rules.rules, undefined, heldRules);
const cardRunBlocked =
agentFix.blocked ??
(agentRules.forAgent.length === 0 && agentRules.notForAgent.length > 0
? t(`suggestions.${notForAgentMessage(agentRules.notForAgent)}`)
- : null);
+ : agentRules.forAgent.length === 0 && agentRules.held.length > 0
+ ? tRules(heldMessage(agentRules.held))
+ : null);
// A drag with files over the page shows where they go; one dropped beside
// the page (not on its text) goes in at the cursor.
@@ -2848,8 +2889,9 @@ export function DraftEditor({
published: status === 'published',
hasBrief: reads.brief.status === 'ready' ? reads.brief.brief !== null : null,
empty: !pageHasWords,
- rewrite: rewriteAdvice(rules.rules, reach),
- openRules: rulesForNext(rules.rules),
+ rewrite: rewriteAdvice(rules.rules, reach, heldRules),
+ openRules: rulesForNext(rules.rules, heldRules),
+ openTotal: rules.rules.filter(({ rule, status }) => rule.on && status.state === 'bad').length,
quality: quality
? { trust: trustNow, trustLow: trustNow !== null && trustNow < TRUST_GATE, todos }
: null,
@@ -2869,6 +2911,8 @@ export function DraftEditor({
// The sources (the fan-out rules read them), and with Quality the site's
// trust and the link reads (Trust moves as they land).
const nextRead =
+ // The quoted passages: until they're read, no rule is held by them.
+ citedRead &&
reads.brief.status !== 'loading' &&
reads.sources !== null &&
rules.ready &&
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-step.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-step.test.tsx
index ba2c55b3e..606190cbf 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-step.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-step.test.tsx
@@ -99,6 +99,14 @@ describe('NextStepButton', () => {
expect(onOpenChange).toHaveBeenCalledWith(true, expect.anything());
});
+ it('counts the rules the agent can fix, and says how many more the Rules tab counts', async () => {
+ // Length far off and a rule held by quoted passages: open in the Rules tab, not for Fix.
+ await render(state({ method: 'optimize', openRules: ['faq'], openTotal: 3 }));
+ expect(popup()!.textContent).toContain(
+ '1 rule is still open for the agent. Small, reviewable changes for them. 2 more are yours to decide in the Rules tab.',
+ );
+ });
+
it('says why from the page, with its button, the other one and Skip', async () => {
await render(
state({
@@ -115,7 +123,7 @@ describe('NextStepButton', () => {
expect(onAction).toHaveBeenCalledWith('rewritePage');
await act(async () => button('Fix open rules')!.click());
expect(onAction).toHaveBeenCalledWith('fixRules');
- await act(async () => button('Skip')!.click());
+ await act(async () => button('Skip this step')!.click());
expect(onSkip).toHaveBeenCalledWith('length');
expect(path()).toEqual([
'Plan the page · done',
@@ -161,7 +169,7 @@ describe('NextStepButton', () => {
await render(state());
expect(popup()!.textContent).toContain('Check and mark ready');
expect(button('Before you publish')).toBeDefined();
- expect(button('Skip')).toBeUndefined();
+ expect(button('Skip this step')).toBeUndefined();
// Published: Export, saying it went out.
await render(state({ open: false, published: true }));
expect(popup()!.textContent).toContain(
@@ -173,7 +181,7 @@ describe('NextStepButton', () => {
it("moves focus to the next step's button after Skip, and reads the step out", async () => {
const s = state({ openRules: ['faq'] });
await render(s);
- await act(async () => button('Skip')!.click());
+ await act(async () => button('Skip this step')!.click());
expect(onSkip).toHaveBeenCalledWith('fixRules');
// The editor passes the skip on: the step after it shows.
await render({ ...s, skipped: { fixRules: 'faq' } });
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-step.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-step.tsx
index c9756b5f5..4a13cb9a7 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-step.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-step.tsx
@@ -93,6 +93,17 @@ export function stepActor(step: NextStep): 'agent' | 'you' {
return AGENT_ACTIONS.has(step.primary) ? 'agent' : 'you';
}
+/**
+ * Fix open rules' reason: the rules a run can close, and the others the
+ * Rules tab counts as open (Length, a setting only the person fills, rules
+ * held by quoted passages), so the two never seem to disagree.
+ */
+function fixRulesReason(t: T, state: NextStepState): string {
+ const fix = t('reasons.fixRules', { count: state.openRules.length });
+ const others = (state.openTotal ?? state.openRules.length) - state.openRules.length;
+ return others > 0 ? `${fix} ${t('reasons.fixRulesOthers', { count: others })}` : fix;
+}
+
/** Why the step is next, from the page's own numbers. */
export function stepReason(
t: T,
@@ -105,9 +116,9 @@ export function stepReason(
case 'length':
return state.rewrite?.reason === 'length'
? t('reasons.length', { count: state.rewrite.count, target: state.rewrite.target })
- : t('reasons.fixRules', { count: state.openRules.length });
+ : fixRulesReason(t, state);
case 'fixRules':
- return t('reasons.fixRules', { count: state.openRules.length });
+ return fixRulesReason(t, state);
case 'write':
case 'import':
// Once the person said they'd write it, the step is theirs.
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.test.tsx
index ade93bb45..0c7cb8713 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.test.tsx
@@ -251,6 +251,17 @@ describe('the Rules tab', () => {
);
});
+ it('says a rule held by quoted passages is the person’s to decide', async () => {
+ // Sentences up to 10 characters: the page's one sentence is over, inside a quoted passage.
+ await show(
+ { agentFix: { ...fix(), held: new Set(['sentence']) } },
+ state({ overrides: { sentence: { value: '10' } } }),
+ );
+ expect(container.textContent).toContain(
+ 'Kept by AI citations · yours to decide: the long sentences are in passages AI answers quote',
+ );
+ });
+
it('says why its choice waits under the card, for the choice picked', async () => {
const agentFix = {
...fix(),
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.tsx
index b52481393..3e1e6a8ac 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_rules-tab.tsx
@@ -31,7 +31,9 @@ import { isPageType, type PageType } from '@/lib/content/drafts';
import { SITE_PAGE_TYPES, type SiteType } from '@/lib/content/page-types';
import {
MAX_TEXT_RULE_LENGTH,
+ NO_HELD,
NO_REACH,
+ heldMessage,
RULE_GROUPS,
notForAgentMessage,
openRulesForAgent,
@@ -82,6 +84,8 @@ export interface AgentFix {
running: boolean;
/** Why it can't run now (suggestions still open), or null. */
blocked: string | null;
+ /** Open rules no run can close here: held by what the page keeps (openRulesForAgent). */
+ held?: ReadonlySet<string>;
}
/** Rewrite the whole page to these rules, as the editor runs it: one suggestion. */
@@ -254,7 +258,8 @@ export function RulesTab({
];
// Rewrite the page whole when small edits can't get there.
- const advice = pageRewrite ? rewriteAdvice(state.rules, pageRewrite.reach) : null;
+ const held = agentFix?.held ?? NO_HELD;
+ const advice = pageRewrite ? rewriteAdvice(state.rules, pageRewrite.reach, held) : null;
// A Length the rewrite can't reach: said with a Length it can, never recommended.
const outOfReach = pageRewrite
? lengthOutOfReach(state.rules, pageRewrite.reach ?? NO_REACH)
@@ -269,7 +274,7 @@ export function RulesTab({
(pageRewrite?.reach ?? NO_REACH).floor - cited.chars <= lengthBand(outOfReach.target).max;
// The rules the page doesn't meet now, in the tab's order, and those the agent fixes.
const open = state.rules.filter(({ rule, status }) => rule.on && status.state === 'bad');
- const { forAgent, notForAgent } = openRulesForAgent(state.rules);
+ const { forAgent, notForAgent, held: heldOpen } = openRulesForAgent(state.rules, undefined, held);
const fixable = forAgent.length;
// Run Agent's choice: the safe default, or the whole page (▾) while it is offered.
const [picked, setPicked] = useState<RunMode>('fix');
@@ -278,7 +283,11 @@ export function RulesTab({
// Why Run Agent can't run its choice now, said under the card.
const blocked =
runner?.blocked ??
- (mode === 'fix' && fixable === 0 ? tSuggestions(notForAgentMessage(notForAgent)) : null);
+ (mode === 'fix' && fixable === 0
+ ? notForAgent.length === 0 && heldOpen.length > 0
+ ? t(heldMessage(heldOpen))
+ : tSuggestions(notForAgentMessage(notForAgent))
+ : null);
// A draft on My rules for a type the workspace has none for (its type
// changed, or My rules couldn't be read) shows Ansvisor's set for it.
@@ -449,7 +458,9 @@ export function RulesTab({
note={
rule.key === 'length' && state.lengthConflict
? t('lengthConflict', state.lengthConflict)
- : undefined
+ : rule.key === 'sentence' && held.has('sentence') && status.state === 'bad'
+ ? t('heldSentence')
+ : undefined
}
/>
))}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
index 1837203b2..3721d670d 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
@@ -1383,6 +1383,48 @@ describe('the content editor', () => {
expect(container.querySelector('header')!.textContent).toContain('1 cited passage kept');
});
+ it('leaves long sentences only in quoted passages to the person, never sent to Fix', async () => {
+ // Sentences up to 60 characters: the quoted passage's is the only long one.
+ getContentDraft.mockResolvedValue(
+ draft({
+ ...page,
+ bodyHtml: `${page.bodyHtml}<p>We delve into it.</p>`,
+ rules: {
+ set: null,
+ source: null,
+ overrides: { sentence: { value: '60' } },
+ textRules: [],
+ },
+ }),
+ );
+ getCitedPassages.mockResolvedValue(cited);
+ fixDraftRules.mockResolvedValue({ count: 0 });
+ const width = window.innerWidth;
+ window.innerWidth = 1024;
+ try {
+ await renderPage();
+ await act(async () =>
+ container
+ .querySelector<HTMLButtonElement>('header button[aria-label^="Rules "]')!
+ .click(),
+ );
+ expect(container.querySelector('aside')!.textContent).toContain(
+ 'Kept by AI citations · yours to decide',
+ );
+ await act(async () =>
+ [...container.querySelector('aside')!.querySelectorAll<HTMLButtonElement>('button')]
+ .find((b) => b.textContent === 'Run Agent')!
+ .click(),
+ );
+ await act(async () => {});
+ const keys = fixDraftRules.mock.calls[0][2].rules.map((r: { key: string }) => r.key);
+ expect(keys).toContain('aiTraces');
+ expect(keys).not.toContain('sentence');
+ } finally {
+ window.innerWidth = width;
+ }
+ });
+
it('reads nothing for a new page', async () => {
getContentDraft.mockResolvedValue(draft({ sourceUrl: null }));
await renderPage();
@@ -5548,7 +5590,7 @@ describe('the side panel', () => {
expect(basket()).toBeNull();
expect(nextButton()!.getAttribute('aria-label')).toBe('Next · Plan the page');
await act(async () => nextButton()!.click());
- await act(async () => inBasket('Skip')!.click());
+ await act(async () => inBasket('Skip this step')!.click());
expect(nextButton()!.getAttribute('aria-label')).not.toBe('Next · Plan the page');
expect(JSON.parse(localStorage.getItem('aeo:next-step-skips:d1')!)).toEqual({
plan: 'false',
@@ -5611,7 +5653,7 @@ describe('the side panel', () => {
);
await renderPage();
expect(basket()).not.toBeNull();
- await act(async () => inBasket('Skip')!.click());
+ await act(async () => inBasket('Skip this step')!.click());
expect(basket()).not.toBeNull();
expect(nextButton()!.getAttribute('aria-label')).toBe('Next · Write the first draft');
@@ -5629,7 +5671,7 @@ describe('the side panel', () => {
'The page is empty: write it, and the next step follows from what you write.',
);
expect(inBasket('Write with Agent')).toBeUndefined();
- expect(inBasket('Skip')).toBeUndefined();
+ expect(inBasket('Skip this step')).toBeUndefined();
});
it('leaves focus where a click outside the basket put it', async () => {
@@ -5697,7 +5739,7 @@ describe('the side panel', () => {
await renderPage();
expect(nextButton()!.getAttribute('aria-label')).toBe('Next · Fix open rules');
await act(async () => nextButton()!.click());
- await act(async () => inBasket('Skip')!.click());
+ await act(async () => inBasket('Skip this step')!.click());
const skips = () => JSON.parse(localStorage.getItem('aeo:next-step-skips:d1')!);
const skippedAt = skips().fixRules;
expect(skippedAt).toContain('fanoutH2');
diff --git a/web/src/lib/content/next-step.test.ts b/web/src/lib/content/next-step.test.ts
index 99bfba9d8..899551051 100644
--- a/web/src/lib/content/next-step.test.ts
+++ b/web/src/lib/content/next-step.test.ts
@@ -252,4 +252,17 @@ describe('rulesForNext', () => {
]),
).toEqual(['aiTraces', 'summary']);
});
+
+ it('leaves out rules held by what the page keeps: no Fix run closes them, so Next moves on', () => {
+ const rule = (key: string) => ({ key, on: true, current: '150' }) as never;
+ const statuses = [
+ {
+ rule: rule('sentence'),
+ status: { state: 'bad' as const, code: 'over' as const, count: 3 },
+ },
+ { rule: rule('summary'), status: { state: 'ok' as const } },
+ ];
+ expect(rulesForNext(statuses)).toEqual(['sentence']);
+ expect(rulesForNext(statuses, new Set(['sentence']))).toEqual([]);
+ });
});
diff --git a/web/src/lib/content/next-step.ts b/web/src/lib/content/next-step.ts
index 42efba8fc..b787e8fba 100644
--- a/web/src/lib/content/next-step.ts
+++ b/web/src/lib/content/next-step.ts
@@ -52,13 +52,16 @@ export const FEW_OPEN_RULES = REWRITE_OPEN_RULES - 1;
* The open rules a run of Fix open rules can close: the ones the agent is
* asked to fix, less a setting only the person fills (Who it's for) and
* Length, which its own step takes once it is far off; a page a little off
- * its Length isn't sent round Fix again and again for it. Sorted keys, so
- * Skip can tell when the set changes.
+ * its Length isn't sent round Fix again and again for it; and rules `held` by
+ * what the page keeps word for word, which no run can close: what's left is
+ * the person's, and Next moves on. Sorted keys, so Skip can tell when the
+ * set changes.
*/
export function rulesForNext<T extends { rule: ActiveRule; status: RuleStatus }>(
rules: T[],
+ held?: ReadonlySet<string>,
): string[] {
- return openRulesForAgent(rules)
+ return openRulesForAgent(rules, undefined, held)
.forAgent.filter(
({ rule, status }) =>
rule.key !== 'length' && !(status.state === 'bad' && status.code === 'notSet'),
@@ -81,6 +84,8 @@ export interface NextStepState {
rewrite: RewriteAdvice | null;
/** The open rules a Fix run can close (rulesForNext). */
openRules: string[];
+ /** Every rule on that the page doesn't meet, as the Rules tab counts them. */
+ openTotal?: number;
/**
* Quality's reads (Quality spec, CE-040/041): Trust under its gate (60),
* and the to-dos only the person can do. Null while Quality is off.
diff --git a/web/src/lib/content/rules.test.ts b/web/src/lib/content/rules.test.ts
index d4a13690c..9cfc7f01b 100644
--- a/web/src/lib/content/rules.test.ts
+++ b/web/src/lib/content/rules.test.ts
@@ -30,6 +30,9 @@ import {
RULE_LENGTH_MIN,
RULE_LENGTH_MAX,
lengthBand,
+ NO_REACH,
+ NO_RULE_CONTEXT,
+ heldMessage,
keptOutOfReach,
lengthOutOfReach,
rewriteAdvice,
@@ -240,6 +243,25 @@ describe('length and structure', () => {
expect(one.forAgent.map(({ rule }) => rule.key)).toEqual(['aiTraces']);
expect(one.notForAgent).toEqual([]);
expect(openRulesForAgent(statuses, ['oneH1']).forAgent).toEqual([]);
+ // Held on this page by what it keeps word for word: the person's, apart.
+ const held = openRulesForAgent(statuses, undefined, new Set(['aiTraces']));
+ expect(held.forAgent.some(({ rule }) => rule.key === 'aiTraces')).toBe(false);
+ expect(held.held.map(({ rule }) => rule.key)).toEqual(['aiTraces']);
+ expect(held.notForAgent.map(({ rule }) => rule.key)).toEqual(['oneH1']);
+ // What to say when they're all that's left: the quoted passages', else the Length's.
+ expect(heldMessage(held.held)).toBe('heldLength');
+ expect(heldMessage([{ rule: { key: 'sentence' } }])).toBe('heldAll');
+ });
+
+ it('reads a rule met without the locked passages as held by them', () => {
+ const sentence = activeRules(ruleSet('blog_post'), {
+ overrides: { sentence: { value: '20' } },
+ }).find((r) => r.key === 'sentence')!;
+ const long = 'A sentence that runs well past twenty characters.';
+ const all = page(`<h1>T</h1><p>${long}</p><p>Short.</p>`, 60);
+ expect(checkRule(sentence, all, NO_RULE_CONTEXT).state).toBe('bad');
+ const rest = page('<h1>T</h1><p>Short.</p>', 10);
+ expect(checkRule(sentence, rest, NO_RULE_CONTEXT).state).toBe('ok');
});
it('wants a short summary under the H1, and a short answer under each H2', () => {
@@ -901,6 +923,14 @@ describe('rewriteAdvice', () => {
});
it('recommends it for 4 rules or more the agent can fix', () => {
+ // A rule held by what the page keeps isn't one a rewrite fixes.
+ expect(
+ rewriteAdvice(
+ statuses(null, ['faq', 'summary', 'h2Answer', 'sentence']),
+ NO_REACH,
+ new Set(['sentence']),
+ ),
+ ).toBeNull();
expect(rewriteAdvice(statuses(null, ['faq', 'summary', 'h2Answer']))).toBeNull();
expect(rewriteAdvice(statuses(null, ['faq', 'summary', 'h2Answer', 'keywords']))).toEqual({
reason: 'open',
diff --git a/web/src/lib/content/rules.ts b/web/src/lib/content/rules.ts
index f9611f09c..61053f383 100644
--- a/web/src/lib/content/rules.ts
+++ b/web/src/lib/content/rules.ts
@@ -792,21 +792,43 @@ export function fanoutsToUse(status: RuleStatus, max = 300): string | null {
/**
* The rules on that the page doesn't meet (of `only`, when given): the ones
- * the Content Agent is asked to fix, and those it can't.
+ * the Content Agent is asked to fix, those it never fixes, and those `held`
+ * on this page by what it keeps word for word (editor test 2026-10-25: long
+ * sentences all inside passages AI answers quote, a Length out of a
+ * rewrite's reach), which are the person's to decide.
*/
export function openRulesForAgent<T extends { rule: ActiveRule; status: RuleStatus }>(
rules: T[],
only?: string[],
-): { forAgent: T[]; notForAgent: T[] } {
+ held: ReadonlySet<string> = NO_HELD,
+): { forAgent: T[]; notForAgent: T[]; held: T[] } {
const open = rules.filter(
({ rule, status }) => rule.on && status.state === 'bad' && (!only || only.includes(rule.key)),
);
return {
- forAgent: open.filter(({ rule }) => !NOT_FOR_AGENT.has(rule.key)),
+ forAgent: open.filter(({ rule }) => !NOT_FOR_AGENT.has(rule.key) && !held.has(rule.key)),
notForAgent: open.filter(({ rule }) => NOT_FOR_AGENT.has(rule.key)),
+ held: open.filter(({ rule }) => !NOT_FOR_AGENT.has(rule.key) && held.has(rule.key)),
};
}
+/** No rule held by what the page keeps. */
+export const NO_HELD: ReadonlySet<string> = new Set();
+
+/**
+ * What to say when only held rules are left for the agent: the quoted
+ * passages' (a sentence in one), else the Length's, out of a rewrite's reach.
+ */
+export const heldMessage = (held: readonly { rule: { key: string } }[]) =>
+ held.some(({ rule }) => rule.key === 'sentence') ? 'heldAll' : 'heldLength';
+
+/** A rule read with nothing of the brand's: for checks that read only the page. */
+export const NO_RULE_CONTEXT: RuleContext = {
+ brandDomains: [],
+ competitorDomains: [],
+ fanouts: [],
+};
+
/** How far off its Length a page may be before Rewrite the page to these rules is recommended. */
export const REWRITE_LENGTH_OFF = 0.3;
/** How many rules the agent can fix may be open before it is. */
@@ -958,6 +980,7 @@ export type RewriteAdvice =
export function rewriteAdvice<T extends { rule: ActiveRule; status: RuleStatus }>(
rules: T[],
reach: RewriteReach = NO_REACH,
+ held: ReadonlySet<string> = NO_HELD,
): RewriteAdvice | null {
const length = rules.find(({ rule }) => rule.key === 'length' && rule.on);
const target = Number(length?.rule.current);
@@ -979,7 +1002,7 @@ export function rewriteAdvice<T extends { rule: ActiveRule; status: RuleStatus }
}
// A Length out of reach is no rule a rewrite meets.
const outOfReach = lengthOutOfReach(rules, reach) !== null;
- const open = openRulesForAgent(rules).forAgent.filter(
+ const open = openRulesForAgent(rules, undefined, held).forAgent.filter(
({ rule }) => !(outOfReach && rule.key === 'length'),
).length;
return open >= REWRITE_OPEN_RULES ? { reason: 'open', count: open } : null;