Skip to content

feat(fields, service-messaging): a notification template's record page previews the saved template through the server door - #39707

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-39569-wip
Dec 4, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-39569-wip

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Fixes #39569
Clause-②: no
Metadata-protocol: none

维护者速读

  • 管理员在“设置 → 通知模板”打开一条模板时,正文下方多出一块预览:按服务器真正发送时的样子显示已保存的标题和正文,可填示例值再预览一次;此前只能看到原始模板文字。
  • 属于“通知模板可见可试”这条线:让管理员不用真的发一条通知就能确认模板写对了。
  • 出错时只影响这块预览(显示拒绝原因或“无法预览”),不发送、不写入任何数据;撤掉这一处字段提示即可整体撤回。
  • 无。

What changes

  • A Preview pane under the body on a notification template's record page. It posts the saved row's id and a sample payload to the server preview door (POST /api/v1/messaging/notification-templates/ID/preview, the door Notifications: a render-only door that previews a saved notification template against sample values #39565 added) and shows the subject and body exactly as that door answers. The door renders with the same function the email and SMS channels use. There is no browser-side rendering; nothing is sent and nothing is written.
  • Each placeholder in the saved subject and body becomes a sample-value input. The pane finds placeholders with the renderer's own hole grammar. amount and payload.amount are one input. topic is filled by the server from the template's own topic, so it gets no input. Typing asks nothing; Preview with these values asks again with what was typed.
  • Refresh on save, not per keystroke. The pane snapshots the saved row and asks again when the row's updated_at moves (falling back to its content when a row carries no stamp). An inline draft does not trigger a request.
  • Refusals are text. A 403/404/400 answer shows its own message and code (role=alert); a network failure shows its message; a row with no id shows "Save the template to preview it."; a host with no API fetch shows "The preview is not available here."
  • html / mjml answers draw through the package's existing HTML sanitizer cell; markdown / text answers draw as plain text.
  • Placement (ruling 7405856818 = B, no fallback to A): the pane is the READ face of a new widget hint notification-template-preview on sys_notification_template.body. It is promoted over the markdown base type in resolveCellRendererType and registered lazily (recoverableLazy), so it stays off the eager closure. The edit form is unchanged: the spec degrades an unregistered field widget to the type editor, so the body keeps its markdown editor. A grid cell draws the body alone. The edit-face route was not taken because the edit modal closes on save and never holds a saved render; the record page re-reads the row after a save.
  • Text: a fields.notificationTemplatePreview group (12 keys) in all 11 locale packs, with real translations; zh-Hant generated by the pack's own script.
  • Census rows: one row each in the fields object-literal / populated renderer census and the plugin-detail chip badge-fit census (claim amendment 7411957389). The chip census marks the face fit, so CHIP_UNFIT_RENDERER_TYPES is unchanged.
  • One changeset (patch: @object-ui/fields, @object-ui/i18n, @objectstack/service-messaging).

Read first

  1. ui/packages/fields/src/widgets/NotificationTemplatePreviewField.tsx: the saved-row snapshot (setState during render keyed on the saved key) and the effect's dependency list carry the refresh-on-save rule; the envelope parse in askDoor decides what a refusal shows.
  2. ui/packages/fields/src/index.tsx: the markdown promotion in resolveCellRendererType and the NotificationTemplatePreviewCell wrapper (grid cell and row-less host draw the body alone).
  3. packages/services/service-messaging/src/objects/notification-template.object.ts: the one-line widget hint on body.

Two-minute verification

Boot any app that loads service-messaging, open Setup → Notification Templates, open a template whose body names a placeholder (e.g. customer.name), and look under Body: a Preview pane shows the rendered subject and body with an empty value where the placeholder was, plus one input per placeholder. Type a value and press Preview with these values: the body shows the typed value.

Tests

  • New ui/packages/fields/src/widgets/__tests__/NotificationTemplatePreviewField-39569.test.tsx (21 tests; the ablation below ran at 19, before the two words tests were added): placeholder and payload units; the mount request (URL, method, body); one input per placeholder; no request per keystroke; html through the sanitizer; 403 / 404 / 400 refusals; network failure; a saved-row change asks again; an unsaved draft does not; no id; no fetch; resolver promotion; record-page face; grid cell; row-less host; English and zh-CN words from the packs.
  • Red first: the test alone on main's tree failed to resolve the widget module (VERDICT command-exit 1); green after.
  • Ablation (on disk, restored, tree clean after): with the markdown promotion removed from resolveCellRendererType, 2 failed / 17 passed (the resolver pin and the record-page face pin).
Local readings at 8aae95d (after merging origin/main with os-regen-merge.sh)
  • Scoped sweep (widget test, registry and coverage censuses, i18n pack tests, service-messaging objects): 116 files, 1987 passed and 13 skipped, VERDICT command-exit 0.
  • ui scripts suite under the lock (vitest run scripts/ --maxWorkers=2): 5161 passed, 2 skipped, VERDICT command-exit 0.
  • Type-check exit 0: @object-ui/fields, @object-ui/plugin-detail, @object-ui/i18n, @objectstack/service-messaging (ui closure built first).
  • check-i18n-call-site-keys (ui pnpm check:i18n-keys): exit 0. check:i18n: exit 0 (after building the CLI closure; first attempt exit 3 prerequisite).
  • check:generated: all 14 artifacts up to date. Ratchets (type-check-coverage, type-check-debt), nul-bytes, changeset gates: exit 0.
  • dispatch-gates.mjs --commands derived 76 families; --ran reconciliation: 76 run, 0 missing. All exit 0 except check:dual-build-cjs-loads (exit 3, PREREQUISITE NOT MET: needs a full pnpm build), NOT MEASURED locally, left to CI.

Acceptance notes

  • The pane's hole grammar is a copy of the renderer's TOKEN pattern in service-messaging template-renderer.ts. A cross-package drift pin would need new turbo / cross-package-test-inputs declarations, so it is not pinned here. If the renderer's grammar changes, the inputs drift; the render itself stays correct because the server renders.
  • A body shown as a highlighted field in a summary chip would draw through this face too; with no row the face draws the body alone, which is why the chip census marks it fit.
  • The body column in the list grid draws the body alone (no pane).
  • useFieldTranslation FIELD_DEFAULTS carries no rows for these keys, so a host with no i18n provider renders the keys themselves; every console host has the provider.
  • ui/AGENTS.md rule 2 docs (package README, content/docs/frontend) are outside this claim's surface and were not edited.
  • check:dual-build-cjs-loads NOT MEASURED locally (prerequisite), CI owns it.

Verification

Browser check on the real record page (CRM example backend + Console dev server)
  • Created a template through the API: subject with an invoice-number placeholder, body with customer-name, amount and invoice-number placeholders plus the topic placeholder, topic invoice.paid.
  • The served object metadata carries the widget hint on body.
  • At /apps/com.objectstack.setup/sys_notification_template/record/ID the pane drew under Body with three inputs: number, customer.name, amount.
  • First render (empty samples), as the page text read: Subject "Invoice paid", Body "Hi , we received for (invoice.paid)." The topic came from the template; missing values render empty.
  • After typing INV-7 / Ada / $120 and pressing Preview with these values: Subject "Invoice INV-7 paid", Body "Hi Ada, we received $120 for INV-7 (invoice.paid)."
  • Console: one 401 and one 404 load error from pre-login probes, none from the pane.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibyrf8y7cWLVu7DMgBN

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see

Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json a53022ef4c35a8fee5337170670a34b0582da1e7 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 3a11977f40b7d545b21e4e1bee5edf0494d485a7 — the merge of head 2581e965ca2207f6253292081401ef72128690fa into base a53022ef4c35a8fee5337170670a34b0582da1e7, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 3a11977f40b7d545b21e4e1bee5edf0494d485a7 && git checkout 3a11977f40b7d545b21e4e1bee5edf0494d485a7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a53022ef4c35a8fee5337170670a34b0582da1e7 2581e965ca2207f6253292081401ef72128690fa && git checkout -B drift-repro a53022ef4c35a8fee5337170670a34b0582da1e7 && git merge --no-ff 2581e965ca2207f6253292081401ef72128690fa

node scripts/docs-audit/affected-docs.mjs --json a53022ef4c35a8fee5337170670a34b0582da1e7

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-tesla · os-tesla · session_01L9qibxZ1DSpavkJARmHCQF

席位核对

L1-c · PR #39707 · Head-sha: 8aae95de8cd6eefed627b7980ef131a1a3cc85a0 · 2026-12-04T14:04Z

Verdict: ACCEPT, on green. The zone lands it once every check on this head concludes with none failed. When I read it, 17 checks were still pending, so l1-face's check items were not measured. Its unexpected skip, Dogfood Regression Gate (${{ matrix.shard }}/4), is an unexpanded matrix name on a pending plan, and should be re-read at landing.

Face.

  • Relation. Fixes #39569 is right: this is card 2 of 4 under ruling 7405856818 = B, and the card's whole "What to build" is here.
  • Scope. Claim 7410835379 plus amendments 7411091576, 7411957389 and 7411979862 cover every file.
  • Changeset item the face flagged. @object-ui/plugin-detail's one file is __tests__/summaryChip.badgeFitCensus-8464.test.tsx, which is outside files[], so no entry is owed for it.
  • Changeset entries. fields, i18n and service-messaging at patch, with Clause-②: no and Metadata-protocol: none.
    • The widget: hint on sys_notification_template.body uses an existing key on a platform object; nothing a metadata author can write changes.
    • No L2 is owed: no spec path or governed path is in the diff.

Ruling B, executed.

  • What the pane asks. It asks only the preview door from Notifications: a render-only door that previews a saved notification template against sample values #39565 (POST /api/v1/messaging/notification-templates/:id/preview). That door renders with the channels' own function, so nothing is sent and nothing is written.
  • Placeholders. Placeholders in the saved subject and body become sample inputs. {{ x }} and {{ payload.x }} share one input, and topic comes from the row.
  • Refresh. The pane re-renders when the row's updated_at moves, which means on save, not per keystroke. Refusals show as text with their code.
  • HTML safety. An html/mjml answer goes through HtmlCellRenderer, the package's one sanitizer. Text renders as text in a <pre>, and there is no raw dangerouslySetInnerHTML.
  • Read face only. The edit form keeps the markdown editor, and the hint degrades to type.
  • Grid cells and hosts without a row. These draw the markdown body alone and ask nothing. Both renderer censuses pin this: objectLiteral-8596, and badge-fit, which goes from 42 to 43.
  • Loading. The pane loads lazily, off the eager closure.
  • Translation. The pane's words are in all 11 locale packs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-tesla · os-tesla · session_01L9qibxZ1DSpavkJARmHCQF

席位核对

L1-c · PR #39707 · Head-sha: bde907a6701dbffd5e5a3c8b028374589df954d3 · 2026-12-04T14:17Z

Verdict: ACCEPT (delta), on green. This carries the ACCEPT 7413797377 at 8aae95de8c over to the new head. The zone lands it once every check on this head concludes with none failed.

Delta. One line changes, at NotificationTemplatePreviewField.tsx:157: let body … | null loses its dead = null initializer, which is what Lint UI's no-useless-assignment asked for. Every path assigns body before it is read: the try assigns await res.json(), and the catch assigns null. Behaviour is unchanged, and so are the files, the changeset and the declarations.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-tesla · os-tesla · session_01L9qibyrf8y7cWLVu7DMgBN

Landing · ot-ux2 · 2026-12-04T15:31Z · PR #39707 at 2581e965ca2207f6253292081401ef72128690fa

  • Review: L1-c ACCEPT 7413797377 at 8aae95d. The delta ACCEPT 7414131627 at bde907a covers the one-line lint fix. The head 2581e96 adds only a merge of origin/main, with no conflicts and no regenerated artifacts. No L2 is owed (Clause-② no).
  • Governed: check-governed-merges --pr 39707 reports NOT governed. 858 lines, under 3000.
  • K: the first reading said MERGE MAIN FIRST, because of the shared ui eager-closure budget. After the merge, landing-k is OK with K = 4 < 15. The local eager-closure budget check exits 0 with 318.8 KB of headroom.
  • Checks on this head: 60 success, 12 skipped, 0 failed. Mergeable: clean.
  • Marked ready; auto-merge armed.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 4, 2026 15:31
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit 347998b Dec 4, 2026
73 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-39569-wip branch December 4, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification template form: a preview pane that renders the saved template through the real renderer with sample values

2 participants