Skip to content

Sponsor doc: autosave every edit (UTM suggest, uploads, typing) with visible saving/saved/NOT SAVED status - #502

Merged
alexeygrigorev merged 1 commit into
mainfrom
hub/intake-66d1ea5f014acca06779079b73f592888e6dfed53ca2657dd6e112a7b331e0ee
Nov 23, 2026
Merged

alexeygrigorev merged 1 commit into
mainfrom
hub/intake-66d1ea5f014acca06779079b73f592888e6dfed53ca2657dd6e112a7b331e0ee

Conversation

@alexeygrigorev

@alexeygrigorev alexeygrigorev commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Fixes t2909u/t2910u/t2911u (Hub intake e6ec25cc): clicking the UTM suggestion on a sponsor doc never saved.

Root cause (reproduced on main in Playwright/Chromium): the Add UTM button only changed the in-page draft. Nothing was sent until a manual Save draft click (0 PUTs after the click), and reload showed the old ctaUrl. There was no unsaved indicator.

Fix: autosave

  • Debounced autosave (1.2 s) on every input/change, helper edits (UTM, bullets, radios, selects, image upload/remove via the preview hook) and re-renders; the UTM button saves immediately. Autosave updates only the status line, so focus/caret is never lost.
  • Visible status under the form: All changes saved · Last edited … / Unsaved changes · saving automatically… / Saving… / NOT SAVED: (role=alert) with Retry save.
  • Fails loudly: 20 s request timeout; 5xx/timeout/network are reported to /api/client-errors by the request layer (server ERROR log client_check_failed), 4xx are now reported too.
  • Guest time choice keeps its explicit Save time choice step (autosave never sends an unconfirmed slotChoice).
  • beforeunload warns while dirty/in flight; hiding the tab flushes a pending save. Autosave never changes doc status, and opening a doc never writes.

Tests

  • Unit: UTM click autosaves once without status change; typing autosaves; timeout shows NOT SAVED + Retry; 4xx is reported.
  • Playwright backend/e2e/sponsor-doc-utm-save.spec.js: UTM click → autosaved → reload shows utm_source; typing + image upload autosave and survive reload; forced 500 → NOT SAVED alert + client error report → Retry → saved → reload.
  • Trial-merged with Sponsor docs: Graphics image upload/preview; owning task resolved from Card #500 (graphics upload): sponsor-docs unit + brief-inline-images/sponsor-newsletters/this spec all pass.

@alexeygrigorev alexeygrigorev changed the title Sponsor doc: persist helper-filled UTM, unsaved indicator, loud NOT SAVED failure + report Sponsor doc: autosave every edit (UTM suggest, uploads, typing) with visible saving/saved/NOT SAVED status Nov 23, 2026
…saving/saved/NOT SAVED status

Root cause (t2909u): the Add UTM button only changed the in-page draft;
nothing was sent until a manual Save draft click, so reload lost the value
(reproduced on main in Chromium: 0 PUTs after the click, reload shows the
old ctaUrl). There was no unsaved indicator.

- sponsor-doc-autosave.js: debounced (1.2 s) autosave on every input/change,
  helper edit (preview hook: uploads, bullets, radios, selects) and
  re-render; the UTM button saves immediately. Autosave updates only the
  status line, never re-renders the form, so focus is kept.
- Visible status: All changes saved / Unsaved, saving automatically /
  Saving / NOT SAVED (role=alert) + Retry save. 20 s request timeout;
  5xx/timeout reported by the request layer, 4xx reported here to
  /api/client-errors (server ERROR client_check_failed).
- Guest time choice keeps its explicit Save time choice step.
- beforeunload warns while dirty or in flight; tab hide flushes.
- Upload status no longer says 'Save to keep it'.
- New modules served to the anonymous sponsor page and listed in the
  frontend asset manifest; image file reading moved to sponsor-doc-files.js
  to keep sponsor-docs.js under the 1,000-line limit.
- Unit + Playwright regression: UTM click autosaves and survives reload;
  typing + image upload autosave; forced 500 shows NOT SAVED, is reported,
  and Retry saves.
@alexeygrigorev
alexeygrigorev force-pushed the hub/intake-66d1ea5f014acca06779079b73f592888e6dfed53ca2657dd6e112a7b331e0ee branch from 132aacb to d549207 Compare November 23, 2026 12:50
@alexeygrigorev
alexeygrigorev merged commit 8426b18 into main Nov 23, 2026
4 checks passed
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