Skip to content

feat(prompts): prompt workflow — work status, notes, target URLs with cited tracking - #511

Merged
gkhngyk merged 3 commits into
mainfrom
feature/prompt-workflow
Jul 23, 2026
Merged

gkhngyk merged 3 commits into
mainfrom
feature/prompt-workflow

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

The prompts list only measured; the act side of the AEO loop (which prompts got content work, which are queued, which URLs we're pushing to get cited) lived outside the product. This adds the prompt workflow, v1 + v2:

Data (00031 + 00032, applied to the hosted project)

  • prompts.work_status — todo / in_progress / done, nullable.
  • prompt_notes — author + timestamped notes thread per prompt.
  • prompt_target_urls — multiple URLs per prompt (unique per URL), with denormalized cited_count / first_cited_at / last_cited_at so list surfaces read citation status without scanning results.
  • RLS mirrors the prompts policies: members read, admin/manager write.

All Prompts

  • New Work column: shared WorkStatusBadge — dropdown picker for admin/manager (optimistic update with rollback), read-only badge for members — plus an "X/Y cited" line (green once any target URL is cited) via a cheap prompt_target_urls(cited_count) embed, so "work done but nothing cited yet" rows stand out.
  • Work-status filter (All / To do / In progress / Done / No status) next to the search box, labels rendered through the base-ui SelectValue render-function pattern.

Prompt detail

  • Status picker in the header next to the Active badge.
  • Notes card: free-form thread ("published a comparison post targeting this prompt…") with author + timestamp; Target URLs card: add/remove (normalized + validated), each URL opens in a new tab. Both sit outside the date-range refetch overlay — they're window-independent.

Closed-loop citation tracking (v2)

  • Server: updateTargetUrlStats matches each freshly saved result's citations against the prompt's target URLs (protocol / www / query / fragment / trailing-slash insensitive) and bumps the stats. Hooked into both insert paths — the Cloro result handler and the tracking worker's API-model path — as a best-effort step that can never fail the result insert.
  • Web: adding a URL backfills its stats from the prompt's existing results (paged, capped at 5,000 rows), so pre-existing citations count from day one.
  • UI: "Cited ×N" badge per URL with first/last dates in the tooltip and a "was already cited before targeting" nuance; dashed "Not cited yet" otherwise.

The URL matcher is intentionally duplicated web (TS) / server (JS) with stay-in-sync notes on both sides.

Related issue

—

Type of change

  • feat — New feature

How to test

  1. Status: on All Prompts (admin/manager), click a Work badge → pick "In progress" → survives reload; the filter narrows rows; as a member the badge is read-only and shows the label, not the raw value.
  2. Notes: on a prompt detail page add a note → appears with your name + timestamp, survives reload; delete rolls back on failure.
  3. Target URLs: add a URL that is already cited in this prompt's answers → backfill shows "Cited ×N" immediately with plausible first/last dates; add an uncited URL → "Not cited yet". Duplicate URL add is rejected with a clear message.
  4. Live update: run a tracking check for the prompt; when a new answer cites a target URL, its count increments without re-adding.
  5. Table indicator: prompts with targets show "X/Y cited" under the Work badge — green when ≥1 cited.
  6. Member role sees everything read-only (no add/delete/status controls).

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

gkhngyk added 3 commits July 22, 2026 15:47
The prompts list only measured; the act side of the AEO loop (which
prompts got content work, which are queued, which URLs we're pushing to
get cited) lived outside the product. v1 of the prompt workflow:

- 00031: prompts.work_status (todo / in_progress / done, nullable) plus
  prompt_notes (author, timestamped thread) and prompt_target_urls
  (multiple per prompt, unique per URL, structured so a later iteration
  can auto-check them against the prompt's citations). RLS mirrors the
  prompts policies: members read, admin/manager write. Applied to the
  hosted project.
- All Prompts: a Work column with a shared WorkStatusBadge — dropdown
  picker for admin/manager (optimistic update with rollback), read-only
  badge for members — and a work-status filter (All / To do / In
  progress / Done / No status) next to the search box.
- Prompt detail: the status picker sits in the header next to the
  Active badge; Notes (thread with author + timestamp) and Target URLs
  (add/remove, normalized and validated, opens in a new tab) cards at
  the end of the page, outside the date-range refetch overlay since
  they're window-independent.
The base-ui SelectValue renders the raw option value unless given a
render function — the picker read 'in_progress' once selected. Map
values through WORK_FILTER_LABELS like the insights filter selects do.
v2 of the prompt workflow: the product now answers 'did the page we
published actually start getting cited for this prompt?' on its own.

- 00032: denormalized cited_count / first_cited_at / last_cited_at on
  prompt_target_urls, so list surfaces read stats without scanning
  result citations. Applied to the hosted project.
- Server: updateTargetUrlStats matches each freshly saved result's
  citations against the prompt's target URLs (protocol / www / query /
  fragment / trailing-slash insensitive) and bumps the stats. Hooked
  into both insert paths — the Cloro result handler and the tracking
  worker's API-model path — as a best-effort step that can never fail
  the result insert.
- Web: adding a target URL backfills its stats from the prompt's
  existing results (paged, capped) so pre-existing citations count from
  day one; live tracking keeps them current. The matcher is duplicated
  web/server with a stay-in-sync note.
- UI: each target URL shows 'Cited ×N' (with first/last dates and a
  'was already cited before targeting' nuance in the tooltip) or a
  dashed 'Not cited yet'. The All Prompts Work column gains an 'X/Y
  cited' line under the status badge via a cheap
  prompt_target_urls(cited_count) embed — green once any target URL is
  cited, so 'work done but nothing cited yet' rows stand out.
@gkhngyk
gkhngyk merged commit 6503e63 into main Jul 23, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the feature/prompt-workflow branch July 23, 2026 09:07
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.

1 participant