feat(desktop): custom automation templates and contribute link in template galleries

KI
2mo ago
+339-3

Summary

SUPER-1764 ("Beef up the template page — make it something users can contribute to, or add their own templates"). This ships both halves as a v1, entirely client-side:

Add their own

  • New Save as template action in the automation row menu (context + dropdown, available to owners and team viewers) snapshots the automation's name/prompt/agent/rrule.
  • Saved templates appear in a Your templates section at the top of both template surfaces — the automations empty state and the create-dialog gallery — and pre-fill the create form exactly like built-in templates. Cards get a hover/focus delete button.
  • Persistence is a zustand localStorage store (custom-automation-templates): capped at 50 entries and 10k chars per prompt, identical name+prompt re-saves replace instead of duplicating, quota failures never propagate to callers. Registered in the persisted-key allowlist per the renderer localStorage policy.

Contribute

  • Both galleries end with a Contribute a template link that opens a prefilled GitHub issue ([Automations] Template submission), following the marketing marketplace submission-link pattern. templates/data.ts gets a doc note inviting PRs.

Testing

  • bun test src/renderer/stores/custom-automation-templates.test.ts — 4 tests covering trim/prepend, empty-input rejection, dedupe-replace, and the 50-entry cap; each was mutation-checked (cap and dedupe mutations each fail their test).
  • Persisted-key registry test passes with the new entry.
  • bun run lint clean, apps/desktop typecheck clean.

Not included (possible follow-ups): server-side org-shared templates (would need a DB table + migration), and the project starter-template modal, which is a separate hardcoded surface.

Linear: SUPER-1764


Summary by cubic

Let users save automations as personal templates and see them in both template galleries, plus add a “Contribute a template” link to submit upstream. Delivers SUPER-1764 by making the template page user‑extensible and shareable.

  • New Features
    • Add “Save as template” in the automation row menu (owners and team viewers); snapshots name, prompt, agent, and rrule.
    • Show a “Your templates” section in the automations empty state and the create‑dialog gallery; selecting pre‑fills the form like built‑ins.
    • Template cards for personal entries include a hover/focus delete button.
    • Persist custom templates in a zustand localStorage store named custom-automation-templates; capped at 50 entries and 10k chars/prompt, identical name+prompt re‑saves replace, quota failures are swallowed; registered in the persisted‑key allowlist.
    • Add “Contribute a template” link at the end of both galleries to open a prefilled GitHub issue ([Automations] Template submission); templates/data.ts invites PRs.

Summary by CodeRabbit

  • New Features
    • Save existing automations as reusable custom templates.
    • Browse personal templates in the automation gallery and empty state.
    • Delete saved templates directly from template cards.
    • Custom templates persist between sessions and support up to 50 entries.
    • Added a link for contributing automation templates.
  • Bug Fixes
    • Improved template handling by trimming input, preventing blank entries, and replacing duplicates with the same name or prompt.