THU-MAIC / THU-MAIC/OpenMAIC

wb_edit_code replace_lines corrupts the code block when lineIds are out of document order

オープン 初心者向け
#653 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:editor bug priority:P1 status:in-progress
主要言語
TypeScript
スター
37.7k
フォーク
5.9k
平均マージ
1日 6時間
マージ済み PR(30日)
205

説明

`ActionEngine.executeWbEditCode`'s `replace_lines` operation (`lib/action/engine.ts`) computes the splice anchor as `lines.findIndex(l => l.id === replaceIds[0])` **before** filtering out the replaced lines. `WbEditCodeAction.lineIds` (`lib/types/action.ts`) is a plain `string[]` with no ordering contract, and the agent producing it may emit IDs out of document order.

When `replaceIds[0]` is not the topmost replaced line (e.g. `["L5", "L2"]`), the subsequent `.filter()` removes a line **above** the anchor, so the saved index goes stale and the replacement lines are spliced at the wrong position — corrupting the displayed code block.

### Reproduction (logic)
Lines `[A, B, C, D, E]`, `replace_lines` with `lineIds: ["D", "B"]`, content `"X"` → produces `[A, C, E, X]` (X appended at the end) instead of `[A, X, C, E]` (X where B was).

### Suggested fix
Anchor the insertion at the topmost (minimum original index) replaced line. PR to follow.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

lib/action/engine.ts の ActionEngine.executeWbEditCode から始めて、replace_lines 操作を調べ、その後 lib/types/action.ts の WbEditCodeAction.lineIds を確認します。Issue の ["D", "B"] ケースを再現し、順序付けられた ID に対する期待される動作を変更せずに、置換が置換対象の最上位の行を基準に行われることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
tooling
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
76/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。