8000 feat(automations): the variable picker's catalog and a template's preview for a draft automation by adeelahmad · Pull Request #461 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(automations): the variable picker's catalog and a template's preview for a draft automation - #461

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-oi3om9
Oct 16, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-oi3om9

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Workflow studio M9, part 3 of 3 (variables and templates). Parts 1 (#454, templates) and 2 (#460, saved variables) are merged.

Description

Before: to write {{ events.mail.object.subject }} you had to know the kind's field names. The only way to see what a template gives was to save the automation and run it.

After:

  • Variable catalog (variables.catalog, POST /api/v1/automations/variables {draft, node?}): what a draft automation's templates can read. Each entry has {path, type, label, example, group, untrusted}.
    • The run context's keys and fields (user.email, namespace.name, now...).
    • Each trigger's activity, events.<as>.<field>, from its kind's schema with the sample's values. A schedule or at trigger starts on clock.tick and a webhook on webhook.received.
    • event.<field> for the fields every trigger's kinds share. A batch's activities come as a list (events.mail.0...).
    • The saved variables, and with node, what the action and decide nodes before it pass on (steps.<id>.<field>), from each action's output schema. An ask_model with a json_schema gives the object that schema describes.
  • Preview (variables.preview, POST /api/v1/automations/preview {template, draft, activity?, trigger?, node?, prompt?}): what a template gives before the automation is saved.
    • It renders against a real activity by id (404 for one you can't see) or the trigger kind's sample.
    • A param's value keeps its type. A prompt shows outside text marked, as the model will see it, with rules.
    • The steps before node are stand-ins named by their path ([steps.ask.trip]).
    • A template that fails comes back as 200 with error (the missing variable and its nearest name) and line. A draft that doesn't check is a 400.
  • Access: anyone signed in may use both, over their own namespaces only. A draft's id must be an automation they may change, or the answer is 404.
  • MCP: automation_variables and preview_template, both read-only.

Motivation and Context

Workflow studio, module M9 (brief workflow-studio/briefs/M9.md, items 6 and 7). This is what the builder's variable picker and its preview line (M11) read.

Defaults taken (reversible):

  • Earlier steps are stand-ins rather than a dry run of the nodes before the template's. This keeps the preview instant and free of model calls; a dry run is under Refine later.
  • event.* lists only the fields every trigger's kinds share, so a picked path works whichever trigger fired.
  • A template that fails returns 200 with error, so the builder can show it under the field.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests (tests/api/test_automation_preview.py). They cover two joined kinds, an upstream action, batch and schedule triggers, a preview against the sample and against a real activity (with a 404 for one the person can't see), prompts, errors and the MCP tools.
  • My change requires documentation updates, and I have updated docs/ accordingly: docs/automations.md (The variable picker and preview), docs/api.md and docs/mcp.md.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md. (n/a)

Done questions (AGENTS.md)

  • Goal: completes M9 once merged with green CI.
  • Agents: the automation_variables and preview_template MCP tools, as well as the REST API.
  • Zero setup: no new prerequisite.
  • Fewest clicks: the picker lists every path with an example, and the preview shows the result and the nearest name for a typo.
  • Configurable: n/a, no new setting.
  • Light: pure Python. A preview runs no node and calls no model.
  • Private and secure: previews read only activities, namespaces and automations the person may see, and render in the existing Jinja sandbox. I added a new entry point to the threat model (all three files).
  • Cost: n/a, no model calls.
  • User decides: read-only; nothing is saved.
  • Upgrades: n/a, no stored data changes.
  • Honest: the docs status table marks the picker and preview built.
  • Tests and docs updated, and the client regenerated with make openapi.
  • Open standards: JSON Schema types for each entry, with no new dependencies.
  • Refine later items are written in docs/automations.md: a dry-run preview of the nodes before, a saved prompt template's output schema in the picker, and matching on variables (M5). I removed the old "an action's outputs in the variable picker" bullet, which this delivers.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JZDyxMfCBYNRw12CHqE9ss


Generated by Claude Code

…view for a draft automation

variables.catalog lists what a draft's templates can read (the run context, each trigger's activity fields from its
kind's schema, the saved variables, and the outputs of the nodes before a node), with types, labels, examples and
which are outside text. variables.preview renders a template against a real activity or the trigger kind's sample,
prompts shown marked as the model sees them, errors with the nearest name and line. POST /api/v1/automations/variables
and /preview, and the automation_variables and preview_template MCP tools.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JZDyxMfCBYNRw12CHqE9ss
@adeelahmad adeelahmad self-assigned this Oct 16, 2026
@adeelahmad
adeelahmad merged commit 223a2c2 into main Oct 16, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-oi3om9 branch October 16, 2026 02:33
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.

2 participants

0