feat(linear): Post comment on parent issue when state changes#248
feat(linear): Post comment on parent issue when state changes#248rgibert wants to merge 10 commits into
Conversation
Add two Jinja2 template config fields to LinearConfig for posting comments when a parent Linear issue's workflow state changes: - parent_status_comment_completed: used when all action items are done - parent_status_comment_started: used when an incident is in progress Expose both via the LINEAR settings dict following the same pattern as the existing action item nag comment fields. Co-Authored-By: Claude <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/cr0BpGpZtcU2cpuA25FIpW2OdcXVBuVd_TD8I4UNi-8
Cover the new _comment_parent_issue_status_change() helper with nine tests: completed/started templates, canceled-counts-as-done, empty and whitespace-only templates skip commenting, zero action items, API failure resilience, and template render errors. Co-Authored-By: Claude <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/dLHchExcBC82al4op1_w0nFAoNixM6ORNUJj5-n2ExM
Add _comment_parent_issue_status_change() which renders a Jinja2 template from LINEAR settings and posts a comment on the parent issue after its workflow state is updated. Wire it into _update_parent_issue_status() so the comment is posted only when the state update succeeds. Co-Authored-By: Claude <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/tCBtmLfNirISE8EeLk3zwRkb-gNFdxVpq6Lx2KnsjsY
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/10uEt-yMHSBMpV2hgTO9Ii9B2zOOgLY1AawJE56YeLQ
The GraphQL query already fetches state { type } via ISSUE_FIELDS, but
the return dict was discarding it. Expose it so callers can check the
current state type before making redundant updates.
Co-Authored-By: Claude <noreply@anthropic.com>
Agent transcript: https://claudescope.sentry.dev/share/zE0rzhPkht-CdM7066fpTcSjse8eht6ysIVitFlRsx0
Fetch the parent issue's current state before updating. If it already matches the target state, skip the update_issue call and comment post. This prevents spamming the parent issue with duplicate "Firetower set this issue to..." comments on every action-item sync. If get_issue fails (returns None), fall through to the existing update path to preserve reliability. Co-Authored-By: Claude <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/HpgRbZkX1TIMFHKpVSuXTOf1DJ0QUIcIKlakW4ixWpM
When get_issue returns None, the code cannot determine the current state of the parent issue. Previously it would proceed with the update and post a comment describing a transition that may not have happened. Now it returns early, consistent with the existing guard for matching state. Co-Authored-By: Claude <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/XGpB-bGfRojw3T90v9RFRnEDBL1cZwaTCmkwqsjrPA0
Replace lazy "(s)" suffixes with Jinja conditionals that correctly pluralize "day" and "action item" based on actual count. Co-Authored-By: Claude <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/6LrCPJ7RAsrvngoaj47g2KedAPHpDx4Q_Tp_5v02Uq0
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0af5af7. Configure here.
|
|
||
| parent_issue = linear_service.get_issue(incident.linear_parent_issue_id) | ||
| if not parent_issue or parent_issue.get("state_type") == target_state: | ||
| return |
There was a problem hiding this comment.
Same-type state skips update
Medium Severity
The early return treats the parent as already in the desired workflow when state_type equals target_state, but Linear allows several distinct workflow states that share the same type. Firetower still resolves a single state_id per type, so the parent can remain on a different “started” (or “completed”) state and never receive update_issue or a status comment.
Reviewed by Cursor Bugbot for commit 0af5af7. Configure here.


When Firetower changes the parent Linear ticket's workflow state (via
_update_parent_issue_status()), it now posts a comment explaining why the transition happened -- e.g., "Firetower set this issue to Completed. Incident INC-2001 is Done and all 3 action item(s) are complete."This gives visibility into automated state changes directly in Linear, so people looking at the ticket understand why it moved without needing to check Firetower.
Comments are only posted after a successful
update_issue()call. Template rendering errors and API failures are logged but do not block the state change.Agent transcript: https://claudescope.sentry.dev/share/pzP9lcJ0H-hmoz7k_UeCk-Poj0JBO-AJkfGFWzMo0b0