Skip to content

feat(notifications): version templates with safe rollback - #1862

Merged
github-actions[bot] merged 3 commits into
Smartdevs17:mainfrom
zarah-s:feat/1748-template-versioning
Oct 26, 2026
Merged

github-actions[bot] merged 3 commits into
Smartdevs17:mainfrom
zarah-s:feat/1748-template-versioning

Conversation

@zarah-s

@zarah-s zarah-s commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Notification templates kept only the current copy per (type, channel) pair, so a bad edit was irreversible. This adds versioning with safe rollback (#1748).

Design choice: rollback is a forward move

Rewriting the version number back to an old value would let two different bodies claim the same version, so a message sent after a rollback could not be told apart from one sent before the bad edit. Instead, a rollback republishes the chosen snapshot as the next version and records restoredFrom, keeping every version number unique and monotonic. Nothing is ever deleted.

Backend

  • notificationTemplateVersionService — saveDraft (a no-op save creates no version), listVersions, getCurrent, rollback, with an in-memory repository.
  • notificationTemplateRouter (mounted at /api/notification-templates):
    • GET /api/notification-templates
    • GET /api/notification-templates/:type/:channel
    • GET /api/notification-templates/:type/:channel/versions
    • POST /api/notification-templates/:type/:channel
    • POST /api/notification-templates/:type/:channel/rollback?version=…

Frontend

  • notificationTemplateStore — on-device mirror of the same model.
  • TemplateVersionHistoryScreen — version timeline with a rollback action.
  • Navigation registration.

Docs

New "Versioning and rollback" section in docs/NOTIFICATIONS.md.

Testing

  • notificationTemplateVersionService.test.ts + notificationTemplateRouter.test.ts — 27 tests, real HTTP server over the router (version chaining, no-op saves, per-channel isolation, rollback keeps bad version, invalid/no-history errors, query + body rollback).
  • notificationTemplateStore.test.ts — 11 tests (save/no-op/rollback/selectors).
  • TemplateVersionHistoryScreen.test.tsx — timeline, current marker, rollback.
  • ESLint/Prettier clean; tsc introduces no new errors (516 total, same as main).

closes #1748

zarah-s and others added 3 commits October 20, 2026 14:39
Adds versioning and rollback for notification templates (Smartdevs17#1748).

Templates previously kept only the current copy per (type, channel) pair, so a
bad edit was irreversible. Now every save is an immutable version and a rollback
republishes an earlier snapshot as the next version — never rewinding the
number, so version numbers stay monotonic and a message sent after a rollback
is still distinguishable from one sent before the bad edit.

Backend
- notificationTemplateVersionService: saveDraft, history, and rollback with an
  in-memory repository; a no-op save creates no version
- notificationTemplateRouter (/api/notification-templates): list, current,
  history, save and rollback; errors mapped to 400/404

Frontend
- notificationTemplateStore: on-device mirror of the same model
- TemplateVersionHistoryScreen: version timeline with rollback action
- navigation registration

Docs: versioning-and-rollback section in docs/NOTIFICATIONS.md
# Conflicts:
#	backend/server.ts
#	src/navigation/types.ts
@github-actions
github-actions Bot merged commit ed95d9f into Smartdevs17:main Oct 26, 2026
11 of 27 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.

Add notification template versioning

2 participants