write_file overwrites changes made after the agent read the file

Cerrado
#167 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
desktop, devtools

Línea de trabajo

Start by reading src/main/tools/files.ts:204-213 and types.ts:392 to understand how requireRead records reads, then inspect session.ts:409 for saved-session migration. Trace how write_file checks the read state and compare the current file with the recorded value. Done means stale reads are rejected with the specified message and existing saved readFiles: string[] sessions are migrated safely.

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

Descripción

bug priority: medium severity: medium

Found in the 2026-10-07 code review and confirmed with a probe (the file ended as agent, not user edit).

Problem

The read-before-write rule (src/main/tools/files.ts:204-213, requireRead) records only that a path was read (readFiles: Set<string>, types.ts:392), not what was read. edit_file and apply_patch are safer, because their context or old_string must still match. write_file replaces the file outright.

Scenario

The agent reads config.ts. The user edits it in their editor while the agent keeps working. The agent then calls write_file with content built from the old read, and in Auto mode the user's edit is silently lost.

Fix

Make readFiles a Map<string, string> (path → sha256 of the bytes read). In write_file, refuse when the current hash differs: "${path} changed since you read it. Read it again first.". This needs a migration for saved readFiles: string[] (session.ts:409).

Lenguaje dominante
TypeScript
Estrellas
2
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

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.

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.