Skip to content

Restore markdown replace support in docs write#501

Closed
twilsher wants to merge 2 commits intoopenclaw:mainfrom
twilsher:fix/docs-markdown-write-regression
Closed

Restore markdown replace support in docs write#501
twilsher wants to merge 2 commits intoopenclaw:mainfrom
twilsher:fix/docs-markdown-write-regression

Conversation

@twilsher
Copy link
Copy Markdown
Contributor

@twilsher twilsher commented Apr 14, 2026

Summary

This restores docs write --replace --markdown, which worked in v0.11.0 and regressed in later docs refactors.

Root cause

In v0.11.0, markdown replacement used the Drive API update path, which preserved native Google Docs formatting. Later refactors turned docs write into a plain-text Docs mutation command and removed that markdown-aware replace path. That caused formatting loss for workflows that sync markdown into existing Google Docs.

Backward compatibility

Default plain-text docs write behavior stays on the newer Docs API mutation path. This only restores the markdown-preserving update path for docs write --replace --markdown.

Fix

  • restore --replace on docs write
  • restore --markdown on docs write
  • route docs write --replace --markdown back through the Drive API update path
  • keep the current split docs command layout from main
  • keep the newer plain-text Docs API write behavior for non-markdown usage
  • add a regression test covering the markdown replace path

Validation

  • added regression test in internal/cmd/docs_write_update_test.go
  • go test ./internal/cmd -run TestDocsWrite_MarkdownReplaceUsesDriveUpdate
  • make ci

Prompt Used

Create a GitHub PR for steipete/gogcli.

Branch:
fix/docs-markdown-write-regression

Base:
main

State the regression clearly up front:
`docs write --replace --markdown` worked in v0.11.0, where markdown replacement used the Drive API update path. In later docs refactors, `docs write` became a plain-text Docs mutation command, which removed that markdown-aware replace path and caused formatting loss for existing markdown sync workflows.

What this branch does:
- restores `--replace` on `docs write`
- restores `--markdown` on `docs write`
- routes `docs write --replace --markdown` back through the Drive API update path
- keeps the newer plain-text Docs API write behavior for non-markdown usage
- adds a regression test proving markdown replace uses Drive update instead of plain-text Docs mutation

Validation:
- focused docs tests pass
- regression test added in `internal/cmd/docs_write_update_test.go`

Write:
- a short, technical PR title
- a compact PR body
- be direct and explicit about regression cause and compatibility impact
- avoid marketing tone
- use sections:
  - Summary
  - Root cause
  - Fix
  - Validation

steipete added a commit that referenced this pull request Apr 20, 2026
Co-authored-by: twilsher <273817+twilsher@users.noreply.github.com>
@steipete
Copy link
Copy Markdown
Collaborator

Landed manually on main with additional validation and changelog coverage.

Thanks @twilsher!

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