[BUG] File Changes panel lists a rejected file edit as a changed file

Abierto
#2,504 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript, vscode
Área
frontend, testing

Línea de trabajo

Start with webview-ui/src/components/chat/utils/fileChangesFromMessages.ts and trace how tool asks are filtered; then read the approval and finalization paths in src/core/task/Task.ts. Add coverage in webview-ui/src/__tests__/fileChangesFromMessages.spec.tsx for approved, auto-approved, rejected, and finalized-failed asks. Done means only approved edits appear in the File Changes panel, including after task reload.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem (one or two sentences)

The File Changes panel lists a file edit that the user rejected. The file was never written. The panel treats a rejected tool ask as an approved one.

Context (who is affected and when)

Every user who rejects a proposed file edit sees the rejected file in the File Changes panel for the rest of the task. The entry also survives a task reload, because the persisted message record carries the same ambiguous flag. This misleads users into believing a rejected write touched their files.

Reproduction steps
  1. Environment: Zoo Code 3.98.0 in VS Code, Windows 10. Any API provider. Auto-approval for file edits is OFF.
  2. Start a task. Ask the agent to edit an existing file outside the workspace (any absolute path works).
  3. When the edit approval dialog appears, click Reject. The agent receives the rejection and the file is not modified.
  4. Open the File Changes panel.

Observed after step 4: the rejected file is listed in the panel with its full proposed diff.

Expected result

The panel lists only file edits that were approved (by the user or by auto-approval). A rejected edit is not listed.

Actual result

The rejected edit is listed as a changed file, with diff and stats, indistinguishable from a real approved edit.

Variations tried (optional)
  • Approved edits and auto-approved edits list correctly; only rejected (and likely failed/finalized) edits leak in.
  • The same entry also appears after closing and reopening the task (the persisted ui_messages.json carries the same flags).
  • Not verified: whether an auto-denied edit (deny rule / guard) produces the same false entry.
Root cause (analysis against main at dc6d1435e, 2026-11-16)
  1. The panel derives its list in webview-ui/src/components/chat/utils/fileChangesFromMessages.ts. Its filter is:

    // Only include ask "tool" file edits that the user (or auto-approval) has approved
    if (isAskTool && !msg.isAnswered) continue
    

    This equates isAnswered === true with "approved".

  2. isAnswered is also stamped on asks that will NOT complete. Task.finalizePartialToolAsk() in src/core/task/Task.ts sets partial = false and isAnswered = true on a tool ask in error/rejection paths, explicitly to disarm the Save/Reject buttons. Its own doc comment says: "the ask is being finalized because it will NOT complete".

  3. A real approval marks the ask only on yesButtonClicked (handleWebviewAskResponse in src/core/task/Task.ts), and auto-approval additionally sets autoApprovalDecision on the message (ask() update path). A rejected/finalized ask therefore has isAnswered = true and NO autoApprovalDecision.

  4. Result: the panel cannot distinguish "answered = approved" from "answered = rejected/failed", so the rejected edit passes the filter and is displayed.

Evidence from persisted task state (sanitized): the tool-ask message for the rejected write has answered = true and an empty autoApprovalDecision, while every genuinely approved edit has autoApprovalDecision = "approve". The target file does not exist on disk at the listed path.

Suggested fix direction

Do not overload isAnswered with "approved". Either:

  • add an explicit per-message outcome marker (for example toolApproval: "approved" | "rejected" | "finalized-failed") set at the three write sites, and filter on it in fileChangesFromMessages.ts; or
  • at minimum, exclude answered asks that have no autoApprovalDecision and were not answered by yesButtonClicked.

A unit test in webview-ui/src/__tests__/fileChangesFromMessages.spec.tsx should cover: approved, auto-approved, rejected, and finalized-failed tool asks.

App Version

3.98.0

API Provider (optional)

Not Applicable / Other (UI/state bug, provider-independent)

Model Used (optional)

N/A

Zoo Code Task Links (optional)

No response

Relevant logs or errors (optional)
No logs; the defect is visible in the persisted ui_messages.json flags described above.
Lenguaje dominante
TypeScript
Estrellas
2k
Forks
301
Merge medio
3 d 14 h
PR fusionados (30 d)
103

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Zoo-Code-Org/Zoo-Code

Todos los issues de Zoo-Code-Org/Zoo-Code

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.