Skip to content

[Bug] Plot count +1 — debug via Chrome MCP / Playwright #769

@realproject7

Description

@realproject7

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

  1. Open Supabase dashboard or use the Supabase client
  2. Query: SELECT id, storyline_id, plot_index, title, created_at FROM plots WHERE storyline_id = '<straton-storyline-id>' ORDER BY plot_index
  3. Record the exact rows — how many are there? Are there duplicate plot_index values?
  4. Query: SELECT plot_count FROM storylines WHERE storyline_id = '<straton-storyline-id>'
  5. Compare: does plot_count match the actual row count?

Step 2 — Trace the display

  1. Open the storyline page (/story/<storyline-id>) in Chrome MCP
  2. Inspect what plot_count value the page receives from the API/server component
  3. Check: is the page displaying plot_count directly, or is it counting rendered plot cards?
  4. 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

  1. Apply the fix based on findings
  2. Verify via Chrome MCP that the count is now correct on both storyline page and profile page
  3. If DB fix needed, also verify other storylines aren't affected

Acceptance Criteria

  • Root cause identified and documented in PR description
  • Plot count matches actual number of plots for Straton storyline
  • Verified on both storyline page and profile Writer tab via Chrome MCP or Playwright
  • If duplicate rows found: deduplicated + unique constraint added
  • If display bug: logic fixed with no side effects
  • Bump patch version

Branch

task/769-plot-count-debug

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/T3Assigned to T3 builder agentbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions