Skip to content

[Phase A3] Editable draft Markdown + per-section regenerate API #19

@terisuke

Description

@terisuke

Tracked under ADR 0002 — Phase A. Detail: implementation plan §A3.

Problem

The Markdown output textarea is readonly (static/index.html:153); the user cannot make a small inline correction without copying the text into a separate editor. Worse, when a section misses the mark, the only recourse is to regenerate the entire draft (slow on gemma4:31b, and risks losing acceptable sections). Issue #11 (style threshold) is more painful than it should be because of this.

The Preview tab also has no Copy button — switching tabs to copy is unnecessary friction.

Scope

  • Make <textarea id=\"markdown-output\"> writable. Live-sync edits into the rendered preview via marked.
  • Add a Copy button to the Preview tab as well.
  • Add a "Regenerate this section" button that activates when the cursor is inside a ## heading subtree.
  • New endpoint POST /api/drafts/{id}/regenerate-section accepts { section_anchor, brief_id, persona_id, format_id } and returns a candidate replacement for that section only.
  • Replacement is presented as a diff/preview; the user accepts or rejects.

Acceptance criteria

  • Editing the Markdown textarea immediately updates the preview.
  • Regenerating section "## 実装" replaces only that subtree of the Markdown; other sections remain byte-identical.
  • Copy works from both tabs.
  • Regenerate-section call respects persona + format strategy (depends on Phase B for full effect; on Phase A this can fall back to the current single-format path).
  • Unit tests for the section anchor parser (Markdown heading splitter).

Out of scope

  • Visual diff UI for the regenerated section (text-only is fine for now).
  • Streaming of the regenerated section (covered indirectly by Phase A2 if endpoint supports SSE).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions