Skip to content

feat(automations): add tags to automations - #1819

Open
Christian-Schou wants to merge 18 commits into
cortexapps:mainfrom
Christian-Schou:feat/automation-tags
Open

Christian-Schou wants to merge 18 commits into
cortexapps:mainfrom
Christian-Schou:feat/automation-tags

Conversation

@Christian-Schou

Copy link
Copy Markdown

Problem

The Automations page shows every automation in one flat list. An installation can hold many automations that belong to different teams, and an admin cannot see quickly which automations belong together or filter the list to one group.

Closes #1818

Fix

Installation-wide tags, managed by admins, modeled on GitHub labels.

Orchestrator

  • Two new tables, tag and automation_tag (migration 0101_tags). A tag has a name, a color (#rrggbb) and an optional description. Names are unique without regard to case (lower(name) index).
  • TagService (new tag.proto): list (with a count of non-archived automations), create, update, delete. Deleting a tag removes it from every automation by foreign key.
  • AutomationService.AddAutomationTag / RemoveAutomationTag, and Automation.tags (field 18). A tag change makes no new version. An automation has at most 10 tags. The add locks the automation row FOR NO KEY UPDATE, so concurrent adds cannot pass the limit and inserts that reference the automation (runs) do not wait. DuplicateAutomation copies the tags.
  • The tag rules live in src/tags/rules.ts. The server is their only authority; each rule answers with its own message.
  • All six new RPCs are admin-only. Both protos are orchestrator-native and not compiled into Rust.

Web

  • One chip draws every tag: a descriptor chip whose tint and text come from the stored color at a fixed lightness per theme (CSS relative colors), so any color stays readable. Measured minimum text contrast over the whole hue circle: 6.2:1 light, 7.9:1 dark. Browsers without relative-color support show a neutral chip (@supports).
  • Settings → Tags (Workspace group): search, create, edit in place (quick picks, random color, hex field, the browser's color picker), delete with a count of affected automations.
  • Automations list: a Tags column (2 chips, then "+N" with every tag in its tooltip), a tag filter in the URL with a color swatch per tag, "No tags", and a "Manage tags" link. In a narrow table the column shows the first tag and "+N", and the name line hides its scope badge.
  • Editor: a "Tags" section in the Settings tab with a searchable picker that can also create a tag. Chips never act, as web/DESIGN.md requires.

Deploy: the migration only adds two tables. The previous build runs on the new schema, and a rollback leaves the tables in place. No user data changes.

Also in this branch, in its own commit: an unused next-fire computation in DuplicateAutomation is removed.

Test

  • Orchestrator: bun run typecheck; bun test → 2665 pass, 18 skip, 0 fail. New live-Postgres tests (tag-store.test.ts) cover case-insensitive uniqueness under concurrent creates, the limit under concurrent adds, the lock mode, and cascades. RPC tests cover each rule, admin gating, built-ins and archived automations.
  • Web: pnpm format:check, pnpm lint, pnpm test → 1118 pass, pnpm build.
  • Checked by hand in a browser against a local orchestrator, light and dark, at 1280, 1440 and 1920px windows.

Known follow-ups, not in this change: the as unknown as HarnessCatalogClient cast repeats in five files and needs one shared adapter; some minor edge cases in the tag picker and filter (a "Create" offer for a name that differs only in spaces, a duplicate filter option after a case-only rename).

🤖 Generated with Claude Code

Christian-Schou and others added 18 commits November 19, 2026 09:46
Add the `tag` and `automation_tag` tables and `makeTagStore`. A tag has a
name, a color and a description. Names are unique without regard to case.
Adding a tag to an automation locks the automation row, so concurrent adds
cannot pass the tag limit. Deleting a tag or an automation removes its
links by foreign key. Automation create can link tags in the same write.

The migration only adds two tables, so the previous build runs on it.

Review pass: both link writes now share one definition of an active
automation (it was computed twice), and both Postgres error checks share
one SQLSTATE walk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `tag.proto` with `TagService` (list, create, update, delete). Give
`Automation` a `tags` field and add the AddAutomationTag and
RemoveAutomationTag RPCs to the contract; the next change implements
them. The tag rules live in `src/tags/rules.ts`. The orchestrator is
their only authority, and each rule answers with its own message.

Review pass: no findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implement AddAutomationTag and RemoveAutomationTag. Both are admin-only,
work on built-ins, refuse an archived automation, and never make a new
version. An automation has at most 10 tags. Every automation response
now carries the automation's tags: the list loads them for all rows in
one query, and DuplicateAutomation copies them to the copy.

Review pass: no findings in the changed code. A harness catalog cast in
registerAutomations (`as unknown as`) repeats in four other files; it
needs one shared fix, so it stays out of this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mation

The handler computed the copy's next cron fire time and then discarded
it: the copy starts disabled with no fire time, and turning it on
schedules it. Remove the computation and say why in the comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`TagChip` draws a tag as a descriptor chip with 8px corners. The
`.tag-chip` class redraws the stored color at a fixed lightness per theme
with a capped chroma, so any color gives readable text. The measured
minimum text contrast over the whole hue circle is 6.2:1 in the light
theme and 7.9:1 in the dark theme. A browser without CSS relative colors
shows a neutral chip.

`TagColorField` offers 8 quick picks, a random color, a hex field and the
browser's color picker. The suggested colors use OKLCH hues 205 to 350,
away from the status and accent hues. The field passes on what the admin
enters; the server owns the color rule.

Review pass: no findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settings → Tags (Workspace group, admin-only) lists every tag with its
description and how many automations use it. The count links to the
Automations list filtered by that tag. Admins create a tag (with a random
color unless they pick one), edit its name, description and color in
place, and delete it after a confirmation that says how many automations
lose it. Errors show the server's message.

The automations index route now reads `?tags=` as a list of tag names,
so the count link is typed.

Review pass: with no tags the page showed two "New tag" buttons; only the
heading's remains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each row shows its tags on the second line, before the description: at
most 2 chips, then a "+N" button whose tooltip and accessible name list
every tag. That line now sits outside the row's link, because a button
cannot be inside a link; the name still opens the automation.

A tag filter above the table selects automations with any of the chosen
tags, or with no tags. The selection is in the URL by tag name, so a
filtered view can be shared. A name that matches no tag stays a
selectable option, and an empty result offers "Clear filter". The
heading count reads "shown of total" while a filter is on. "Manage tags"
links to Settings → Tags. The test render helper now returns its router,
so a test can read the URL.

Review pass: the loaded-state check repeated five times; it is now one
constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The editor header shows the automation's tag chips, then one button:
"Add tag" without tags, "Edit tags" with some. It opens a searchable list
of every tag with its description, the automation's own tags checked and
first. Checking a tag adds it; unchecking removes it. A name that matches
no tag, without regard to case, can be created on the spot with a random
color. Errors show the server's message. Chips do not act, so removing a
tag goes through the picker. Create mode shows no picker.

Review pass: no findings. The editor test fixture now carries `tags`, as
a real automation message does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A chip truncates a long name, but its tooltip showed only the
description, so the full name could not be read. The tooltip now always
starts with the name. Two long chips could also overflow the name column
into the Trigger column at narrow widths: the chips now shrink and
truncate, the "+N" button keeps its size, and the description takes only
the space the tags leave. The "+N" button's accessible name now starts
with its visible text, so voice control can reach it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The picker's search scored each tag's name and id together, so a few
letters often matched unrelated tags through their ids. Each item's
search value is now the name alone; names are unique.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The edit form sent name, description and color on every save, so a save
could write back a field this admin did not touch over another admin's
newer value. It now sends only the fields that changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A declaration with var() always parses, so a browser without full CSS
relative-color support did not fall back to the neutral declarations:
the color became unset. The tinted rules now sit behind an @supports
test for the exact syntax they use, and other browsers keep the neutral
chip, as the comment now says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adding a tag locked the automation row FOR UPDATE, which conflicts with
the key-share lock every foreign-key check takes, so an insert of a run
for that automation waited for the tag write. FOR NO KEY UPDATE still
serializes concurrent tag adds (the limit test still holds) and does not
block those inserts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tags shared the name cell's second line with the description, which
squeezed descriptions to a few letters. They now have their own "Tags"
column between "Automation" and "Trigger", so the chips line up and can
be scanned. The name cell is one link again (status dot, name,
description), because the "+N" button now sits in its own cell. The
table's minimum width grows from 860px to 980px for the new column.

Review pass: the comments about the shared second line went with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The filter menu listed tags as plain names, the one place where a tag did
not look like a tag. Each tag option now has a small swatch drawn by the
same rule as its chip (`TagSwatch`). "No tags" and a name in the URL that
matches no tag have none.

Review pass: no findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the editor header, several tags squeezed the narrow name column: the
chips stacked one per line and the header grew very tall. The tags now
live in a "Tags" section of the Settings tab, after "About", as Ghost
keeps tags in its post settings panel: the chips, then "Add tag" or
"Edit tags". The header is as it was before tags.

Review pass: the editor tests no longer mock the tag hooks, which the
header no longer uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Raising the table's minimum width to 980px for the Tags column made the
table scroll sideways at a 1440px window with both side menus open, which
hid the on/off switch. The minimum is 860px again, and the columns give
the name more room. In a narrow Tags cell, a long second tag squeezed the
first one to "B…": the first chip now keeps its width and only the chips
after it truncate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At a 1440px window with both side menus open, the automations table is
about 870px wide, and the Tags column could show only a whole first chip,
a stub of the second ("C…") and "+N". The tag row is now a size
container: below 11rem it shows the first chip, allowed to shrink, and a
"+N" that counts every other tag. When the table is narrower than 68rem,
the name line hides its scope badge ("per PR", "per thread") so the name
stays readable. Wide tables do not change.

Review pass: both "+N" variants share one renderer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Christian-Schou

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

This branch has not been deployed

No deployments
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.

Tags for automations

1 participant