Skip to content

fix(editor): keep the canvas editable and stop discarding input during validation - #62

Open
ruibaby wants to merge 2 commits into
mainfrom
fix/editor-validation-flow
Open

ruibaby wants to merge 2 commits into
mainfrom
fix/editor-validation-flow

Conversation

@ruibaby

@ruibaby ruibaby commented Nov 29, 2026

Copy link
Copy Markdown
Member

Problem

Editing a page in the visual editor could lock up and lose input:

  • While a server-side validation round trip was in flight, the canvas was treated as non-editable, so the whole editor froze after each edit.
  • When validation failed, the source that triggered the failure was rolled back, discarding what the user had just typed.
  • The run view kept rendering the last saved draft without saying so, and re-validation fired a toast on every keystroke, so the behaviour looked like a broken preview.

Changes

  • Decouple canvas editing from validation (ui/src/composables/useWorkingDocument.ts, ui/src/views/EditorView.vue, ui/src/components/VisualEditor.vue, ui/src/editor/canvas.ts): input and canvas operations are never blocked by validation; only save/publish wait for validating to settle. A failed validation shows an inline banner and keeps the last valid render instead of rolling back the user's content.
  • Keep the source view alive across view switches (EditorView.vue): the source editor is hidden with v-show rather than unmounted, so cursor/scroll state and in-flight edits survive a trip to the canvas.
  • Silence repeat validation toasts (useWorkingDocument.ts): once a document is already invalid, further validation requests are muted. The first failure can still raise the global login-expired dialog, so a 401 is never swallowed.
  • Surface stale drafts in the run view (RuntimePreview.vue, EditorHeader.vue): a banner explains that the run view shows the last saved draft and offers "保存并重新运行"; the header mirrors 未保存 / 已保存 draft state.

Verification

  • pnpm --dir ui type-check — pass.
  • Targeted specs (working-document, canvas, runtime-preview, editor-view, workspace) — 71 passed.
  • Full unit suite — 347 passed, 2 pre-existing failures unrelated to this change (ai-create.spec.ts placeholder title, chat-live.spec.ts first-run streamed questions).
  • pnpm --dir ui build — pass (only the repo's existing chunk-size warning).
  • End-to-end in an isolated Halo 2.26 instance with only this plugin installed: repeated edits, save, run view, "保存并重新运行", and visual/source round trips all behave as expected, with no console errors from the plugin.

Notes

  • The isolated fixture shows an "upgrade AI Foundation" hint in the chat panel; that is the fixture (only this plugin installed) and is unrelated to this change.

Keep the last server verdict while a new validation request is in flight, mirror canvas edits into the live DOM so rapid edits are not dropped, and gate saving on the pending verdict instead of the canvas.

Render the theme preview only after validation settles and while the visual view is active, keep the source editor mounted across view switches, and warn when the run view shows a saved draft behind unsaved edits.
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.

1 participant