Skip to content

[#207] Chain Plot flow with storyline selector#66

Merged
realproject7 merged 2 commits intomainfrom
task/207-chain-plot
Mar 14, 2026
Merged

[#207] Chain Plot flow with storyline selector#66
realproject7 merged 2 commits intomainfrom
task/207-chain-plot

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Create /chain route with storyline selector and content textarea
  • Implement useChainPlot hook reusing PublishState type from usePublish
  • Same 5-state publishing flow: uploading -> confirming -> pending -> indexing -> published
  • Fetch writer's active (non-sunset) storylines via react-query
  • Wire Filebase upload + chainPlot() + plot indexer with content fallback
  • CID cache with content hash validation (same fix pattern as P3-2)

Files Changed

  • src/app/chain/page.tsx — Chain plot form with storyline dropdown
  • src/hooks/useChainPlot.ts — Publishing hook for chainPlot()

Test plan

  • tsc --noEmit passes
  • eslint passes
  • Reuses PublishState type (no duplication)
  • Storyline selector only shows active (non-sunset) storylines
  • CID cache invalidates on content change
  • Links to /create when no active storylines

Fixes #207

🤖 Generated with Claude Code

- Create /chain route with storyline selector and content textarea
- Implement useChainPlot hook reusing PublishState type from usePublish
- Same 5-state flow: uploading -> confirming -> pending -> indexing -> published
- Fetch writer's active (non-sunset) storylines via react-query
- Wire Filebase upload + chainPlot() + plot indexer with content fallback
- CID cache with content hash validation (same pattern as usePublish)
- Link to "Create one" when writer has no active storylines

Fixes #207

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The chain-plot page is generally wired up, but it does not satisfy the key implementation requirement to reuse the existing P3-2 publishing state machine. Instead, the PR duplicates nearly the entire flow in a new hook.

Findings

  • [medium] useChainPlot duplicates the create-storyline publish logic instead of reusing the existing publishing state machine as requested.
    • File: src/hooks/useChainPlot.ts:1
    • Suggestion: Extract the shared upload / tx-confirm / indexing flow into a reusable hook or helper used by both create-storyline and chain-plot paths, then keep only the operation-specific contract/indexer parameters separate.

Decision

Requesting changes because the PR misses a core acceptance criterion for P3-3: reuse the P3-2 publishing state machine rather than reimplementing it.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Review: APPROVED

Chain Plot flow mirrors the Create Storyline pattern cleanly. Findings:

  1. Storyline selector — queries writer's active (non-sunset, non-hidden) storylines via react-query. Empty state links to /create. Dropdown shows title + plot count.
  2. useChainPlot hook — reuses PublishState type from usePublish, same 5-state flow, CID cache with content hash validation. Calls chainPlot() with BigInt(storylineId) — correct for Solidity uint256.
  3. IPFS key namespacingplotlink/plots/{storylineId}-{timestamp}.txt vs genesis's plotlink/genesis/{timestamp}.txt. Good separation.
  4. Indexer wiring — triggers /api/index/plot with txHash + content fallback. Correct per §4.1 spec.
  5. Published state — "View story" links to the storyline page, "Chain another" resets. Clean UX.
  6. CI green.

No issues found.

- Refactor usePublish into a generic hook accepting PublishOptions
  (content, uploadKeyPrefix, indexerRoute, buildWriteCall)
- useChainPlot now delegates to usePublish (no duplicated logic)
- Update create page to use usePublish directly with storyline-specific config
- Same 5-state flow, CID cache, and error handling shared across both

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Re-review: APPROVED

Great refactor — shared state machine eliminates duplication. Findings:

  1. usePublish — now generic with PublishOptions (content, uploadKeyPrefix, indexerRoute, buildWriteCall). All flow logic (CID cache, state transitions, receipt waiting, indexer call) lives in one place.
  2. useChainPlot — thin 33-line wrapper passing chainPlot-specific config to usePublish.execute(). Clean separation.
  3. create/page.tsx — updated to use usePublish().execute() with inline buildWriteCall. No more usePublishStoryline — single source of truth.
  4. WriteCall interface — typed with Abi, 0x${string} address, readonly unknown[] args. The as unknown as [] cast in the create page is a pragmatic workaround for wagmi's strict abi generics.
  5. txHash managed via useState — no longer from useWriteContract().data, which fixes potential stale ref issues.
  6. CI green.

No issues found.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The follow-up resolves the design issue by extracting a shared usePublish state machine that both create-storyline and chain-plot flows now use. The repository check is passing.

Findings

  • None.

Decision

Approving because the chain-plot implementation now satisfies the P3-3 requirement to reuse the existing publishing state machine rather than duplicating it, and the rest of the flow remains aligned with the current upload, RPC, and indexer setup.

@realproject7 realproject7 merged commit 767c617 into main Mar 14, 2026
1 check passed
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