Fix Linear implementer comment mention handling

Merged
KH
5mo ago
+5727-587

User description

Summary

  • Keeps Linear comment.create mention-gating because cloud dispatch uses broad Linear watch paths and does not pre-filter comments by @-mention.
  • Replaces the broken literal @agentrelay substring gate with Linear mention markdown/structured mention detection, inferred agent aliases, and optional MENTION alias overrides.
  • Logs every early-return reason and adds a top-of-handler payload-shape diagnostic so future 0ms handler ACKs are explainable.
  • Hardens issue id extraction for comment payload shapes before calling the existing harness -> PR path.

Notes

  • The existing implementation branch (ctx.harness.run -> PR URL -> Linear comment) is unchanged; this PR fixes the guard that prevented it from being reached.
  • MENTION is optional for the default Agent Relay/linear-implementer identity. Deployments with a custom Linear bot display name or user id should set MENTION to comma-separated aliases if the inferred aliases do not match.
  • The relayfile GitHub/Linear mount materialization and comments/<id>.json path issue observed during probing is separate infra work and intentionally not changed here.

Validation

  • npm run typecheck
  • npm test
  • npm run compile

Summary by cubic

Fixes Linear comment mention handling so the implementer only runs when explicitly addressed, and unwraps relayfile payloads for reliable issue/comment parsing. The PR-opening flow is unchanged; custom bot names can use optional MENTION aliases.

  • Bug Fixes

    • Replace literal handle check with structured mention detection; infer aliases from agent/persona and support optional MENTION.
    • Unwrap relayfile resource.payload and accept camelCase/snake_case fields; harden issue ID/body extraction for comment.create and issue.create.
    • Keep self-reply guard and author identity check; log clear skip reasons with event diagnostics; export handleLinearEvent with unit tests (incl. relayfile shapes) and add npm test.
  • Dependencies

    • Add dev dependency agentworkforce and override @opentelemetry/otlp-transformer to pin protobufjs.

CodeAnt-AI Description

Fix Linear comment mentions so the agent runs only when explicitly addressed

What Changed

  • Linear comments now trigger the agent only when the comment clearly mentions it, instead of relying on a literal handle match.
  • The agent recognizes common mention formats and can use optional alias names for custom Linear bot handles or display names.
  • Comments from the agent itself still stop the loop, and skipped events are now logged with a clear reason.
  • Added coverage for mentioned comments, non-mentioned comments, and self-replies; updated the Linear setup notes to explain the optional mention aliases.

Impact

✅ Fewer missed Linear requests
✅ Fewer accidental PR runs
✅ Clearer Linear setup for custom bot names

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.