Skip to content

bug(docs write --replace --markdown --tab): new content inherits the tab's last-paragraph list; format --no-bullets skips that paragraph #1333

Open

Description

@alexnayko

What happens

gog docs write <id> --tab <tab> --replace --markdown keeps the list membership of the tab's original last paragraph. If that paragraph is a list item, every paragraph of the new content joins that list: headings, prose, blank paragraphs, and markdown lists, which lose their own list and preset.

Related but separate: gog docs format <id> --tab <tab> --no-bullets without --match removes bullets from every paragraph except the last one. That leftover bulleted empty paragraph makes the next --replace --markdown reproduce the first bug, so the documented recovery does not work.

This looks like the same class as #756 (find-replace inheriting the anchor paragraph style), on the whole-tab replace path.

Repro (v0.48.0, f939ed3, a fresh scratch doc)

  1. Seed the tab so its last paragraph is a list item. a.md:

    # Seed
    
    Intro paragraph.
    
    - seed bullet one
    - seed bullet two

    gog docs write $D --tab t.0 --replace --markdown --file a.md. The markdown writer ends with an empty normal paragraph, so make the last paragraph a list item with documents.batchUpdate: insertText "seed final bullet" at the last index, then createParagraphBullets over it. Read-back: the last paragraph is BULLET in the same list as the seed bullets. This mirrors a real doc whose body ended in a bulleted line.

  2. Replace with b.md:

    # New heading
    
    Plain paragraph one.
    
    ## Second heading
    
    Plain paragraph two.
    
    1. step one
    2. step two

    gog docs write $D --tab t.0 --replace --markdown --file b.md

  3. gog docs raw $D --json, tab t.0 body:

    1-13   HEADING_1    BULLET (seed list)  "New heading"
    13-34  NORMAL_TEXT  BULLET (seed list)  "Plain paragraph one."
    34-49  HEADING_2    BULLET (seed list)  "Second heading"
    49-70  NORMAL_TEXT  BULLET (seed list)  "Plain paragraph two."
    70-71  NORMAL_TEXT  BULLET (seed list)  ""
    71-80  NORMAL_TEXT  BULLET (seed list)  "step one"
    80-89  NORMAL_TEXT  BULLET (seed list)  "step two"
    89-90  NORMAL_TEXT  BULLET (seed list)  ""
    
  4. gog docs format $D --tab t.0 --no-bullets, then raw again: paragraphs 1 to 89 have no bullet, but 89-90 keeps BULLET (seed list). Running step 2 again brings back all-paragraph bullets.

Control: the same step 2 on a tab whose last paragraph is a normal empty paragraph gives the expected result. Headings and prose have no bullet, and only "step one" and "step two" are bulleted, in their own new list.

Expected

  • --replace --markdown gives each paragraph only the list membership its markdown implies, whatever the tab's previous last paragraph was. For example, run deleteParagraphBullets (and reset indentation) over the whole tab range, including the final paragraph, before or after the insert.
  • format --no-bullets without --match covers the final paragraph too. In a real doc, a raw deleteParagraphBullets whose range runs from 1 to the segment end index was accepted and cleared it.

Impact

A whole-tab markdown rewrite of a real document turned all 47 paragraphs, including all 7 headings, into one bulleted list. The only recovery was a raw documents.batchUpdate (deleteParagraphBullets over the full range, then createParagraphBullets for the intended list).

Environment

gog v0.48.0 (f939ed3), Linux, OAuth user account, Docs API with tabs.

Activity

  1. added
    clawsweeper:intake:bugPreliminary submission classification; full source review pending.
    P2Normal priority bug or improvement with limited blast radius.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    no-staleExempts this issue from stale automation.
    and removed
    clawsweeper:intake:bugPreliminary submission classification; full source review pending.
    on Nov 12, 2026
  2. clawsweeper commented on Nov 12, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work.

    Summary
    Keep open: current main retains both defects, and the earlier paragraph-style fix covers a different replacement path.

    Reproducibility: Current source establishes the preserved terminal newline, missing list reset, and excluded final empty paragraph; the reporter provides live v0.48.0 read-back and a control, but this review ran no tests or live mutations.

    Next step
    Establish failing regressions for inherited terminal bullets and final-empty-paragraph removal, then repair the replacement reset and no-match formatting range.

    Review details

    Best possible solution:

    Reset the surviving paragraph’s bullets and indentation before rendering replacement markdown, and include the final empty paragraph when removing bullets without --match.

    Do we have a high-confidence way to reproduce the issue?

    Current source establishes the preserved terminal newline, missing list reset, and excluded final empty paragraph; the reporter provides live v0.48.0 read-back and a control, but this review ran no tests or live mutations.

    Is this the best way to solve the issue?

    A focused terminal-paragraph reset and paragraph-aware bullet-removal range address both defects without changing append or inline replacement semantics.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Live Google Docs read-back is still needed to verify terminal-paragraph cleanup and list preset independence after the repair.

    Codex review notes: model internal, reasoning medium; reviewed against 6f910fffac0a.

    Label changes

    Label changes:

    • add P2: A reproducible, limited-scope Docs editing defect corrupts paragraph formatting and defeats the normal bullet-removal recovery.
    • add impact:other: Document list membership, heading presentation, and intended numbering are corrupted during a supported markdown rewrite.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P2: A reproducible, limited-scope Docs editing defect corrupts paragraph formatting and defeats the normal bullet-removal recovery.
    • impact:other: Document list membership, heading presentation, and intended numbering are corrupted during a supported markdown rewrite.
    Evidence reviewed

    Acceptance criteria:

    • go test ./internal/cmd -run 'TestDocsWrite_MarkdownReplaceWithTab|TestDocsFormatCmd'
    • go test ./internal/docsformat ./internal/docsmarkdown
    • make ci
    • On a disposable Docs tab, seed a bulleted terminal paragraph, replace with headings/prose/numbered markdown, and inspect docs raw --json for independent list membership and presets.
    • Verify docs format --no-bullets clears a final empty bulleted paragraph and repeated markdown replacement does not restore inherited bullets.

    What I checked:

    • Current default branch: GitHub identifies main as the default branch, and its SHA matches the reviewed checkout. (6f910fffac0a)
    • Replacement preserves inherited paragraph state: replaceMarkdownLocally deletes through endIndex minus one, preserving the terminal newline, then inserts markdown at index 1 without resetting bullets or indentation. (internal/cmd/docs_write_markdown.go:336, 6f910fffac0a)
    • Insertion does not clear inherited lists: The insertion helper submits InsertText followed by renderer formatting; headings and plain paragraphs do not receive a bullet-removal reset. (internal/cmd/docs_mutation.go:339, 6f910fffac0a)
    • Final empty paragraph excluded: Without --match, targetRanges ends at document end minus one; for the reported final empty paragraph [89,90), the generated range [1,89) does not overlap it. (internal/cmd/docs_format.go:234, 6f910fffac0a)
    • Bullet removal preserves the supplied endpoint: The formatting planner passes the selected start and end directly into DeleteParagraphBullets, so no downstream adjustment includes the terminal paragraph. (internal/docsformat/format.go:411, 6f910fffac0a)
    • Existing tests miss inherited list state: The tab replacement test records deletion and insertion requests but does not model an existing bulleted terminal paragraph or verify resulting list membership. (internal/cmd/docs_write_markdown_tab_test.go:19, 6f910fffac0a)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed November 12, 2026, 5:34 PM ET / 22:34 UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.no-staleExempts this issue from stale automation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions