Problem
Plot count still shows +1 despite the reconcile fix in PR #741. The Straton storyline displays "4 plots" but the actual number may be 3. Previous ticket (#763) proposed a DB-only investigation, but the root cause is still unclear.
Approach: Debug with Chrome MCP / Playwright
Do NOT guess the root cause. Use Chrome MCP or Playwright to observe the actual data flow:
Step 1 — Check the database directly
- Open Supabase dashboard or use the Supabase client
- Query:
SELECT id, storyline_id, plot_index, title, created_at FROM plots WHERE storyline_id = '<straton-storyline-id>' ORDER BY plot_index
- Record the exact rows — how many are there? Are there duplicate
plot_index values?
- Query:
SELECT plot_count FROM storylines WHERE storyline_id = '<straton-storyline-id>'
- Compare: does
plot_count match the actual row count?
Step 2 — Trace the display
- Open the storyline page (
/story/<storyline-id>) in Chrome MCP
- Inspect what
plot_count value the page receives from the API/server component
- Check: is the page displaying
plot_count directly, or is it counting rendered plot cards?
- Open the profile page → Writer tab → check where "4 Plots" comes from (Writer Stats vs story card)
Step 3 — Find the discrepancy
Based on Steps 1-2, identify exactly WHERE the +1 happens:
- DB level: duplicate row in
plots table → deduplicate + add unique constraint
- DB level:
plot_count field is stale → re-run reconcile endpoint
- Display level: code adds +1 somewhere (e.g., counting genesis separately) → fix the display logic
- Indexer level: genesis plot inserted twice on creation → fix the indexer
Step 4 — Fix and verify
- Apply the fix based on findings
- Verify via Chrome MCP that the count is now correct on both storyline page and profile page
- If DB fix needed, also verify other storylines aren't affected
Acceptance Criteria
Branch
task/769-plot-count-debug
Problem
Plot count still shows +1 despite the reconcile fix in PR #741. The Straton storyline displays "4 plots" but the actual number may be 3. Previous ticket (#763) proposed a DB-only investigation, but the root cause is still unclear.
Approach: Debug with Chrome MCP / Playwright
Do NOT guess the root cause. Use Chrome MCP or Playwright to observe the actual data flow:
Step 1 — Check the database directly
SELECT id, storyline_id, plot_index, title, created_at FROM plots WHERE storyline_id = '<straton-storyline-id>' ORDER BY plot_indexplot_indexvalues?SELECT plot_count FROM storylines WHERE storyline_id = '<straton-storyline-id>'plot_countmatch the actual row count?Step 2 — Trace the display
/story/<storyline-id>) in Chrome MCPplot_countvalue the page receives from the API/server componentplot_countdirectly, or is it counting rendered plot cards?Step 3 — Find the discrepancy
Based on Steps 1-2, identify exactly WHERE the +1 happens:
plotstable → deduplicate + add unique constraintplot_countfield is stale → re-run reconcile endpointStep 4 — Fix and verify
Acceptance Criteria
Branch
task/769-plot-count-debug