Skip to content

feat(templates): share, install, sync and uninstall templates with per-item locks - #1669

Merged
viethung0o0 merged 1 commit into
mainfrom
feat/templates-share-install-sync
Nov 8, 2026
Merged

viethung0o0 merged 1 commit into
mainfrom
feat/templates-share-install-sync

Conversation

@viethung0o0

@viethung0o0 viethung0o0 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Templates cover every category (sequences, MCP servers, AI files, questionnaires, coupon topics and pipelines join flows, AI agents, triggers and the rest), each with an Include and a View/Edit choice per item
  • Referenced tags, custom fields, bot fields, sequences and Places near me categories are installed automatically. A same-name field of another type is created under a suffixed name, and {{field}} tokens are rewritten to it, never left pointing at the source workspace
  • Reinstalling updates the existing copy in place. With auto-update on, saving a template with real changes syncs every enrolled installation; locally edited copies are backed up first and can be restored
  • Locked items can't be edited or deleted in the target workspace. The guard runs in the services, under one sorted advisory-lock protocol shared by local edits, syncs, restores and uninstall
  • Uninstall, by the installer or by the publisher when the installer granted it, removes only unmodified copies the installation created. Edited copies, items with dependents and shared tags/fields are kept and detached
  • Install, sync and uninstall run as leased, idempotent worker jobs, with a sweep that redispatches stuck rows and closes ones that can never run
  • Share links can expire and be rotated; the template list shows active install counts and a per-workspace analytics page
  • Keywords carry their match conditions (install, sync, backup and lock); a trigger's setCustomField that names its field ships it as an id, so the field installs with the template
  • Flows: duplicate keeps the published state and remaps self-references; the new export endpoint and import no longer trust the file's source workspace
  • Public API (templates token scope) for every operation, mirrored in the CLI and MCP; the UI calls the same service methods
  • Adds the template-integration skill, so new resources and reference fields register with Templates

Behaviour changes

  • Flow import renames colliding fields and strips workspace member ids instead of keeping foreign ids
  • Duplicating a flow keeps its published version and active state; a draft-only flow is copied as an inactive draft
  • Template management is open to workspace admins with the matching category permissions, not just super admins
  • A Places near me step's category is found or created by name (case-insensitive) in the target; it ships empty, since locations are never copied

Migration

  • Eight template migrations (20261102070000 … 20261102070700), dated after main's latest so drizzle-kit's head stays correct. run-migrations.mjs records them for a database that applied any earlier set of template migration names, without re-running SQL
  • 20261102070500 dedupes TemplateInstalledResource and builds its unique index concurrently. Run the read-only preflight queries in that migration's header against production before deploying
  • 20261102070700 builds the AIFile queued-run index concurrently. A failed build leaves an invalid index that the re-run drops first

Validation

  • pnpm lint (schema drift included) and type checks for database, business, worker, builder and CLI
  • Unit tests for utils, flow-config, database, business, worker, CLI and builder
  • Database tests for install, sync, uninstall (engine, lifecycle, effects), concurrency, the mutation matrix, reference safety, list paging and the database package
  • Fresh database migrated from zero; the concurrent indexes come out valid
  • Local browser checks of the template list, editor, installs, install detail and share pages at desktop and phone width

@viethung0o0 viethung0o0 added the feature New feature or request label Nov 8, 2026
@viethung0o0
viethung0o0 force-pushed the feat/templates-share-install-sync branch from c00f701 to 6ae93c5 Compare November 8, 2026 17:42
…r-item locks

Templates cover every category, each item with an Include and a View/Edit choice. Referenced tags, custom fields, bot fields, sequences and Places near me categories are installed automatically; a same-name field of another type is created under a suffixed name and {{field}} tokens are rewritten to it.

Reinstalling updates the existing copy in place. With auto-update on, saving a template with real changes syncs every enrolled installation; locally edited copies are backed up first and can be restored. Locked items cannot be edited or deleted in the target workspace; the guard runs in the services under one sorted advisory-lock protocol shared by local edits, syncs, restores and uninstall.

Uninstall, by the installer or by the publisher when the installer allowed it, removes only unmodified copies the installation created. Install, sync and uninstall run as leased, idempotent worker jobs with a sweep that redispatches stuck rows. Share links can expire and be rotated; templates list active installs and have an Installs tab with a per-workspace view.

A tenant owner (a reseller in /manage, the platform admin in /admin) can pick a default template: every workspace created under the tenant afterwards gets it installed in its own creation transaction, dispatched after commit on every creation path. The key is kept only as a hash, set and clear are recorded in an append-only history, and installs a default created are marked Automatic. When the tenant owner published the default, its installs grant the publisher the workspace name and uninstall, as for a manual install; a default published by anyone else stays anonymous.

Templates of the platform (the root tenant) can be installed into workspaces of white-label tenants; a white-label tenant's own templates never leave it. A copy that crosses tenants never gives its publisher access, on install, reinstall or later. The install page offers creating a new workspace and does not ask a cross-tenant installer for publisher access; creating a template asks for its name first, and a new template creates its install folder by default.

Public API (templates token scope) for every operation, mirrored in the CLI and MCP; the UI calls the same service methods. Includes the template-integration skill, the regression testing guide with an end-to-end API check, and all 21 locales.
@viethung0o0
viethung0o0 force-pushed the feat/templates-share-install-sync branch from 6ae93c5 to 20cd0bf Compare November 8, 2026 19:01
@viethung0o0
viethung0o0 marked this pull request as ready for review November 8, 2026 23:38
@viethung0o0
viethung0o0 merged commit e505ac5 into main Nov 8, 2026
15 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants