#16409: fix(feishu): preserve docx block order via sequential inserts
channel: feishu
size: S
Cluster:
Memory Management Enhancements
## Summary
- fix(feishu): preserve docx block order via sequential inserts
- Split from our `v2026.2.13` patch train as a single-purpose change for easier review.
## Why
- Keep the diff focused and low-risk so it can be merged or reverted independently.
## Scope
- Branch: `fix/feishu-docx-sequential-insert-v2026-2-13-en`
- Files changed: 2
- Key files:
- `extensions/feishu/src/docx.test.ts`
- `extensions/feishu/src/docx.ts`
## Test Plan
- Suggested local command:
- `./node_modules/.bin/vitest run extensions/feishu/src/docx.test.ts`
- Validation status:
- [ ] CI checks pass
- [ ] Maintainer re-ran local tests
## Risk & Rollback
- Risk: low to medium; impact limited to touched module(s).
- Rollback: revert this PR commit(s) cleanly.
## Co-authorship
- Co-authored by @ciberponk and Codex (GPT-5).
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Changed `insertBlocks` to insert blocks one-at-a-time sequentially instead of in a single batch, ensuring markdown conversion order is preserved in the final Feishu document. Previously, batch insertion via `documentBlockChildren.create` with multiple children could reorder blocks unpredictably. Added a test that verifies each block is inserted individually in the correct sequence.
<h3>Confidence Score: 4/5</h3>
- Safe to merge with minimal risk - focused fix for a specific ordering issue
- The change is straightforward and well-tested. It trades performance (N API calls vs 1) for correctness, which is appropriate for this use case. The test coverage validates the sequential behavior. Minor risk exists around partial failure handling - if an insert fails mid-sequence, earlier blocks remain inserted with no rollback, but this matches the existing error-handling pattern.
- No files require special attention
<sub>Last reviewed commit: a43a2f9</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#14402: fix(feishu): chunk large documents for write/append to avoid API 40...
by lml2468 · 2026-02-12
80.4%
#16428: fix(feishu): retry docx block insertion on rate limits
by ciberponk · 2026-02-14
79.8%
#16592: feat(feishu): add write mode import for markdown documents
by ciberponk · 2026-02-14
73.4%
#16438: feat(feishu): add create_from_markdown import action
by ciberponk · 2026-02-14
72.6%
#16647: feat(feishu_doc): allow optional initial content on create
by ciberponk · 2026-02-15
70.7%
#20304: feat(feishu): support Docx table create/write + image/file upload a...
by xuhao1 · 2026-02-18
70.5%
#19027: fix(feishu): keep chunked messages in topic/thread context
by qiangu · 2026-02-17
70.4%
#16637: feat(feishu_doc): support optional public_access on create
by ciberponk · 2026-02-14
69.0%
#20795: fix(markdown): prevent triple newlines after blockquotes
by novalis133 · 2026-02-19
68.8%
#16594: feat(feishu): add set_public_permission doc action
by ciberponk · 2026-02-14
66.6%