Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(health): notice a code component's file deleted outside the app - #1638

Merged
gregpriday merged 1 commit into
developfrom
bugfix/issue-1540-a-code-component-s-file-deleted-outside
Nov 28, 2026
Merged

gregpriday merged 1 commit into
developfrom
bugfix/issue-1540-a-code-component-s-file-deleted-outside

Conversation

@gregpriday

Copy link
Copy Markdown
Member

When a placed code component's .svelte file was deleted or moved away outside the app while the project was open, the reload read the missing file as empty code and took it as an ordinary outside change. Nothing reached the author: the status bar said No problems, and the break only showed on the next load ("took too long to open", Vite's "Does the file exist?") or at export, where the build named src/routes/+page.svelte rather than the component.

Resolves #1540

Changes

  • The deletion is held when it happens. ProjectSession.readBack tells a missing source from an empty one through the read's raw documents. A code component whose file was loaded and is now gone (confirmed by lstat) is held as a canonical conflict, deletedCode: { definitionId }, with the code last loaded as SiteOrigin Builder's version. The component keeps that code meanwhile, no History step is recorded, and the hold reaches the editor at once and survives a restart (conflicts.json).
  • Two choices in Project health. The row names the component ("Two Columns code component file. Deleted outside SiteOrigin Builder.") and offers Put the file back (the existing restore, from the held code) and Remove Two Columns and its N placements (new remove choice). The removal is one step of History that Undo takes back, file and all. It is refused while the file is back, while other code imports the component, while another kind of conflict is open, or while a page changed outside the app is still waiting to load. It never deletes a file that reappears during the removal, and nothing is removed when the hold has already settled.
  • The hold follows the file. Put back exactly as it was, the conflict settles itself (as before). Put back with other code, it becomes an ordinary changed-file conflict with Keep, at once or at the next open. Deleted again, live or while the project was closed, it is a deleted file again. Keeping a deleted code component's file deleted is refused. A deleted file's hold whose component has gone (a removal stopped by a crash, say) is let go once a read of the project passes validation. The removal leaves the already-gone source out of its journal, so finishing an interrupted removal never deletes a file put back meanwhile.
  • A project opened without the file says so. A new error diagnostic, CODE_SOURCE_MISSING, names the component and its path in Project health. The session tracks which code sources were missing at the last read and clears them as the app writes them.
  • Export names the component. Controller.exportBlocked and the Export dialog name the component for both cases, and the dialog holds both exports back up front for a component opened without its file.
  • removalWithPlacements (src/engine/definitions.ts) plans the removal: each outermost placement, then the component.

A project opened with the file already gone has no loaded code to put back, so it offers no one-click removal. Project health names the component, the file can be put back by hand, and the component can be removed through the library. The hold detection runs before the refused-edit check from #1606, so a deleted file is never reported as refused edited code.

Known gaps

  • A placement saved into another page in the instant between the removal's whole-project check and its journal can still be left pointing at the removed component. Every whole-project save has this window, including the library's own component removal.
  • A file that exists but can't be read is reported as missing.
  • When a component is renamed and its file deleted in the same batch, the missing-file notice can be sent a moment before the renamed state (Low).

Testing

  • tests/unit/deleted-code-source.test.ts (new, through the controller's fake watches), 15 tests:

    • the deletion is held with the loaded code and no History step, and the export names the component;
    • restore puts back the newest loaded code;
    • removal of one and of several placements, with Undo bringing back the file, definition and placement;
    • the opening check on removal, and refusal once settled;
    • refusal while a page edit is still being loaded;
    • two deleted components, one removed;
    • Keep refused, and Remove refused once the file is back;
    • settle, reclassify and re-delete transitions;
    • removal waits for another deleted file that has been put back but not loaded yet;
    • reopen with the hold, with other code put back while closed, with a changed-file hold whose file went while closed, and with an orphaned hold;
    • a cold open names the component in Project health and the export, and clears once the file is back, an empty file included.

    All fail on develop.

  • Adjacent: source-refused-browser, code, conflict-versions, convert-edited, documents, held-handoff, history-steps, own-saves, read-only-open, removal-review, saved-versions, session-recovery, session, export-modal-actions-browser: green.

  • Impact set: 58 of 576 unit test files (10%): all green.

  • npm run typecheck:changed: green.

  • Not covered: no browser test renders the new Project health row, and the tests/e2e/code.mjs e2e was not extended.

- hold the deletion as a conflict with the code last loaded, naming the component
- offer to put the file back or remove the component and its placements in one undoable step
- name a component opened without its file in Project health and the export
- keep holds true as the file goes, comes back, or its component goes
@gregpriday
gregpriday force-pushed the bugfix/issue-1540-a-code-component-s-file-deleted-outside branch from 2018582 to fa9fabf Compare November 28, 2026 09:27
@gregpriday
gregpriday merged commit 7766172 into develop Nov 28, 2026
1 check failed
@gregpriday
gregpriday deleted the bugfix/issue-1540-a-code-component-s-file-deleted-outside branch November 28, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A code component's file deleted outside the app goes unnoticed until the page breaks

1 participant