Skip to content

feat(content-editor): show a version 2 brief's plan in the Brief tab and edit its TL;DR, angle, answers and proof (brief rules PR 9) - #1546

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/brief-tab-v2
Oct 26, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/brief-tab-v2

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Brief rules 2026, PR 9 of 10: the Brief tab shows a version 2 brief's plan, and Edit brief edits it.

What the tab shows for a version 2 brief

  • TL;DR and Angle: rows under Goal and Audience.

  • Each section:

    • its format as a tag beside the H2 (Table, Steps…);
    • "Answer first: …", the note on what its first sentences must say;
    • its facts, each "Statistic: claim" with "From " or "Source to find".
  • Proof to gather: the brand's own proof, each with its kind.

    • Once Brief › Your input is read, a kind it has is marked "In Your input". A case or a test counts as experience (inputsGiven).
    • Otherwise Add input opens Your input, as Quality's Add does. Each button is named by its proof for a screen reader ("Add input: Average bags per week").
  • Writing notes, folded until opened (kept in the page while hidden, so the button's aria-controls names it):

    • the names as written (brand, products, competitors);
    • the links planned: internal or outbound, the words to link, the page, the H2 they go in. An outbound link shows its site (sca.example/brew), an internal one its path;
    • freshness (the point to date, an "Updated" date, the year in the title);
    • the fan-outs left for another page.

    These are the writer's notes, so they're read-only here.

Edit brief, for a version 2 brief

  • TL;DR and Angle textareas, cut to the web's limits.
  • Each section's "Answer first", with its own label: once filled, a placeholder alone wouldn't tell it from the key points.
  • Proof to gather: a kind and the words for each, with add and remove, 6 at most.
    • An empty proof is dropped on save, and an empty TL;DR, angle or answer saves as null.
  • Formats, facts and the writing notes are kept as they were, as feat(content): read and keep the brief's version 2 through Edit brief (brief rules PR 3) #1539 already keeps what Edit doesn't show.
  • Whether the form shows the version 2 fields is read once, when Edit opens, so a rebuild landing meanwhile doesn't change what Save writes.

Related issue

Roadmap CE-EVAL-001 / brief rules 2026 (no GitHub issue).

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. Run the tests:
    cd web && yarn vitest run "src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_brief-tab.test.tsx"
  2. On a dev DB, put a version 2 brief on a draft. web/src/lib/content/__fixtures__/brief-v2.json is one. You can also rebuild with feat(content): plan each section's answer, format and facts in the brief behind CONTENT_BRIEF_RULES, with the cited pages numbered and the rules in effect (brief rules PR 4) #1540, feat(content): plan the page in the brief behind CONTENT_BRIEF_RULES: essentials, angle, proof to gather, fan-outs left out and freshness, with Brief › Your input as sources (brief rules PR 5) #1543 and feat(content): name the brand, its products and competitors as written, and plan links to the pages listed only, in the brief behind CONTENT_BRIEF_RULES (brief rules PR 6) #1545 deployed and CONTENT_BRIEF_RULES=true.
  3. Open the draft's Instructions › Brief and check that the TL;DR, the angle, each section's format, answer and facts, the proof list and Writing notes show.
  4. Click Edit brief, change the TL;DR, an answer and a proof, and save.

I checked this in the browser at 1024 px, light and dark, on a demo draft with a version 2 brief (put back afterwards).

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 checks, run locally after the review fixes:

  • yarn format: no changes.
  • yarn lint: 0 errors.
  • yarn typecheck: clean.
  • yarn test: 424 files, 4,020 passed.
  • yarn build: OK, with CI's placeholder env.

Then I merged today's main (with #1541's rules in the side panel) with no conflicts, and ran the typecheck and the Brief tab, editor page, rebuild and agent-write tests again: 278 passed.

Tests:

  • the TL;DR, the angle and each section's answer, format and facts;
  • the proof list, marked by Your input, with Add input opening it;
  • no Add input until Your input is read;
  • the writing notes folded until opened, with each kind of note;
  • none of it for a brief before version 2;
  • editing the TL;DR, angle, answers and proof, keeping the notes, formats and facts;
  • no version 2 field added to an older brief;
  • a proof's kind changed in its select, and 6 proofs at most;
  • the region hidden while folded, the outbound site, each Add input's name.

Pre-push review

A review agent read the change before the push. It found nothing high and confirmed:

  • answer: null and tldr/angle null are safe for draftBriefSchema;
  • the byte limit still shows "too long";
  • Add input scrolls to Your input as Quality's does;
  • the tests fail without the change.

Fixed from it:

  • an outbound link showed only its path;
  • aria-controls pointed at nothing while the notes were folded;
  • several identical "Add input" names;
  • a rebuild landing while Edit is open could make Save write nulls over the new plan;
  • keys that could repeat;
  • the notes' punctuation outside en.json;
  • a fact's tooltip showing a raw ref;
  • long words overflowing at narrow widths;
  • InputsGiven is now exported from draft-inputs.ts;
  • test gaps.

🤖 Generated with Claude Code

cihan-gyk and others added 3 commits October 26, 2026 15:55
…(the TL;DR, the angle, each section's answer, format and facts, the proof to gather against Your input, and folded writing notes) and edit its TL;DR, angle, answers and proof (brief rules PR 9)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…otes in the page while folded, name each Add input by its proof, read the editor's version once, and move the notes' punctuation into en.json (pre-push review)

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.

Looks good, with follow-ups.

What I checked:

  • How brief text reaches the page.
    • Every new field is rendered as React text or an attribute (title, aria-label). There's no dangerouslySetInnerHTML, no <a>, no href or src.
    • t() and t.rich() take the brief's words as values, which aren't parsed. The <muted> tags come from en.json only.
    • A fact's source shows its label as text. Its ref isn't rendered anywhere.
    • A planned link shows its words and its page as text, and its address only as a title. draftBriefSchema keeps a link only with an http(s) address, and drops the rest.
  • A brief before version 2.
    • Each new row, list and the notes render only when their field is there, so such a brief shows nothing new.
    • The H2 line is now a flex row. It looks the same, except that a long heading wraps under itself.
    • Edit brief adds nothing to it. With v2 false there's no tldr, angle, proof or answer key, and version stays absent. The test pins this.
  • Edit brief, version 2.
    • The limits are BRIEF_V2_LIMITS, the ones draftBriefSchema reads with: TL;DR and angle 500, an answer 600, and at most 6 proofs of 300.
    • An empty TL;DR, angle or answer saves as null, which v2text accepts. An empty proof is dropped.
    • Each section keeps its format and facts through ...s, so they move with it, and a removed section takes them along.
    • entities, links, freshness, leftOut and version are kept through ...brief.
    • v2 is read once, when Edit opens.
    • Save goes through saveDraftBrief, unchanged: it parses with draftBriefSchema, then checks the 64 KB, and "too long" still shows.
    • The kind's Select gets items, and a value that isn't a listed kind is ignored.
  • Proof and Your input.
    • given is set only once Your input is read. While it loads, fails or is off, given is null, so there's no mark and no Add input.
    • inputsGiven is Quality's own, and it follows Your input as the person edits it.
    • A case or a test counts as experience, as brief.ts and the server's prompt say.
    • Add input calls the editor's addInput, as Quality's Add does: it opens the panel and the Brief tab, and scrolls to Your input.
  • Accessibility.
    • The Writing notes toggle is a button in the h4, with aria-expanded. Its aria-controls names the dl, which stays in the page with hidden while folded. The chevron is aria-hidden.
    • Each Add input is named "Add input: ", visible words first.
    • In Edit, each kind, proof and Remove control is named by its number, and the TL;DR, the angle and each answer have a label.
  • Strings. Every new string is in en.json. The formats, fact kinds and proof kinds have a key for each value of the schema's enums, and the schema reads any other value as none.
  • Tests.
    • The view, proof, notes and edit tests fail without the change.
    • The two version 1 tests pass either way, as guards should.
    • They render the real component. Only the action is mocked; see item 3.
  • Merge.
    • The PR's own change, from main at 062792e to 912f8d2, is these five files and nothing else. So the merge of main (912f8d2) hides nothing.
    • Of these files, main has since changed only en.json. A three-way merge of it is clean, and the result parses with no repeated keys.
    • Web only, no migration.
  • Before and after the API deploy.
    • The API on prod writes no version 2 brief, and the flag is off. So every brief there looks and edits as it does today.
    • Nothing a user sees changes at merge, or at the API deploy while the flag is off.

Earlier open items:

  • A fact's source ref isn't checked to be http(s) (#1540 item 3).
    • Not touched, and still safe: this PR shows only the label and links nothing.
    • draftBriefSchema checks link addresses, but reads a fact's ref as plain text.
    • Keep it open for the first change that opens a fact's source.
  • Nothing reads leftOut, entities or links (#1543 item 4, #1545).
    • Partly done: the Brief tab now shows them.
    • The writer's briefText and the fan-out rules still don't read them.

Follow-ups:

  1. "In Your input" is read by kind, not by proof (web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_brief-tab.tsx:427, :434-452; web/src/lib/content/draft-inputs.ts:197).
    • Any table, or any Ansvisor row picked, marks every data proof "In Your input", whatever it holds. "Returns by model" then reads as given and loses its Add input, when it's exactly what's missing.
    • With Quality below phase 2, Your input isn't shown. The proof list still says "Add it in Your input" (web/messages/en.json:4347).
    • Fix:
      • Word the mark by kind: "Your input has data" or "Your input has experience", by PROOF_INPUT. Keep Add input on the row.
      • Pass whether Your input is on (yourInput != null). When it's off, leave "Add it in Your input" out of the info line.
  2. Renaming or removing an H2 in Edit brief leaves a planned link pointing at it (_brief-tab.tsx:621, :703-705).
    • links[].section names an H2 by its text, and ...brief keeps it as it was.
    • So after a rename, Writing notes say "in 'Old heading'", and the writer, once it reads links, won't find that H2.
    • Fix:
      • Keep each section's heading as built (was: s.heading) in the editor's state.
      • On save, move a link's section to the new heading, or to null when its H2 is gone.
      • Or have the writer read a section it can't find as anywhere.
  3. No test checks that what Save sends passes the schema (_brief-tab.test.tsx:542, :563).
    • The mock returns the brief as sent, so a field draftBriefSchema refuses would still pass here and fail in the app as "Couldn't save".
    • Fix:
      • In the version 2 edit test, assert draftBriefSchema.safeParse({ ...saved, origin: 'edit' }).success.
      • Add a fact whose ref isn't an http(s) address, and assert the tab renders it as text with no link. The first change that links a source then has to check the ref.

@gkhngyk
gkhngyk merged commit 54da3b1 into ansvisor:main Oct 26, 2026
6 checks passed
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