THU-MAIC / THU-MAIC/OpenMAIC

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

Offen Anfängerfreundlich
#653 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:editor bug priority:P1 status:in-progress
Vorherrschende Sprache
TypeScript
Sterne
37.7k
Forks
5.9k
Ø Merge
1 T. 6 Std.
Gemergte PRs (30 T.)
205

Beschreibung

`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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in lib/action/engine.ts bei ActionEngine.executeWbEditCode und untersuche die replace_lines-Operation. Überprüfe anschließend WbEditCodeAction.lineIds in lib/types/action.ts. Reproduziere den ["D", "B"]-Fall aus dem Issue und verifiziere, dass der Austausch an der obersten ersetzten Zeile verankert ist, ohne das erwartete Verhalten für geordnete IDs zu ändern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
76/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.