Skip to content

feat(content): add Brief › Your input, and count the experience, data and quotes the page uses (CE-048, part a) - #1452

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/quality-your-input
Oct 24, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/quality-your-input

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Quality Phase 2, CE-048 "Brief › Your input", part a: the block, where it is kept, and how Quality counts it. Part b, the Content Agent writing from it as numbered sources, is the next PR. Everything sits behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE=2. At phase 1, nothing is read or shown.

Brief › Your input (_your-input.tsx) sits at the top of Brief, titled "Your input · used only as you write it" (spec §6):

  • Your experience: free text, up to 4,000 characters. It is kept on Save, or when the person leaves the box.
  • Your data:
    • Ansvisor data cards come from the draft's prompts with answers. The prompts the draft targets come first, then the most answered. A card reads, for example, "From your Ansvisor data: in 825 answers to “…” over the last 30 days, you were named 28 times."
    • Use this keeps the numbers with the day they were used (asOf, in the person's time zone) and days: 30 (Sources' window). The block cites them as "Ansvisor data, October 2026", as the spec says, and asOf/days let part b name the exact window if you'd rather.
    • Upload CSV or Excel (up to 10 MB) is read in the browser with the same readers as Attach.
    • Or the person can paste numbers: CSV, or tab-separated from Excel or Google Sheets.
    • A table keeps 100 rows × 12 columns at most. Each cell is cut to 200 characters, never half of one, with NUL removed.
    • Up to 5 tables, kept to the database's 64 KB: a table that doesn't fit keeps its first rows that do, and says so.
  • Expert quotes: name, title and company, the quote word for word, and an http(s) source link. All four are required. It says "Add quotes from real people only." They are kept to the database's 16 KB.
  • Guard note (dark card): "Content Agent never makes things up. …"

Kept per draft: 00265 content_draft_inputs. It is one row a draft, beside the brief, so a rebuilt brief leaves it.

  • RLS: members of the draft's workspace read and write it, through content_draft_member(), as the draft itself. A write must name its writer (updated_by = auth.uid()), as in 00214.
  • Size checks: experience ≤ 4,000 characters; data ≤ 5 tables and 64 KB; Ansvisor data ≤ 10 and 16 KB; quotes ≤ 10 and 16 KB.
    • The editor measures sizes as Postgres writes jsonb as text (jsonbBytes, checked against octet_length(…::jsonb::text)), so a save is never turned away for size.
  • The server actions validate with Zod (draftInputsSchema) and upsert the whole input.
  • A read keeps what still fits the schema item by item (keptInputs), so one stale item doesn't empty the block, and the next save doesn't write over the rest.
  • A change is made to the input as it is when it lands. A file read meanwhile or a card used isn't lost.
  • A failed save says so and reads the input again. A change made since wins over that read.

Quality counts what the page uses (inputsUsed), only as far as it can be read:

  • An expert's quote, word for word. The marks around it and dash kinds don't matter.
  • A figure from the person's data: a share (42%, %42), a decimal, or 3+ digits that aren't a year. Thousands separators are read alike.
    • Dates and their pieces, years and small counts ("in 2026", "12 steps") are anyone's numbers, so they don't count.
  • Ansvisor data: its answers and mentions together in one sentence.
  • The experience, by its own runs of three words (one word of 5+ letters among them). At least 30% of them and at least 3 must be on the page, so its topic or common words alone don't count.

Then:

  • E-E-A-T gains experience (20) and original data (15) from spec §2.1.
  • Trust gains expertQuote (8). A quote alone doesn't score Trust: it still waits for a figure or a dated source.
  • In phase 2, E-E-A-T, Trust and the to-dos wait until the input is read, so no score jumps while it loads. A read that fails leaves them without it, and Brief says "Couldn't read your input. Try again".
  • Your to-dos gain three: Add your own experience, Add your own data, Add an expert's quote.
    • Each shows its gain on its own score (E-E-A-T or Trust; QualityTodo.score is new).
    • Add opens Brief and scrolls to Your input, from Quality and from the Next nudge.
    • Something given but not used yet says so ("It's in Your input, but the page doesn't use it yet").

Some copy ("the agent writes from it as you give it", "let the agent write from it") describes what part b adds. Phase 2 stays off until part b lands with it.

Related issue

Quality spec (Drive), Phase 2, CE-048 (part a). Independent of #1449–#1451 (from main).

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. Apply 00265 and set NEXT_PUBLIC_CONTENT_QUALITY_PHASE=2 in web/.env.local.
  2. Open a draft with tracked prompts and open Instructions › Brief. "Your input" is at the top, with Ansvisor data cards for the draft's prompts.
  3. Click Use this on a card. It moves up with "Cited as “Ansvisor data, …”". Reloading keeps it.
  4. Upload a small CSV (e.g. Teams,Share / 1250,42%). It is listed with its row count. Paste numbers and add them too.
  5. Add a quote. Add quote stays off until all four fields are filled and the link starts with http(s).
  6. Type an experience and click away. Reloading keeps it.
  7. Open Instructions › Quality. Your to-dos list the three new items with their gains. The experience one says it's in Your input but not used yet. Add opens Brief at Your input.
  8. Write a number from the CSV into the page, or the quote word for word. That to-do is checked off and its score rises.
  9. With the flag at 1, none of this shows and nothing is read.

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

00265 is applied on the dev DB and schema.sql is rebuilt. I checked its policies there inside a rolled-back transaction, signed in as a member: a write naming someone else as updated_by is refused, one naming the member goes through, and oversized Ansvisor data hits its check. Web: format, lint (no errors), typecheck, all 3,390 tests and the build pass.

I haven't checked it in the browser in both themes yet; it goes into the next local test session, with screenshots.

🤖 Generated with Claude Code

… and quotes the page uses (CE-048, part a)

Quality phase 2 (NEXT_PUBLIC_CONTENT_QUALITY_PHASE at 2):

- Brief › Your input, at Brief's top: the person's experience; their data
  (Ansvisor data cards from the draft's prompts, kept with the day and
  the 30 days they cover; CSV or Excel read in the browser; pasted
  numbers, tabs included); expert quotes with name, title, the words and
  an http(s) source; the guard note
- 00265 content_draft_inputs: one row a draft, members only, a write
  names its writer; sizes as the editor keeps them (jsonbBytes measures
  jsonb as Postgres writes it)
- inputsUsed: a quote word for word, marks around it aside; a figure from
  the person's data (a share, a decimal, 3+ digits that aren't a year);
  Ansvisor data's two numbers in one sentence; the experience by its own
  runs of three words
- E-E-A-T gains experience (20) and original data (15), Trust expertQuote
  (8); in phase 2 they wait for the input; Your to-dos gain three, each
  with Add opening Brief › Your input, and say when given but not used
- changes are made to the input as it is when they land; a failed save
  reads it again unless a change came since; a failed read offers Try
  again

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 24, 2026
cihan-gyk and others added 2 commits October 24, 2026 14:59
…r-input

# Conflicts:
#	supabase/schema.sql
#	web/messages/en.json
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx
#	web/src/lib/content/quality-checks.test.ts
#	web/src/lib/content/quality-checks.ts
#	web/src/types/supabase.ts

@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. Two small follow-ups and a note for part b.

00265 dry-run against the production schema (rolled back): it applies cleanly. RLS is on and 4 policies are created. A member reads, writes and deletes their own draft's row. A write that names someone else as updated_by, or names no one, is refused. Another workspace sees nothing and can't update, delete or insert. anon is refused. Every size and shape check holds. updated_at moves on update, and the row goes with its draft. schema.sql matches the migration, and the merge of main carries no changes beyond the two sides.

Phase 1: useDraftInputs is off below phase 2, so nothing is read, shown or saved, and E-E-A-T, Trust and the to-dos get used: null / quote: null, as before. The Ansvisor data cards come from content_draft_sources, which already checks membership and is scoped to the draft's brand.

  1. Quote fields have no length limit in the UI (_your-input.tsx:381-405). quoteSchema caps name, title, text and link at 120 / 160 / 600 / 2048. The inputs have no maxLength, so past a cap Add quote just stays disabled, with nothing saying why. Give the four inputs maxLength={…} from the same constants, as the experience box has. A count under the quote text would help too.

  2. asOf depends on a locale's date format (_your-input.tsx:264). new Date().toLocaleDateString('en-CA') gives YYYY-MM-DD today, but the en-CA short date format has changed between ICU/CLDR releases before. If it isn't ISO, z.iso.date() turns the whole save away and the card is dropped on the re-read. Build the local day from getFullYear() / getMonth() + 1 / getDate(), padded.

  3. For part b: ansvisor_data is saved as the browser sends it, and promptId and the counts aren't checked against the draft. That's fine while it's only shown back to the same workspace. When the agent reads it on the server, take the numbers for each promptId from the draft's own sources (content_draft_sources for the draft) instead of the stored values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants