Applications editor: make the save/rename interlock hold across tabs

Abierto
#1,964 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
frontend

Línea de trabajo

Start with src/features/instance/applications/lib/editorSaveInterlock.ts, which holds the in-memory save/rename interlock added in #1959, and find the save and rename call sites that use it. The task is to make that lock span tabs, probably with the Web Locks API, which needs a design decision on lock names per instance and path. Done means two tabs on one application can't lose saved text when a save and a rename of the same file overlap; this is hard to test automatically, so a manual two-tab check is likely needed.

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

Descripción

What happens

#1959 makes an application file's save and a rename wait for each other (src/features/instance/applications/lib/editorSaveInterlock.ts). A save that lands while a rename is copying the file would otherwise lose the saved text: the rename reads the file, writes the copy and drops the original.

That interlock lives in one tab's memory. Two tabs on the same instance don't see each other, so a save in tab A can still land in the middle of a rename in tab B, and the saved text is lost from the renamed file.

It takes two tabs on one application, with a save and a rename of the same file within a second or so of each other.

Possible fix

Take the interlock across tabs with the Web Locks API: navigator.locks.request on a name per instance and path, held for the save or the rename. All tabs of an origin share it, and a closed tab's locks are released. BroadcastChannel could tell other tabs that a lock is held, but on its own it can't make one tab wait for another.

This only covers tabs in one browser. Another person, or the assistant's tools run elsewhere, can still interleave. The server would have to make renames atomic to close that.

Review-Deferral: 10b5354eb1c693c0 severity=nit category=concurrency

Raised by the cross-model review of #1959 (#1945).

🤖 Generated by Anthropic Claude Code (Claude Opus 5.5); posted via @dawsontoth.

Lenguaje dominante
TypeScript
Estrellas
5
Forks
4
Merge medio
1 d 19 h
PR fusionados (30 d)
144

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 HarperFast/studio

Todos los issues de HarperFast/studio

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.