Skip to content

feat(linear): Post comment on parent issue when state changes#248

Open
rgibert wants to merge 10 commits into
mainfrom
feat/linear-parent-status-comment-config
Open

feat(linear): Post comment on parent issue when state changes#248
rgibert wants to merge 10 commits into
mainfrom
feat/linear-parent-status-comment-config

Conversation

@rgibert

@rgibert rgibert commented Jun 9, 2026

Copy link
Copy Markdown
Member

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

rgibert added 4 commits June 9, 2026 11:51
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
@rgibert rgibert marked this pull request as ready for review June 9, 2026 17:25
@rgibert rgibert requested a review from a team as a code owner June 9, 2026 17:25
Comment thread src/firetower/incidents/services.py
rgibert added 2 commits June 9, 2026 13:40
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
@rgibert rgibert self-assigned this Jun 9, 2026
Comment thread src/firetower/incidents/services.py
rgibert added 2 commits June 11, 2026 13:16
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
Comment thread src/firetower/incidents/services.py
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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0af5af7. Configure here.

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.

1 participant