Repository navigation
feat(content): read the Length rule as a target within 20%, not a minimum - #1357
Conversation
…imum
A rule asking for 3,000 characters passed a 15,921-character page, since
length was checked as a floor, so Apply rules with Agent never asked for it
to be shortened. The rule now reads as a target: within 20% meets it
(2,400–3,600 for 3,000); shorter or longer is open, said on the badge
("15,921 · over") and in full on hover and to the agent ("15,921
characters, over 2,400–3,600"). The rule explains itself on hover. The
agent still leaves a few suggestions a run, so a long page shortens step by
step.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk this is item 9 from the editor feedback: the Length rule now reads as a target within ±20%, not a minimum, so a 15,921-character page under a 3,000 rule is open, and Apply rules with Agent asks for it to be shortened. It's web only; the agent's 8-suggestion cap is unchanged, so a long page shortens a few passages per run. |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good: the band check, both statuses, the hover text and what the agent is told all work, and the tests cover them. Two things:
-
The editor's counter disagrees with the rule.
_toolbar.tsx:223still turns the count amber as soon ascharacters > target. Now:- a 3,300-character page on a 3,000 target is amber, but Length shows ✓;
- a 2,000-character page is grey, but Length reads "under".
Colour it by
lengthBand(target), amber belowminor abovemax, so the counter and the Rules tab say the same thing. Add a test for it, in_toolbar.test.tsorpage.test.tsx. -
Follow-up, not blocking. The agent can only shorten by rewriting words in place:
keepSuggestionsdrops a replace with an emptyafter(server/src/lib/content-agent.js:180);- the system prompt asks for "small changes… as little as each rule needs" (
:93); - other open rules in the same run (FAQ, fan-out H2s) still produce inserts that lengthen the page.
One line in
SYSTEM_PROMPTwould help: for a Length rule that reads "over", replace wordy sentences with much shorter ones and don't insert. That fits with option (b) later.
Tested on top of main together with #1354: web and server tests, tsc, lint and Prettier pass.
… own result (#1366) Follow-up to #1357's review. The counter turned amber past the target while the Length rule passes within 20%. It now turns amber exactly when the Length rule is on and reads short or long (lengthWarns), so it can't disagree with the Rules tab: not with the rule turned off, and not with a rule value the counter's target clamps. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Content Editor feedback item 9. A Rules entry asked for 3,000 characters on a page the editor counts at 15,921. The Length rule was checked as a minimum, so the page met it and Apply rules with Agent never asked for it to be shortened.
The user chose option (a): the rule becomes a target band.
lib/content/rules.ts):lengthBand(target)gives{ min: target × 0.8, max: target × 1.2 }.short/long(count,min,max).ruleStatusDetail). The Length rule also gets a hover hint: "A target, not a minimum…".aim: 3000 characters · now: 15,921 characters, over 2,400–3,600.content-agent.js), so a page far over its target shortens a few passages at a time. A whole-page "Shorten" mode (option b) and applying My rules (option c) are not in this PR.Related issue
Content Editor feedback round (no issue).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
yarn test:rules.test.ts(the band, both ways),_rules-tab.test.tsx(15,921 over a 3,000 target) andpage.test.tsx(the agent's detail).Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(2721 tests pass) andyarn build.🤖 Generated with Claude Code