Skip to content

feat(triggers): support PM triggers for work items created directly in a triggering status#1141

Merged
zbigniewsobiecki merged 2 commits intodevfrom
feature/pm-triggers-created-status
Apr 18, 2026
Merged

feat(triggers): support PM triggers for work items created directly in a triggering status#1141
zbigniewsobiecki merged 2 commits intodevfrom
feature/pm-triggers-created-status

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Apr 18, 2026

Summary

  • Extend LinearStatusChangedTrigger.matches() to also match action: 'create' events (issues created directly in a triggering Linear state)
  • Extend JiraStatusChangedTrigger to match and handle jira:issue_created events (reading status from issue.fields.status.name instead of changelog)
  • Update Linear and JIRA unit tests to cover creation scenarios
  • Fix pre-existing credential-scoping.test.ts failures caused by JIRA env vars leaking into tests
  • Trello already handled both createCard and updateCard — no changes needed

Card: https://trello.com/c/ysRpf882/612-support-pm-triggers-for-work-items-created-directly-in-a-triggering-status

Root Cause

Linear trigger checked payload.action === 'update' && updatedFrom.stateId, and JIRA trigger checked jira:issue_updated — neither matched when an issue was created directly in a triggering status. Trello's factory already had isMove || isCreate.

Changes

src/triggers/linear/status-changed.ts

  • matches() now also returns true for action === 'create' && type === 'Issue'
  • handle() is unchanged — already reads data.stateId and data.identifier which are present on both create and update events

src/triggers/jira/status-changed.ts

  • matches() now also returns true for webhookEvent === 'jira:issue_created'
  • handle() delegates status resolution to a new resolveNewStatus() helper that reads from issue.fields.status.name for creation events and from changelog for update events
  • Extracted helper also reduces cognitive complexity (lint compliance)

Tests

  • tests/unit/triggers/linear-status-changed.test.ts: Updated test that expected action: 'create' to NOT match; added 3 new tests for creation event handling
  • tests/unit/triggers/jira-status-changed.test.ts: Updated test that expected jira:issue_created to NOT match; added issueStatusName fixture support and 4 new tests for creation event handling
  • tests/unit/cli/credential-scoping.test.ts: Added cleanup of JIRA_EMAIL/JIRA_API_TOKEN/JIRA_BASE_URL in beforeEach so tests pass when these env vars are set in the environment

Test Plan

  • linear-status-changed.test.ts — 24 tests pass
  • jira-status-changed.test.ts — 25 tests pass
  • status-changed.test.ts (Trello) — 11 tests pass (no changes, already handled both cases)
  • credential-scoping.test.ts — 8 tests pass (was 6 failing, now fixed)
  • Lint: no errors
  • Typecheck: no errors

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

Cascade Bot and others added 2 commits April 18, 2026 08:59
…n a triggering status

- Extend LinearStatusChangedTrigger.matches() to also match action: 'create' events
- Extend JiraStatusChangedTrigger to match and handle jira:issue_created events
- Update Linear and JIRA unit tests to cover creation scenarios

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
JIRA_EMAIL/JIRA_API_TOKEN/JIRA_BASE_URL were set in the CI/dev
environment causing resolvePmType() to return 'jira' instead of
'trello' for tests that don't set CASCADE_PM_TYPE, leading to
createPMProvider failing with "JIRA integration requires projectKey".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

zbigniewsobiecki added a commit that referenced this pull request Apr 18, 2026
Make the create-path firing (added by PR #1141) independently configurable
per agent via the existing declarative YAML/CLI/dashboard pipeline.

Two boolean params on pm:status-changed:
- onMove   (default true)  — fire when an item is moved into the status
- onCreate (default false) — fire when an item is created in the status

Linear and JIRA: preserve pre-#1141 behavior by default; users opt in
explicitly. Trello: data migration backfills onCreate=true for existing
projects so fire-on-create keeps working without silent regression.

Also tightens create-path matches() to require status presence, restores
fromStatus in JIRA update-path log, de-dups the JIRA test helper's
ternary, and extracts resolveAgentType/shouldFireOnEvent helpers to keep
handler complexity in check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit 297a7e0 into dev Apr 18, 2026
9 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the feature/pm-triggers-created-status branch April 18, 2026 12:54
zbigniewsobiecki added a commit that referenced this pull request Apr 18, 2026
Make the create-path firing (added by PR #1141) independently configurable
per agent via the existing declarative YAML/CLI/dashboard pipeline.

Two boolean params on pm:status-changed:
- onMove   (default true)  — fire when an item is moved into the status
- onCreate (default false) — fire when an item is created in the status

Linear and JIRA: preserve pre-#1141 behavior by default; users opt in
explicitly. Trello: data migration backfills onCreate=true for existing
projects so fire-on-create keeps working without silent regression.

Also tightens create-path matches() to require status presence, restores
fromStatus in JIRA update-path log, de-dups the JIRA test helper's
ternary, and extracts resolveAgentType/shouldFireOnEvent helpers to keep
handler complexity in check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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