Skip to content

feat(content): open the Content Editor from Content Opportunities - #1334

Merged
gkhngyk merged 13 commits into
ansvisor:mainfrom
cihan-gyk:feature/opportunity-content-entry
Oct 22, 2026
Merged

gkhngyk merged 13 commits into
ansvisor:mainfrom
cihan-gyk:feature/opportunity-content-entry

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

From the user's spec (Content Editor entry points, PR B of 2), with their follow-up choices: go from Content Opportunities straight to the Content Editor, and simpler buttons.

Opportunity panel (OpportunityActions, new)

  • Three buttons in front, in the user's order: Send to Actions, Generate Brief, Send to Editor. Each turns into its done state in the same place: Open in Actions, Brief Generated, Open draft.
  • The rest go in a "…" menu on the right: Send to Plan, Another angle, Send to Workflow, Copy All Data, Mark as reviewed, Restore, Dismiss. The "Another angle" link next to the badges moves into the menu.
  • Send to Editor is the filled button, because it's the new main path. Generate Brief is now outline.

Opportunities list (OpportunityRowMenu, new)

  • A row's actions now live in one "…" menu, the same as the panel's: Send to Editor / Open draft, Send to Plan / Open in Plan, Send to Workflow, Open in new tab, Dismiss.
  • The Actions column narrows from 176 px to 96 px, which gives the titles more room at 1024 px.

Send to Editor opens New content › Start. Start is the step that picks the page and type before the editor opens.

  • Which page: a create decision starts a new page. Every other decision (optimize, expand, refresh, consolidate, defend) starts on the opportunity's first target page, the way the Content plan does (lib/content/opportunity-start.ts).
  • Page type: it follows feat(content): suggest opportunity content types by the brand's site type #1332's rules.
  • When it shows: only for owned work that's still open (new, reviewed, sent, in progress). Earned work lives on other sites, and New content doesn't list closed opportunities.
  • Open draft: shown when a draft not yet published was started from the opportunity (getOpportunityDrafts, one read per page of rows).

Send to Plan marks the opportunity's Plan row as a priority, so it ranks first with a Priority tag. It uses content_plan_marks from #1321.

  • Admins and managers only, matching that table's write policy.
  • Once the row is a priority, the item reads Open in Plan. getPlanPriorities reads which rows already are.
  • A toast confirms the change and links to the Plan.

Stacked on #1332 and #1321 (with #1320 and #1319):

Web only, no new migration.

Related issue

None. Product spec from the user.

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. Content → Opportunities → "…" on a row. The menu shows Send to Editor, Send to Plan, Send to Workflow, Open in new tab and Dismiss.
  2. Send to Editor on a create opportunity opens Start for a new page, with the opportunity's page type picked.
  3. Send to Plan shows the toast "Added to the Plan's priority list". The item then reads Open in Plan, and the Plan lists the row first with a Priority tag.
  4. Open an opportunity. Send to Actions, Generate Brief and Send to Editor are in front, and the rest are under "…".
  5. Send to Editor on an expand opportunity opens Start on its page. Escape closes Start, and the panel stays open.

I checked it in light and dark, at 1024 px and wider, and on the full-page view of an opportunity.

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

yarn test: 286 files, 2,524 tests pass, with #1321 and #1332 merged in. yarn build passes with CI's placeholders.

🤖 Generated with Claude Code

cihan-gyk and others added 8 commits October 21, 2026 21:39
…e in its final layout

- "What AI cites in your topics" drew both shares on one track scaled to
  AI's largest share, so a type the brand leans on more than AI does
  (e.g. 35% · 73%) ran its bar past the track onto the shares column. The
  two shares are now two thin bars on one scale, the larger of the two,
  never past the track.
- The list and the sections above it (AI results, the mix) were read and
  drawn apart, so the list showed mid-screen first and jumped down when
  the sections came in. The page now shows one spinner until both reads
  are in; a list that fails says so at once.

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

More of the brand's pages cited for the same prompts is no loss (AI
answers aren't a ranking), so neither Start nor the Plan treats it as a
problem any more:

- Start's "Overlap check" is an "Overview": a plain box listing the
  brand's pages AI already cites for these prompts, with no amber warning,
  no "Safe to create" and no "Recommended". The action the person clicked
  stays chosen (Create stays Create); the choices are the plan's page when
  it named one, a new page, and optimizing the page cited most.
- The Plan drops the Overlaps card, the ⚠ Overlap tag on rows, and the
  rows that were listed only because another page of the brand is cited
  for the same prompts.

content_plan_pages (00220/00221) still returns overlaps; the Plan no
longer reads it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each Priority list row gets a "…" menu:
- Assign to… (every member): a row with a draft assigns its Action
  Center task (sending the draft first when needed); a row without one
  opens Start on Team, which now has an "Assign to" picker. The Who
  column shows the assignee.
- Mark as priority (admins and managers): the row goes to the top with a
  Priority tag; a Priority card counts and filters the marked rows.
- Hide from the plan (admins and managers): the row leaves the list, with
  Undo and "N hidden rows · Show"; an opportunity's row also dismisses the
  opportunity and gets its status back when shown again.

Migration 00229 adds content_plan_marks (members read; admins and
managers write).

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

Content Opportunities gave every brand the same ten asset types, so a
shop could get a glossary or landing page and a SaaS brand a product or
category page. The generator now reads brands.site_type (or the
editor's guess from Shopping mode and industry), lists that site's page
types with their formats in the prompt, and limits assetType and the
supporting types to them, plus the earned third_party_article and
backlink. No calculation changes.

Older opportunities keep their stored types and are read as the brand's
page types (pillar_guide -> guide / buying_guide, landing_page ->
solution_page / collection_page / destination_page, and so on). The
opportunities list, the drawer, the assets card and Copy All Data name
them with the editor's labels. Start preselects an opportunity's type
for a new page; an existing page goes by its own address or title
first. The Content Plan follows the same rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	web/src/components/content/new-content-dialog.tsx
#	web/src/lib/actions/content-plan.ts
From the user's spec, PR B of the Content Editor entry points, with the
user's follow-up choices:

- Opportunity panel: three buttons in front, in this order: Send to
  Actions, Generate Brief and Send to Editor. Each turns into its done
  state in place (Open in Actions, Brief Generated, Open draft). The
  rest move into a "..." menu on the right: Send to Plan, Another angle,
  Send to Workflow, Copy All Data, Mark as reviewed, Restore, Dismiss.
- Opportunities list: a row's actions sit in one "..." menu: Send to
  Editor or Open draft, Send to Plan or Open in Plan, Send to Workflow,
  Open in new tab, Dismiss. The Actions column narrows to fit.
- Send to Editor opens New content > Start. A create decision starts a
  new page; any other decision starts on its first target page
  (lib/content/opportunity-start.ts). Owned work still open only.
  getOpportunityDrafts finds the draft already being written.
- Send to Plan marks the opportunity's Plan row as a priority
  (content_plan_marks, ansvisor#1321) for admins and managers;
  getPlanPriorities reads which rows already are.

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

Copy link
Copy Markdown
Collaborator Author

@gkhngyk This is PR B of the user's Content Editor entry points. Opportunities now open straight in the editor (Send to Editor / Open draft), and the panel and the list rows each keep their actions in one "…" menu. At the user's request it adds Send to Plan: it marks the opportunity's Plan row as a priority, using #1321's content_plan_marks, for admins and managers only.

Stacked on #1332 and #1321 (plus #1320/#1319). #1321's branch is merged in (fa7a50e0, conflicts resolved keeping both sides), so the diff includes those PRs until they land; this PR's own commit is 355ebc1b. I'll merge main forward as they merge.

It's web only with no migration, and web tests (2,524) and the build pass.

@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 22, 2026

@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 small fixes before merge. I reviewed this PR's own commit (355ebc1b) and the conflict resolution in fa7a50e0. The resolution is fine: the hidden-row read selects OPPORTUNITY_COLUMNS, so assetType works for hidden rows too. Everything else in the diff belongs to #1319/#1320/#1321/#1332.

  1. A failed drafts read offers Send to Editor, which can start a second draft. web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx:513 and web/src/components/content/opportunity-detail.tsx:156: when getOpportunityDrafts fails, the code treats it as "no draft", so the row and the panel show Send to Editor even when a draft exists. Keep the failure separate from "none". Leave the item disabled with a retry, or show a toast when the read fails, so a failed read never turns into a second page for the same opportunity.

  2. Send to Plan from the panel doesn't update the list. opportunity-detail.tsx:177 sets the panel's own priority, but the list's priorities (page.tsx:523–549) keeps the old value. The row menu says "Send to Plan" until the page reloads. Calling onChanged won't fix it: loadData keeps the same shownIds, so the priorities aren't read again. Pass an onPrioritized(id) callback from the page into the panel (the page's <OpportunityDetail … onChanged> at page.tsx:1749), or move the priority state up to the page.

  3. Start's page type uses the wrong brand when the opportunity isn't from the active brand. opportunity-detail.tsx:848 uses siteTypeOf(activeBrand), but the dialog runs on opportunity.brandId. /dashboard/content/[id] can open an opportunity from another of the org's brands. Look up the brand by opportunity.brandId (s.brands.find((b) => b.id === opportunity.brandId)).

  4. Dead strings. After this change nothing reads content.send (web/messages/en.json:4011, the old row "Send" label) or content.alternative.hint (en.json:4144, the old tooltip on Another angle). Remove both, or put the hint back as the menu item's title.

  5. Unused test mock. web/src/lib/actions/content-drafts-start.test.ts:71 adds a contains filter to the mock, but no code in this PR calls it. #1333 adds the same line, so the two will conflict. Drop it here.

  6. Nit: the content prop's doc at web/src/components/content/opportunity-actions.tsx:64 still says "null when it isn't offered", but the type isn't nullable. canStart covers that case now.

Merge notes

  • Because it carries #1321, this branch now conflicts with main in supabase/schema.sql (00235 landed). Regenerate the file with build-schema.sh after rebasing.
  • It also conflicts with #1333 in content-drafts.ts, where both PRs add a function after getContentStartOptions, and in its test. Keep both.
  • The conflicts with #1323, #1325 and #1328 come from #1321/#1332, not from this commit.

cihan-gyk and others added 4 commits October 22, 2026 12:02
# Conflicts:
#	supabase/schema.sql
#	web/messages/en.json
#	web/src/app/[locale]/(dashboard)/dashboard/content/plan/_plan-insights.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.test.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/plan/page.tsx
#	web/src/components/content/new-content-dialog.test.tsx
#	web/src/lib/content/plan.test.ts
#	web/src/lib/content/plan.ts
… only what is still dismissed

hidePlanRow and showPlanRow no longer take an opportunity id from the client:
the server reads it from the row key the mark is written under (a uuid, or
'invalid'). Show again gives an opportunity back its status only while it
is still dismissed; one completed or reopened elsewhere keeps its status and
only the mark goes. Hidden rows read only dismissed opportunities. The
Priority card's dot is in ink, as its outline badge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and tell the list about Send to Plan

- A failed getOpportunityDrafts is no "no draft": the row menu and the
  panel offer "Couldn't check for a draft · Retry" instead of Start, so a
  failed read never starts a second draft for the same opportunity.
- Send to Plan from the panel calls the page's onPrioritized, so the row's
  menu says Open in Plan without a reload.
- Start's page types come from the opportunity's brand, not the active one.
- content.send is gone; content.alternative.hint is Another angle's title.
- Drop the unused contains mock and fix the content prop's doc.

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

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Thanks, all six are in 92a4aaac, on top of a merge of #1321's fixes (92ad9e92, which also brings main; schema.sql matches a rebuild):

  1. A failed drafts read no longer offers Send to Editor. The page and the panel keep the failure apart from "none". The row menu and the panel then show "Couldn't check for a draft · Retry", which reads again. Start isn't offered until a read succeeds.
  2. Send to Plan from the panel updates the list. OpportunityDetail takes onPrioritized(id), and the page passes its markPrioritized, the same one its own Send to Plan uses. Tried in the browser: the row's menu says Open in Plan right after, without a reload.
  3. Start's page type uses the opportunity's brand. The site type is read from brands.find((b) => b.id === opportunity.brandId).
  4. Strings. content.send is removed, and content.alternative.hint is back as Another angle's title.
  5. The unused contains mock is dropped.
  6. The content prop's doc is fixed.

Tests cover the retry in both the row menu and the panel, and the hint. Web: 2,543 tests, lint, tsc, Prettier and the build pass.

On merging with #1333: whichever lands second keeps both functions after getContentStartOptions in content-drafts.ts, and the .is('archived_at', null) note from #1328 still applies to getDraftForPrompt.

@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. All six earlier findings are done in 92a4aaac:

  1. A failed getOpportunityDrafts is now kept apart from "no draft". The row menu and the panel show "Couldn't check for a draft · Retry" instead of Send to Editor, and both have a test.
  2. Send to Plan from the panel calls the page's onPrioritized, so the row menu says Open in Plan without a reload.
  3. Start's page types come from opportunity.brandId's brand.
  4. content.send is removed, and content.alternative.hint is Another angle's title, with a test.
  5. The contains mock is dropped.
  6. The content prop's doc is fixed.

The merge 92ad9e92 brings in #1321's head (a4101397). Re-merging its parents gives the same tree, so it has no hidden changes.

Follow-up (low; it applies to whichever of this PR and #1328 lands second):

  1. web/src/lib/actions/content-drafts.ts:328: once #1328 is in, getOpportunityDrafts should also filter .is('archived_at', null). #1328 filters it on the Plan, in MCP and in the Action Center. Without the filter, Opportunities offers Open draft for a draft the Library has archived. There's no unique index on opportunity_id, so skipping archived drafts lets Start write a fresh draft.

Merge notes

  • Merges cleanly on current main.
  • It contains #1321 at its current head (a4101397, with 00229) and #1332's original commit (8c21917f). It doesn't contain #1332's later merge of main, but merges cleanly with it. It merges after #1321 and #1332.
  • 00229 isn't on prod yet. Apply it before #1321 merges.
  • Conflicts:
    • with #1328, in content/library/page.test.tsx and content-plan.test.ts (from #1321; keep both mocks);
    • with #1333, in content-drafts.ts, content-drafts-start.test.ts and new-content-dialog.tsx.
  • No conflicts with #1322 or #1329.

Tested on top of the current main together with #1343, #1344, #1321, #1329, #1332, #1334 and #1342: web and server tests, tsc, lint and Prettier pass, and schema.sql matches a rebuild. 00229, 00234 and 00238 are applied on production.

@gkhngyk
gkhngyk merged commit db993ea into ansvisor:main Oct 22, 2026
1 check passed
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 22, 2026
cihan-gyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 22, 2026
…chived

00218's content_drafts_action_work_key counted archived drafts too, so a
task whose draft was archived could never start again: readActionDrafts
skips the archived one, the insert hit the key, and the 23505 retry found
no winner. 00233 recreates the key over drafts not archived. Restoring the
archived one while a newer draft does the same work is refused (23505),
named newer_draft, and the Library says what to do. getOpportunityDrafts
(from ansvisor#1334, now on main) skips archived drafts too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk pushed a commit that referenced this pull request Oct 22, 2026
* fix(content): draw the Plan's mix bars to one scale, and open the page in its final layout

- "What AI cites in your topics" drew both shares on one track scaled to
  AI's largest share, so a type the brand leans on more than AI does
  (e.g. 35% · 73%) ran its bar past the track onto the shares column. The
  two shares are now two thin bars on one scale, the larger of the two,
  never past the track.
- The list and the sections above it (AI results, the mix) were read and
  drawn apart, so the list showed mid-screen first and jumped down when
  the sections came in. The page now shows one spinner until both reads
  are in; a list that fails says so at once.

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

* fix(content): show the brand's cited pages as an Overview, not an overlap warning

More of the brand's pages cited for the same prompts is no loss (AI
answers aren't a ranking), so neither Start nor the Plan treats it as a
problem any more:

- Start's "Overlap check" is an "Overview": a plain box listing the
  brand's pages AI already cites for these prompts, with no amber warning,
  no "Safe to create" and no "Recommended". The action the person clicked
  stays chosen (Create stays Create); the choices are the plan's page when
  it named one, a new page, and optimizing the page cited most.
- The Plan drops the Overlaps card, the ⚠ Overlap tag on rows, and the
  rows that were listed only because another page of the brand is cited
  for the same prompts.

content_plan_pages (00220/00221) still returns overlaps; the Plan no
longer reads it.

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

* feat(content): assign, mark as a priority or hide a Content plan row

Each Priority list row gets a "…" menu:
- Assign to… (every member): a row with a draft assigns its Action
  Center task (sending the draft first when needed); a row without one
  opens Start on Team, which now has an "Assign to" picker. The Who
  column shows the assignee.
- Mark as priority (admins and managers): the row goes to the top with a
  Priority tag; a Priority card counts and filters the marked rows.
- Hide from the plan (admins and managers): the row leaves the list, with
  Undo and "N hidden rows · Show"; an opportunity's row also dismisses the
  opportunity and gets its status back when shown again.

Migration 00229 adds content_plan_marks (members read; admins and
managers write).

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

* feat(content): suggest opportunity content types by the brand's site type

Content Opportunities gave every brand the same ten asset types, so a
shop could get a glossary or landing page and a SaaS brand a product or
category page. The generator now reads brands.site_type (or the
editor's guess from Shopping mode and industry), lists that site's page
types with their formats in the prompt, and limits assetType and the
supporting types to them, plus the earned third_party_article and
backlink. No calculation changes.

Older opportunities keep their stored types and are read as the brand's
page types (pillar_guide -> guide / buying_guide, landing_page ->
solution_page / collection_page / destination_page, and so on). The
opportunities list, the drawer, the assets card and Copy All Data name
them with the editor's labels. Start preselects an opportunity's type
for a new page; an existing page goes by its own address or title
first. The Content Plan follows the same rules.

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

* feat(content): open the Content Editor from Content Opportunities

From the user's spec, PR B of the Content Editor entry points, with the
user's follow-up choices:

- Opportunity panel: three buttons in front, in this order: Send to
  Actions, Generate Brief and Send to Editor. Each turns into its done
  state in place (Open in Actions, Brief Generated, Open draft). The
  rest move into a "..." menu on the right: Send to Plan, Another angle,
  Send to Workflow, Copy All Data, Mark as reviewed, Restore, Dismiss.
- Opportunities list: a row's actions sit in one "..." menu: Send to
  Editor or Open draft, Send to Plan or Open in Plan, Send to Workflow,
  Open in new tab, Dismiss. The Actions column narrows to fit.
- Send to Editor opens New content > Start. A create decision starts a
  new page; any other decision starts on its first target page
  (lib/content/opportunity-start.ts). Owned work still open only.
  getOpportunityDrafts finds the draft already being written.
- Send to Plan marks the opportunity's Plan row as a priority
  (content_plan_marks, #1321) for admins and managers;
  getPlanPriorities reads which rows already are.

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

* feat(content): export an opportunity as CSV, Excel or Word

The user asked for an Export button on the opportunity's full page and in
the right-hand panel, listing Export CSV, Export Excel and Export Word one
under the other. It sits on the actions row, left of the "..." menu.

All three formats come from what Copy All Data copies.
opportunityToMarkdown now renders a structured write-up
(opportunityDocument: sections of fields, items, numbered steps and
text), and its Markdown output is unchanged. lib/content/opportunity-export.ts
writes that same write-up as:
- CSV: section, field and value rows, with a byte order mark;
- Excel: one sheet with a bold header (write-excel-file);
- Word: a .docx with the title, section headings, bold field labels
  and lists.

Word uses the docx package, added at the user's OK. It is pinned to 9.9.0,
a release at least two weeks old, and loaded only on the click.

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

* fix(content): read a Plan row's opportunity from its key, and restore only what is still dismissed

hidePlanRow and showPlanRow no longer take an opportunity id from the client:
the server reads it from the row key the mark is written under (a uuid, or
'invalid'). Show again gives an opportunity back its status only while it
is still dismissed; one completed or reopened elsewhere keeps its status and
only the mark goes. Hidden rows read only dismissed opportunities. The
Priority card's dot is in ink, as its outline badge.

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

* fix(content): keep a failed draft read from offering Send to Editor, and tell the list about Send to Plan

- A failed getOpportunityDrafts is no "no draft": the row menu and the
  panel offer "Couldn't check for a draft · Retry" instead of Start, so a
  failed read never starts a second draft for the same opportunity.
- Send to Plan from the panel calls the page's onPrioritized, so the row's
  menu says Open in Plan without a reload.
- Start's page types come from the opportunity's brand, not the active one.
- content.send is gone; content.alternative.hint is Another angle's title.
- Drop the unused contains mock and fix the content prop's doc.

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

* test(content): count Export in front of the panel's draft retry

#1334's retry test lists the panel's front buttons; with this PR's Export
button there is one more.

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

* fix(content): pin docx to 9.7.0, which installs on Node 20

[email protected] depends on nanoid@^6, whose engines need Node 22+, so CI's
Node 20 web job (and Vercel's install on Node 20) stopped at yarn install.
9.7.0 is the last release on nanoid@^5 (Node ^18 || >=20) and @types/node
^25, and has every API the export uses. The lockfile drops docx 9.9.0's
nanoid 6, @types/node 26 and undici-types 8.9; @types/node@^25.2.3 joins
the existing 25.7.0 entry.

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

* fix(content): wrap multi-line export cells, and use the sheet's header case in the CSV

An outline step's points sit on their own lines in one value; the sheet's
cell now wraps, so Excel shows them. The CSV's header reads Section,Field,Value
like the sheet's.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 22, 2026
…or Markdown (#1348)

* fix(content): draw the Plan's mix bars to one scale, and open the page in its final layout

- "What AI cites in your topics" drew both shares on one track scaled to
  AI's largest share, so a type the brand leans on more than AI does
  (e.g. 35% · 73%) ran its bar past the track onto the shares column. The
  two shares are now two thin bars on one scale, the larger of the two,
  never past the track.
- The list and the sections above it (AI results, the mix) were read and
  drawn apart, so the list showed mid-screen first and jumped down when
  the sections came in. The page now shows one spinner until both reads
  are in; a list that fails says so at once.

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

* fix(content): show the brand's cited pages as an Overview, not an overlap warning

More of the brand's pages cited for the same prompts is no loss (AI
answers aren't a ranking), so neither Start nor the Plan treats it as a
problem any more:

- Start's "Overlap check" is an "Overview": a plain box listing the
  brand's pages AI already cites for these prompts, with no amber warning,
  no "Safe to create" and no "Recommended". The action the person clicked
  stays chosen (Create stays Create); the choices are the plan's page when
  it named one, a new page, and optimizing the page cited most.
- The Plan drops the Overlaps card, the ⚠ Overlap tag on rows, and the
  rows that were listed only because another page of the brand is cited
  for the same prompts.

content_plan_pages (00220/00221) still returns overlaps; the Plan no
longer reads it.

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

* feat(content): assign, mark as a priority or hide a Content plan row

Each Priority list row gets a "…" menu:
- Assign to… (every member): a row with a draft assigns its Action
  Center task (sending the draft first when needed); a row without one
  opens Start on Team, which now has an "Assign to" picker. The Who
  column shows the assignee.
- Mark as priority (admins and managers): the row goes to the top with a
  Priority tag; a Priority card counts and filters the marked rows.
- Hide from the plan (admins and managers): the row leaves the list, with
  Undo and "N hidden rows · Show"; an opportunity's row also dismisses the
  opportunity and gets its status back when shown again.

Migration 00229 adds content_plan_marks (members read; admins and
managers write).

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

* feat(content): suggest opportunity content types by the brand's site type

Content Opportunities gave every brand the same ten asset types, so a
shop could get a glossary or landing page and a SaaS brand a product or
category page. The generator now reads brands.site_type (or the
editor's guess from Shopping mode and industry), lists that site's page
types with their formats in the prompt, and limits assetType and the
supporting types to them, plus the earned third_party_article and
backlink. No calculation changes.

Older opportunities keep their stored types and are read as the brand's
page types (pillar_guide -> guide / buying_guide, landing_page ->
solution_page / collection_page / destination_page, and so on). The
opportunities list, the drawer, the assets card and Copy All Data name
them with the editor's labels. Start preselects an opportunity's type
for a new page; an existing page goes by its own address or title
first. The Content Plan follows the same rules.

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

* feat(content): open the Content Editor from Content Opportunities

From the user's spec, PR B of the Content Editor entry points, with the
user's follow-up choices:

- Opportunity panel: three buttons in front, in this order: Send to
  Actions, Generate Brief and Send to Editor. Each turns into its done
  state in place (Open in Actions, Brief Generated, Open draft). The
  rest move into a "..." menu on the right: Send to Plan, Another angle,
  Send to Workflow, Copy All Data, Mark as reviewed, Restore, Dismiss.
- Opportunities list: a row's actions sit in one "..." menu: Send to
  Editor or Open draft, Send to Plan or Open in Plan, Send to Workflow,
  Open in new tab, Dismiss. The Actions column narrows to fit.
- Send to Editor opens New content > Start. A create decision starts a
  new page; any other decision starts on its first target page
  (lib/content/opportunity-start.ts). Owned work still open only.
  getOpportunityDrafts finds the draft already being written.
- Send to Plan marks the opportunity's Plan row as a priority
  (content_plan_marks, #1321) for admins and managers;
  getPlanPriorities reads which rows already are.

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

* feat(content): export an opportunity as CSV, Excel or Word

The user asked for an Export button on the opportunity's full page and in
the right-hand panel, listing Export CSV, Export Excel and Export Word one
under the other. It sits on the actions row, left of the "..." menu.

All three formats come from what Copy All Data copies.
opportunityToMarkdown now renders a structured write-up
(opportunityDocument: sections of fields, items, numbered steps and
text), and its Markdown output is unchanged. lib/content/opportunity-export.ts
writes that same write-up as:
- CSV: section, field and value rows, with a byte order mark;
- Excel: one sheet with a bold header (write-excel-file);
- Word: a .docx with the title, section headings, bold field labels
  and lists.

Word uses the docx package, added at the user's OK. It is pinned to 9.9.0,
a release at least two weeks old, and loaded only on the click.

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

* fix(content): read a Plan row's opportunity from its key, and restore only what is still dismissed

hidePlanRow and showPlanRow no longer take an opportunity id from the client:
the server reads it from the row key the mark is written under (a uuid, or
'invalid'). Show again gives an opportunity back its status only while it
is still dismissed; one completed or reopened elsewhere keeps its status and
only the mark goes. Hidden rows read only dismissed opportunities. The
Priority card's dot is in ink, as its outline badge.

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

* fix(content): keep a failed draft read from offering Send to Editor, and tell the list about Send to Plan

- A failed getOpportunityDrafts is no "no draft": the row menu and the
  panel offer "Couldn't check for a draft · Retry" instead of Start, so a
  failed read never starts a second draft for the same opportunity.
- Send to Plan from the panel calls the page's onPrioritized, so the row's
  menu says Open in Plan without a reload.
- Start's page types come from the opportunity's brand, not the active one.
- content.send is gone; content.alternative.hint is Another angle's title.
- Drop the unused contains mock and fix the content prop's doc.

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

* test(content): count Export in front of the panel's draft retry

#1334's retry test lists the panel's front buttons; with this PR's Export
button there is one more.

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

* fix(content): pin docx to 9.7.0, which installs on Node 20

[email protected] depends on nanoid@^6, whose engines need Node 22+, so CI's
Node 20 web job (and Vercel's install on Node 20) stopped at yarn install.
9.7.0 is the last release on nanoid@^5 (Node ^18 || >=20) and @types/node
^25, and has every API the export uses. The lockfile drops docx 9.9.0's
nanoid 6, @types/node 26 and undici-types 8.9; @types/node@^25.2.3 joins
the existing 25.7.0 entry.

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

* fix(content): wrap multi-line export cells, and use the sheet's header case in the CSV

An outline step's points sit on their own lines in one value; the sheet's
cell now wraps, so Excel shows them. The CSV's header reads Section,Field,Value
like the sheet's.

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

* feat(content): put the editor's tags on a second line, and keep the side panel's tabs in sight, Rules first

The header's top row keeps the title and the page's actions; the page type,
method, status, rules and cited-passages tags move to a line of their own
under the title, all of them at any width and lined up (the status badge sat
lower in its wrapper). While the side panel is closed, its tabs stay down the
editor's right edge and open it on the one picked, so the panel is never out
of sight on a window under 1280px, where it starts closed. Rules is the first
tab and the panel opens on it; Impact reads when first opened.

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

* feat(content): export the page from the Content Editor as Word, HTML or Markdown

Export sits beside Copy HTML in the editor's header and downloads the page as
Copy HTML gives it. HTML is that page as a titled document. Word and Markdown
read it as blocks first (headings, paragraphs, quotes, nested and numbered
lists, tables, links, bold and italic): Markdown keeps an HTML block as HTML,
Word keeps its text. The schema JSON-LD is markup, so only the HTML file
carries it. A page without an H1 opens with its title. On a phone the button
is an icon, so the header's one row still fits.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk pushed a commit that referenced this pull request Oct 22, 2026
…ws (#1328)

* feat(content): archive, delete and set a status from the Library's rows

Each Library row gets a menu: its status (In progress · In review ·
Ready · Published; Ready goes through Mark ready, keeping a History
version and completing the draft's task) and, for admins and managers,
Send to Archive (with Undo) or Restore, and Delete behind a
confirmation. An Archived tab holds archived drafts, which keep their
status and leave the other tabs, the Plan and the MCP list. Created and
Updated replace the AEO score column, and "Draft" reads "In progress".

Migration 00233 adds content_drafts.archived_at/archived_by, a trigger
letting only admins and managers archive, and a manager delete policy
(drafts had none).

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

* fix(content): guard archived drafts on insert too, and keep them out of the Action Center

- 00233: guard_content_draft_archive runs before insert or update. A
  member's new draft with archived_at or archived_by set is refused
  (42501), so archived_by is never the app's word; the server, which
  bypasses RLS, is unaffected.
- readActionDrafts skips archived drafts: the Action Center drawer doesn't
  list them, and a task's Start writes a new draft instead of reopening one.
- Remove aeoScoreText and the list's scoreBefore/scoreAfter, unused since
  the AEO Score column went.

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

* fix(content): let Start write a new draft once its work's draft is archived

00218's content_drafts_action_work_key counted archived drafts too, so a
task whose draft was archived could never start again: readActionDrafts
skips the archived one, the insert hit the key, and the 23505 retry found
no winner. 00233 recreates the key over drafts not archived. Restoring the
archived one while a newer draft does the same work is refused (23505),
named newer_draft, and the Library says what to do. getOpportunityDrafts
(from #1334, now on main) skips archived drafts too.

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

* fix(content): don't open an archived draft from a tracked prompt

getDraftForPrompt (#1333) skips archived drafts, as getOpportunityDrafts
does, so Start opens the work in hand, never one sent to the Archive.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 22, 2026
…reation date (#1354)

* fix(content): draw the Plan's mix bars to one scale, and open the page in its final layout

- "What AI cites in your topics" drew both shares on one track scaled to
  AI's largest share, so a type the brand leans on more than AI does
  (e.g. 35% · 73%) ran its bar past the track onto the shares column. The
  two shares are now two thin bars on one scale, the larger of the two,
  never past the track.
- The list and the sections above it (AI results, the mix) were read and
  drawn apart, so the list showed mid-screen first and jumped down when
  the sections came in. The page now shows one spinner until both reads
  are in; a list that fails says so at once.

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

* fix(content): show the brand's cited pages as an Overview, not an overlap warning

More of the brand's pages cited for the same prompts is no loss (AI
answers aren't a ranking), so neither Start nor the Plan treats it as a
problem any more:

- Start's "Overlap check" is an "Overview": a plain box listing the
  brand's pages AI already cites for these prompts, with no amber warning,
  no "Safe to create" and no "Recommended". The action the person clicked
  stays chosen (Create stays Create); the choices are the plan's page when
  it named one, a new page, and optimizing the page cited most.
- The Plan drops the Overlaps card, the ⚠ Overlap tag on rows, and the
  rows that were listed only because another page of the brand is cited
  for the same prompts.

content_plan_pages (00220/00221) still returns overlaps; the Plan no
longer reads it.

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

* feat(content): assign, mark as a priority or hide a Content plan row

Each Priority list row gets a "…" menu:
- Assign to… (every member): a row with a draft assigns its Action
  Center task (sending the draft first when needed); a row without one
  opens Start on Team, which now has an "Assign to" picker. The Who
  column shows the assignee.
- Mark as priority (admins and managers): the row goes to the top with a
  Priority tag; a Priority card counts and filters the marked rows.
- Hide from the plan (admins and managers): the row leaves the list, with
  Undo and "N hidden rows · Show"; an opportunity's row also dismisses the
  opportunity and gets its status back when shown again.

Migration 00229 adds content_plan_marks (members read; admins and
managers write).

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

* feat(content): archive, delete and set a status from the Library's rows

Each Library row gets a menu: its status (In progress · In review ·
Ready · Published; Ready goes through Mark ready, keeping a History
version and completing the draft's task) and, for admins and managers,
Send to Archive (with Undo) or Restore, and Delete behind a
confirmation. An Archived tab holds archived drafts, which keep their
status and leave the other tabs, the Plan and the MCP list. Created and
Updated replace the AEO score column, and "Draft" reads "In progress".

Migration 00233 adds content_drafts.archived_at/archived_by, a trigger
letting only admins and managers archive, and a manager delete policy
(drafts had none).

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

* feat(content): suggest opportunity content types by the brand's site type

Content Opportunities gave every brand the same ten asset types, so a
shop could get a glossary or landing page and a SaaS brand a product or
category page. The generator now reads brands.site_type (or the
editor's guess from Shopping mode and industry), lists that site's page
types with their formats in the prompt, and limits assetType and the
supporting types to them, plus the earned third_party_article and
backlink. No calculation changes.

Older opportunities keep their stored types and are read as the brand's
page types (pillar_guide -> guide / buying_guide, landing_page ->
solution_page / collection_page / destination_page, and so on). The
opportunities list, the drawer, the assets card and Copy All Data name
them with the editor's labels. Start preselects an opportunity's type
for a new page; an existing page goes by its own address or title
first. The Content Plan follows the same rules.

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

* feat(content): open the Content Editor from Content Opportunities

From the user's spec, PR B of the Content Editor entry points, with the
user's follow-up choices:

- Opportunity panel: three buttons in front, in this order: Send to
  Actions, Generate Brief and Send to Editor. Each turns into its done
  state in place (Open in Actions, Brief Generated, Open draft). The
  rest move into a "..." menu on the right: Send to Plan, Another angle,
  Send to Workflow, Copy All Data, Mark as reviewed, Restore, Dismiss.
- Opportunities list: a row's actions sit in one "..." menu: Send to
  Editor or Open draft, Send to Plan or Open in Plan, Send to Workflow,
  Open in new tab, Dismiss. The Actions column narrows to fit.
- Send to Editor opens New content > Start. A create decision starts a
  new page; any other decision starts on its first target page
  (lib/content/opportunity-start.ts). Owned work still open only.
  getOpportunityDrafts finds the draft already being written.
- Send to Plan marks the opportunity's Plan row as a priority
  (content_plan_marks, #1321) for admins and managers;
  getPlanPriorities reads which rows already are.

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

* feat(content): export an opportunity as CSV, Excel or Word

The user asked for an Export button on the opportunity's full page and in
the right-hand panel, listing Export CSV, Export Excel and Export Word one
under the other. It sits on the actions row, left of the "..." menu.

All three formats come from what Copy All Data copies.
opportunityToMarkdown now renders a structured write-up
(opportunityDocument: sections of fields, items, numbered steps and
text), and its Markdown output is unchanged. lib/content/opportunity-export.ts
writes that same write-up as:
- CSV: section, field and value rows, with a byte order mark;
- Excel: one sheet with a bold header (write-excel-file);
- Word: a .docx with the title, section headings, bold field labels
  and lists.

Word uses the docx package, added at the user's OK. It is pinned to 9.9.0,
a release at least two weeks old, and loaded only on the click.

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

* fix(content): read a Plan row's opportunity from its key, and restore only what is still dismissed

hidePlanRow and showPlanRow no longer take an opportunity id from the client:
the server reads it from the row key the mark is written under (a uuid, or
'invalid'). Show again gives an opportunity back its status only while it
is still dismissed; one completed or reopened elsewhere keeps its status and
only the mark goes. Hidden rows read only dismissed opportunities. The
Priority card's dot is in ink, as its outline badge.

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

* fix(content): keep a failed draft read from offering Send to Editor, and tell the list about Send to Plan

- A failed getOpportunityDrafts is no "no draft": the row menu and the
  panel offer "Couldn't check for a draft · Retry" instead of Start, so a
  failed read never starts a second draft for the same opportunity.
- Send to Plan from the panel calls the page's onPrioritized, so the row's
  menu says Open in Plan without a reload.
- Start's page types come from the opportunity's brand, not the active one.
- content.send is gone; content.alternative.hint is Another angle's title.
- Drop the unused contains mock and fix the content prop's doc.

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

* test(content): count Export in front of the panel's draft retry

#1334's retry test lists the panel's front buttons; with this PR's Export
button there is one more.

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

* fix(content): guard archived drafts on insert too, and keep them out of the Action Center

- 00233: guard_content_draft_archive runs before insert or update. A
  member's new draft with archived_at or archived_by set is refused
  (42501), so archived_by is never the app's word; the server, which
  bypasses RLS, is unaffected.
- readActionDrafts skips archived drafts: the Action Center drawer doesn't
  list them, and a task's Start writes a new draft instead of reopening one.
- Remove aeoScoreText and the list's scoreBefore/scoreAfter, unused since
  the AEO Score column went.

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

* fix(content): pin docx to 9.7.0, which installs on Node 20

[email protected] depends on nanoid@^6, whose engines need Node 22+, so CI's
Node 20 web job (and Vercel's install on Node 20) stopped at yarn install.
9.7.0 is the last release on nanoid@^5 (Node ^18 || >=20) and @types/node
^25, and has every API the export uses. The lockfile drops docx 9.9.0's
nanoid 6, @types/node 26 and undici-types 8.9; @types/node@^25.2.3 joins
the existing 25.7.0 entry.

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

* fix(content): wrap multi-line export cells, and use the sheet's header case in the CSV

An outline step's points sit on their own lines in one value; the sheet's
cell now wraps, so Excel shows them. The CSV's header reads Section,Field,Value
like the sheet's.

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

* fix(content): let Start write a new draft once its work's draft is archived

00218's content_drafts_action_work_key counted archived drafts too, so a
task whose draft was archived could never start again: readActionDrafts
skips the archived one, the insert hit the key, and the 23505 retry found
no winner. 00233 recreates the key over drafts not archived. Restoring the
archived one while a newer draft does the same work is refused (23505),
named newer_draft, and the Library says what to do. getOpportunityDrafts
(from #1334, now on main) skips archived drafts too.

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

* feat(content): put the editor's tags on a second line, and keep the side panel's tabs in sight, Rules first

The header's top row keeps the title and the page's actions; the page type,
method, status, rules and cited-passages tags move to a line of their own
under the title, all of them at any width and lined up (the status badge sat
lower in its wrapper). While the side panel is closed, its tabs stay down the
editor's right edge and open it on the one picked, so the panel is never out
of sight on a window under 1280px, where it starts closed. Rules is the first
tab and the panel opens on it; Impact reads when first opened.

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

* feat(content): export the page from the Content Editor as Word, HTML or Markdown

Export sits beside Copy HTML in the editor's header and downloads the page as
Copy HTML gives it. HTML is that page as a titled document. Word and Markdown
read it as blocks first (headings, paragraphs, quotes, nested and numbered
lists, tables, links, bold and italic): Markdown keeps an HTML block as HTML,
Word keeps its text. The schema JSON-LD is markup, so only the HTML file
carries it. A page without an H1 opens with its title. On a phone the button
is an icon, so the header's one row still fits.

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

* feat(content): export the Library as CSV, Excel or Word, by tab and creation date

The Library's header gets Export: the drafts listed (the tab, within a new
Created range: any time or the last 7, 30 or 90 days, kept in the URL) with
their pages. CSV and Excel hold a row per draft: title, status, method, page
type, who wrote it, dates, the live page's address, its length and its text
(Excel cuts a page past a cell's 32,767 characters). Word puts every draft in
one document, each from a page of its own under a line saying where it
stands. A row's menu exports one draft as Word, HTML or Markdown, as the
editor's Export does.

The pages are read for the export only (getContentDraftPages, 100 ids a
read). draftDocx's rendering is shared with the Library's document, whose
numbered lists each count on their own.

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

* fix(content): don't open an archived draft from a tracked prompt

getDraftForPrompt (#1333) skips archived drafts, as getOpportunityDrafts
does, so Start opens the work in hand, never one sent to the Archive.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
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