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.

feat(content): read the Length rule as a target within 20%, not a minimum (#1357)

Cihan387064644efe
diff --git a/web/messages/en.json b/web/messages/en.json
index 64cf421ff..7cb3a18be 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -3992,6 +3992,7 @@
"measureSteps": "How to measure, as numbered steps"
},
"hints": {
+ "length": "A target, not a minimum: within 20% of it meets the rule. A page well over it is open, and Apply rules with Agent shortens it a few passages at a time.",
"summary": "A short summary under the H1 that answer engines can quote.",
"fanoutH2": "Takes the top fan-outs you keep in Sources, the most searched first, not every one.",
"internalLinks": "Links with descriptive anchor text to your own pages.",
@@ -4027,6 +4028,10 @@
"found": "{count} found",
"partOf": "{count} of {of}",
"words": "{count} words",
+ "short": "{count, number} · under",
+ "long": "{count, number} · over",
+ "shortDetail": "{count, number} characters, under {min, number}–{max, number}",
+ "longDetail": "{count, number} characters, over {min, number}–{max, number}",
"missing": "Missing",
"noH2": "No H2 yet",
"needsFaq": "Needs FAQ",
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 a8e582b50..a75af2081 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
@@ -78,7 +78,7 @@ import { HtmlBlock, copyToClipboard } from './_html-block';
import { OwnCopies, ownCopyHtml } from './_own-copies';
import { PageTypeMenu } from './_page-type-menu';
import type { AgentRewrite } from './_brief-tab';
-import { ruleStatusText, type AgentFix } from './_rules-tab';
+import { ruleStatusDetail, type AgentFix } from './_rules-tab';
import { EditorPanelRail, EditorSidePanel, useSidePanelOpen, type PanelTab } from './_side-panel';
import {
AgentSuggestions,
@@ -579,7 +579,7 @@ export function DraftEditor({
rule.current
? `${tRules('agent.aim')}: ${rule.current}${rule.unit ? ` ${tRules(`units.${rule.unit}`)}` : ''}`
: null,
- `${tRules('agent.now')}: ${ruleStatusText(tStatus, status)}`,
+ `${tRules('agent.now')}: ${ruleStatusDetail(tStatus, status)}`,
rule.key === 'aiTraces'
? `${tRules('agent.phrases')}: ${aiTracesFound(pageText).join(', ')}`
: null,
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 30a101437..d3ac794e6 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
@@ -35,7 +35,8 @@ function state(
const rules = activeRules(ruleSet('feature_page'), choices);
const page = readPage(
'<h1>Pipeline forecasting</h1><p>A seamless way to forecast in 2026.</p><table><tr><td>x</td></tr></table>',
- 2610,
+ // The user's case: a 3,000-character rule over a 15,921-character page.
+ 15921,
);
const checked = rules.map((rule) => ({
rule,
@@ -109,7 +110,11 @@ describe('the Rules tab', () => {
expect(container.textContent).toContain(`${s.met} of ${s.total} rules met`);
expect(row('Comparison table vs alternatives').textContent).toContain('✓');
expect(row("Who it's for").textContent).toContain('Not set');
- expect(row('Length').textContent).toContain('2,610');
+ // Over the band, said short on the badge and in full on hover.
+ expect(row('Length').textContent).toContain('15,921 · over');
+ expect(row('Length').querySelector('[title*="characters"]')?.getAttribute('title')).toBe(
+ '15,921 characters, over 2,400–3,600',
+ );
expect(row('Banned words').textContent).toContain('1 found');
expect(row('Tone').textContent).toContain('AI check');
expect(row('Use top fan-outs as H2s').textContent).toContain('No fan-outs');
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 091561c1d..f0378eff9 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
@@ -37,6 +37,7 @@ import type { DraftRulesState } from './_use-draft-rules';
/** Rules with an explanation on hover (spec §10). */
const HINTED = new Set([
+ 'length',
'summary',
'fanoutH2',
'internalLinks',
@@ -466,6 +467,20 @@ export function ruleStatusText(
return t(status.code);
}
+/**
+ * The same in full, for the badge's hover and what the agent is told: a
+ * length out of its band with the band ("15,921 characters, over 2,400–3,600").
+ */
+export function ruleStatusDetail(
+ t: (key: string, values?: Record<string, number>) => string,
+ status: RuleStatus,
+): string {
+ if (status.state === 'bad' && (status.code === 'short' || status.code === 'long')) {
+ return t(`${status.code}Detail`, { count: status.count, min: status.min, max: status.max });
+ }
+ return ruleStatusText(t, status);
+}
+
function StatusBadge({ on, status }: { on: boolean; status: RuleStatus }) {
const t = useTranslations('contentEditor.editor.rules.status');
if (!on) {
@@ -476,13 +491,13 @@ function StatusBadge({ on, status }: { on: boolean; status: RuleStatus }) {
const text = ruleStatusText(t, status);
return (
<span
+ title={ruleStatusDetail(t, status)}
className={cn(
'w-20 shrink-0 truncate text-right text-[11px] font-medium',
status.state === 'ok' && 'text-emerald-600 dark:text-emerald-400',
status.state === 'bad' && 'text-amber-600 dark:text-amber-400',
status.state === 'info' && 'font-normal text-muted-foreground',
)}
- title={text}
>
{text}
</span>
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 569be57ee..a6942bc11 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
@@ -1791,6 +1791,13 @@ describe('the side panel', () => {
detail: 'now: 1 found · phrases found: delve',
});
expect(request.rules.every((r: { key: string }) => r.key !== 'sentence')).toBe(true);
+ // The length as a target band, so the agent knows how far off the page is.
+ expect(request.rules).toContainEqual(
+ expect.objectContaining({
+ key: 'length',
+ detail: expect.stringMatching(/now: \d+ characters, under [\d,]+–[\d,]+$/),
+ }),
+ );
expect(request).toMatchObject({ textRules: [], locked: [] });
expect(
container.querySelector('[role="region"][aria-label="Agent suggestions"]')!.textContent,
diff --git a/web/src/lib/content/rules.test.ts b/web/src/lib/content/rules.test.ts
index 678c60fc1..8b88747b5 100644
--- a/web/src/lib/content/rules.test.ts
+++ b/web/src/lib/content/rules.test.ts
@@ -149,13 +149,25 @@ describe('length and structure', () => {
expect(check('sentence', '<p>Short. Also short!</p>')).toEqual({ state: 'ok' });
});
- it('reads the length from the editor’s count', () => {
- expect(checkRule(rule('length'), page('', 2610), ctx)).toEqual({
+ it('reads the length from the editor’s count, as a target within 20%', () => {
+ // A 3,000 target: 2,400–3,600 meets it.
+ expect(checkRule(rule('length'), page('', 2610), ctx)).toEqual({ state: 'ok' });
+ expect(checkRule(rule('length'), page('', 3600), ctx)).toEqual({ state: 'ok' });
+ expect(checkRule(rule('length'), page('', 2000), ctx)).toEqual({
state: 'bad',
- code: 'current',
- count: 2610,
+ code: 'short',
+ count: 2000,
+ min: 2400,
+ max: 3600,
+ });
+ // A page far over its target is open, for Apply rules with Agent to shorten.
+ expect(checkRule(rule('length'), page('', 15921), ctx)).toEqual({
+ state: 'bad',
+ code: 'long',
+ count: 15921,
+ min: 2400,
+ max: 3600,
});
- expect(checkRule(rule('length'), page('', 3000), ctx)).toEqual({ state: 'ok' });
});
it('wants a short summary under the H1, and a short answer under each H2', () => {
diff --git a/web/src/lib/content/rules.ts b/web/src/lib/content/rules.ts
index 33e0b81bf..a002e431d 100644
--- a/web/src/lib/content/rules.ts
+++ b/web/src/lib/content/rules.ts
@@ -478,6 +478,8 @@ export type RuleStatus =
| { state: 'bad'; code: 'over' | 'found'; count: number }
| { state: 'bad'; code: 'partOf'; count: number; of: number }
| { state: 'bad'; code: 'current'; count: number }
+ /** Out of the Length rule's band, as it reads (lengthBand). */
+ | { state: 'bad'; code: 'short' | 'long'; count: number; min: number; max: number }
| { state: 'bad'; code: 'words'; count: number }
| { state: 'bad'; code: 'missing' | 'noH2' | 'needsFaq' | 'notSet' }
| {
@@ -589,6 +591,19 @@ function definesAtOnce(text: string): boolean {
return verb > 0 && !PRONOUNS.test(words[verb - 1]);
}
+/**
+ * The Length rule is a target, not a floor: a page within 20% of it meets it,
+ * shorter or longer doesn't, so a 15,921-character page under a 3,000 rule is
+ * open, and Apply rules with Agent asks for it to be shortened.
+ */
+export const LENGTH_TOLERANCE = 0.2;
+export function lengthBand(target: number): { min: number; max: number } {
+ return {
+ min: Math.round(target * (1 - LENGTH_TOLERANCE)),
+ max: Math.round(target * (1 + LENGTH_TOLERANCE)),
+ };
+}
+
const atLeast = (have: number, want: number): RuleStatus =>
have >= want ? { state: 'ok' } : { state: 'bad', code: 'partOf', count: have, of: want };
@@ -623,10 +638,16 @@ export function checkRule(rule: ActiveRule, page: PageRead, ctx: RuleContext): R
.filter((s) => s.length > n).length;
return over ? { state: 'bad', code: 'over', count: over } : { state: 'ok' };
}
- case 'length':
- return page.characters >= n
- ? { state: 'ok' }
- : { state: 'bad', code: 'current', count: page.characters };
+ case 'length': {
+ const { min, max } = lengthBand(n);
+ if (page.characters < min) {
+ return { state: 'bad', code: 'short', count: page.characters, min, max };
+ }
+ if (page.characters > max) {
+ return { state: 'bad', code: 'long', count: page.characters, min, max };
+ }
+ return { state: 'ok' };
+ }
case 'summary':
if (!summary || !summary.words) return { state: 'bad', code: 'missing' };
return summary.words <= n