Skip to content

fix(content-editor): hold the Quality score until the page's reads are in - #1470

Merged
gkhngyk merged 4 commits into
ansvisor:mainfrom
cihan-gyk:fix/quality-chip-settled
Oct 25, 2026
Merged

gkhngyk merged 4 commits into
ansvisor:mainfrom
cihan-gyk:fix/quality-chip-settled

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The Content Editor header's Quality chip showed the average of whatever had been read so far. On a production draft it went 90 → 45 → 59 within seven seconds of opening:

  • Readability alone gave 90;
  • E-E-A-T (0) arrived next and pulled it to 45;
  • Trust arrived last and moved it to 59.

The same happened after the agent's rewrite. Users read the first number as the page's score.

Now

  • Until the reads that move the score are in, or have failed, the chip says "Quality · reading…" with no number. Those reads are:
    • E-E-A-T: the authors, and in phase 2 Your input;
    • Trust: the site's trust, the sources, the links, and in phase 2 the claims and the AI reads of the sites' kinds.
  • After that, it keeps the last settled score while new reads land (a link added, the agent's page). A pulsing dot and screen-reader text ("updating as the page is read") show this; the dot stops with reduced motion. It moves once, when they're in.
  • Instructions › Quality's segment shows the same score.

Hooks fixed on the way, found in the pre-push review

  • useClaims: a save whose claims weren't asked about yet counts as reading. Before, the score could settle in the 3–30 s before the ask. A claims ask that throws clears its pending count.
  • useSourceClasses now says when a site is still to be read.
  • useLinkChecks: a call that fails on its own (network, a deploy meanwhile) counts as a failed read for that save. Before, the chip could read forever.
  • If the authors fail to load, the score still settles (authorsTried).

Related issue

User report (tested on app.ansvisor.com): the score jumps while the page loads and after the agent's rewrite.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open a draft with links. The chip says "Quality · reading…", then one number appears; it doesn't step through 90 → 45 → 59.
  2. Add a link and wait for the save. The number stays, with a pulsing dot, until the link is read, then it updates once.
  3. Phase 2: the chip also waits for an edit's save and then the claims' read, about 3 s after it. While you type it keeps the last number with a pulsing dot.
  4. Phase 2, a long page not read yet (an imported page, the agent's rewrite): the claims are read in asks 30 s apart (CLAIMS_EVERY_MS), and the chip waits for all of them, so a long page says "reading…" for a minute or more. That is intended: the number moves once, not after each ask.

Browser check at 1024 px (the reading label is longer than "Quality 59") is still owed, batched with the other editor fixes.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Web: yarn test (CHECK_TESTS) and yarn build pass.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 24, 2026 21:56
…e in

The header's Quality chip showed the average of whatever was read first:
Readability alone (90), then with E-E-A-T (45), then with Trust (59),
within seven seconds of opening a page or after the agent's rewrite. It
now says "Quality · reading…" until the authors, Your input, the site's
trust, the sources, the links and (phase 2) the claims are read or
failed, and keeps the last settled score while new reads land (a pulsing
dot, aria-busy). Instructions › Quality's segment shows the same score.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the Quality score settles

Pre-push review fixes:
- a save the claims weren't asked about yet counts as still reading, so
  the score doesn't settle in the gap before the ask (phase 2);
- useSourceClasses says when a site is still to be read; the score waits;
- a link check call that fails on its own counts as a failed read (the
  chip could read forever); a claims ask that throws clears its pending;
- the pulsing dots stop with reduced motion; aria-busy dropped (the
  screen reader text says it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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

A few fixes before merge:

  1. A link the API answers without reading keeps the chip on "reading…". _use-link-checks.ts:87-91: pending counts a link until it has a read, is skipped, or its ask failed at this save. The links route leaves out the links past the member's hourly reads (checkLinks: "a link over it isn't in the answer"), and the hook asks about those again only after the next save. Since qualitySettled now needs linksPending === 0 (_draft-editor.tsx:821), a page someone opens to read without editing says "Quality · reading…" for the whole session. An href the saved page writes differently from the editor does the same.
    Fix: after a successful answer, count each link asked at this save that the answer neither read nor skipped as answered for this save. For example, add it to failedAt at savedAt. It is then asked again after the next save, but it doesn't hold the score. Add a test with an answer that leaves a link out.

  2. Phase 2: an edit shows a partial score before its save. useClaims doesn't count unsaved changes as reading (_use-claims.ts:137-142). The editor's autosave.state !== 'saved' (_draft-editor.tsx:609) only holds the ask. Here is what happens after Accept on the agent's page, or any edit:

    • pageHtml updates after 400 ms, and the save lands about 1.5 s later.
    • In between, qualitySettled is true while the claims are still the old page's. Claims that no block has any more are left out of Trust, so the chip moves to that partial score.
    • After the save it pulses, then moves again when the claims are read.

    That is the two-step jump this PR removes, after the agent's rewrite.
    Fix: in phase 2, hold qualitySettled while a save is waiting or under way (autosave.state === 'unsaved' || autosave.state === 'saving'). Pass useClaims the same narrower flag as unsaved. Today the hook also gets failed, conflict and too_large as unsaved. If a save that the hook hasn't asked about is followed by one of those states, askedSave !== savedAt stays true and the ask stays held. The chip then pulses until the save recovers, or until a reload after a conflict.

  3. Two open PRs add reads that also move Trust: #1465 (the brand facts: useBrandFacts, passed to trust() as brandFacts) and #1468 (the page read's proofs: usePageRead, passed as proofs). Neither is on main yet. qualitySettled doesn't wait for them, so once they're in, the chip settles in phase 2 before they land and moves again when they do. Whichever lands second should add factsState.status !== 'loading' and the page read (pageRead.settled && !pageRead.reading) to qualitySettled, with a page test.

  4. (low) Sources left unasked after a failed ask (_use-source-classes.ts:94). The effect reruns on kinds, and kinds only changes on a successful answer. When an ask fails, two kinds of site stay unasked at this save while reading still counts them:

    • the sites past the first MAX_SOURCE_SITES;
    • a site whose ask was still out when a newer save came in. The new save skipped it because it was still in asking.

    The chip then waits for the next save. Adding answered to the effect's deps gets them asked at this save.

  5. (low) Long pages hold for a minute or more in phase 2. Each claims ask makes at most two calls, and asks are CLAIMS_EVERY_MS apart. Since pending > 0 counts as reading, a long page that hasn't been read yet (an imported page, the agent's rewrite) says "reading…" for 30 s per further ask. If that's intended, the test plan's "about 3 s" should say so. If not, settle once the first ask is back and let the dot pulse for the rest.

Checked and fine: these all settle as they should:

  • phase 1 (claims and site kinds off);
  • the API answering off, ai_budget or the day's cap (limited);
  • a claims or sources ask that fails or throws;
  • authors, site trust or sources that fail to load;
  • an empty page;
  • a page with no links or no unplaced sites.

A settled score of null hides both chips without looping.

cihan-gyk and others added 2 commits October 24, 2026 23:57
… pending saves

Review fixes on the settled Quality chip:
- a link the links answer leaves out (over the hourly reads, or written
  differently on the saved page) counts as answered at this save: asked
  again after the next save, it doesn't hold the score
- phase 2 holds the score while a save waits or is under way, and the
  claims hold their ask only then (not after a failed save, a conflict or
  a page too large, where no new save is coming)
- each sites answer, a failed one too, lets the sites past the batch be
  asked at the same save

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Thanks! Fixed in 49f7240 and 77f6bca:

  1. A link the answer leaves out no longer holds the chip. After a successful answer, each link asked at this save that the answer neither read nor skipped (over the hourly reads, or written differently on the saved page) is marked as answered at this save. It's asked again after the next save.
    • The "link not saved yet" test now expects pending 0 after that answer, and 1 again after the next save until it's read.
    • Pre-push review found one more case. An older save's ask that answered late (or failed) could overwrite a newer save's mark and put the chip back on "updating" until the next edit. A failed or left-out link is now marked only while that ask is still the last one about it. There's a test for this.
  2. Phase 2 holds the score while a save waits or is under way (autosave.state 'unsaved' or 'saving').
    • useClaims gets that same narrower flag, so a failed save, a conflict or a page too large no longer holds its ask. The last saved page is read.
    • A page test types into the editor: the chip keeps its number and says it's updating until the save lands and the claims are read. Without the fix it moved before the save.
  3. Noted. Whichever of feat(content): check a page's prices against approved brand facts in Trust, with an Approve to-do (CE-047, part d) #1465 / feat(content-editor): ask for the proof of the page's own claims as to-dos (CE-049, part b) #1468 lands after this one adds factsState.status !== 'loading' and pageRead.settled && !pageRead.reading to qualitySettled, with a page test.
  4. answered is in the effect's deps. The sites past the batch, and those held while their ask was out, are asked at the same save after a failed answer, with a test.
    • There's no re-ask loop: sites already asked at this save are skipped, and so are sites whose ask is still out.
  5. Long pages: intended. The number should move once, not after each 30 s ask. The test plan now says a long unread page reads "reading…" for a minute or more in phase 2.

Checks: yarn format, lint (0 errors), typecheck, test (3,600 passed) and build pass on 49f7240. After 77f6bca (one hook and its test), I re-ran lint, typecheck and the editor's tests (203 passed).

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

All items done. Looks good.

  1. Done. Once an answer is in, any link that was asked at this save and left out of the answer is marked as answered at this save. An older ask that answers late can't overwrite a newer save's mark. Both cases have tests.
  2. Done. In phase 2 the score holds while a save is waiting or under way, and useClaims gets the same narrower flag. A failed save, a conflict or a page that is too large no longer holds the ask. A page test covers this.
  3. Open, and it moves to the PRs that land after this one. No open head adds the brand facts or the page read to qualitySettled yet. #1465 and #1468 should add them when they merge main forward after this PR.
  4. Done. answered is now in the effect's deps, there's no re-ask loop, and a test covers it.
  5. Answered. The long-page hold is intended, and the test plan now says so.

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.

2 participants