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

Aperta
#1,964 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
5
Fork
4
Merge medio
1g 20h
PR unite (30g)
140

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di HarperFast/studio

Tutte le issue di HarperFast/studio

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.