feat: Linear status sync during loop execution#274
Conversation
Syncs loop execution status to a Linear issue during the run: - Loop start → moves issue to "In Progress" - Loop success → moves to "Done" + adds summary comment - Loop failure → moves to "In Review" + adds error comment Non-blocking: gracefully skips if no API key or issue not found. Exposed as SDK export (createLinearSync) for programmatic use. Closes ENG-1472 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Issue Linking ReminderThis PR doesn't appear to have a linked issue. Consider linking to:
Using If this PR doesn't need an issue, you can ignore this message. |
✔️ Bundle Size Analysis
Bundle breakdown |
Greptile SummaryThis PR adds real-time Linear issue status synchronization to the Key points:
Confidence Score: 3/5
Sequence DiagramsequenceDiagram
participant CLI as ralph run CLI
participant Executor as executor.ts (runLoop)
participant Sync as createLinearSync
participant Linear as LinearIntegration
participant API as Linear GraphQL API
CLI->>Executor: runLoop({ linearSync: "ENG-42" })
Executor->>Sync: createLinearSync({ issueId: "ENG-42" })
Sync->>Linear: updateTask("ENG-42", { status: "In Progress" })
Linear->>API: resolveIssueId + resolveStateId + issueUpdate
API-->>Linear: success
Linear-->>Sync: TaskReference
Sync-->>Executor: handler fn (or null on auth failure)
alt Loop completes successfully
Executor->>Sync: handler({ type: "complete", ... })
Sync->>Linear: updateTask("ENG-42", { status: "Done" })
Linear->>API: resolveIssueId + resolveStateId + issueUpdate
Sync->>Linear: addComment("ENG-42", summary)
Linear->>API: resolveIssueId + commentCreate
API-->>Linear: success
else Loop blocked / failed
Executor->>Sync: handler({ type: "failed", error, iterations })
Sync->>Linear: updateTask("ENG-42", { status: "In Review" })
Linear->>API: resolveIssueId + resolveStateId + issueUpdate
Sync->>Linear: addComment("ENG-42", error details)
Linear->>API: resolveIssueId + commentCreate
API-->>Linear: success
end
Last reviewed commit: 92ed33a |
|
This PR has been automatically marked as stale because it has not had recent activity. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| } else { | ||
| await linearSyncHandler({ | ||
| type: 'failed', | ||
| error: exitReason || 'unknown', |
Check warning
Code scanning / CodeQL
Useless conditional Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 15 days ago
General fix: when a variable is known (or intended) to be always defined/truthy in a given context, avoid using a || fallback that will never be taken; instead, either (a) remove the fallback, or (b) explicitly normalize potentially falsy values before use. This removes useless conditionals and clarifies the intended invariants.
Best fix here: in the Linear sync “failed” payload, replace error: exitReason || 'unknown' with error: String(exitReason || 'unknown'). This preserves the intention of always sending a non-empty error string to Linear, while making the conditional meaningful again. If exitReason is truthy (as CodeQL suggests in most paths), behavior is unchanged apart from explicit string coercion. If there is a rare path where exitReason is falsy, we still get 'unknown' as intended. The important part for the CodeQL warning is that the expression now has a clearly justified fallback and is not merely a misleading conditional that assumes exitReason is always truthy; and by using String(...) we make the payload type explicit.
Concretely, in src/loop/executor.ts, around lines 1810–1815, update the error field assignment in the linearSyncHandler “failed” case. No new imports or additional helpers are needed.
| @@ -1810,7 +1810,7 @@ | ||
| } else { | ||
| await linearSyncHandler({ | ||
| type: 'failed', | ||
| error: exitReason || 'unknown', | ||
| error: String(exitReason || 'unknown'), | ||
| iterations: finalIteration, | ||
| }); | ||
| } |
Summary
--linear-sync <issue-id>flag toralph runthat syncs loop status to a Linear issue in real-timecreateLinearSync) for programmatic useUsage
ralph run "Fix auth bug" --from linear --linear-sync ENG-42Files Changed
src/loop/linear-sync.ts— Linear sync handler with event-driven architecturesrc/loop/__tests__/linear-sync.test.ts— 5 tests covering all transitionssrc/loop/executor.ts— Wire linearSync into loop lifecyclesrc/commands/run.ts— Add linearSync option passthroughsrc/cli.ts— Add--linear-syncCLI flagsrc/index.ts— Export types and factory for SDK usersTest plan
ralph run "task" --linear-sync ENG-XXXmoves ticket through statesCloses ENG-1472
🤖 Generated with Claude Code