Skip to content

Commit b969b7d

Browse files
Fix: correctly promote push events to Linear/Jira context and refine interaction detection
Co-authored-by: Junie <[email protected]>
1 parent 5931fd0 commit b969b7d

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/github/context.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,12 @@ export function extractJunieWorkflowContext(tokenOwner: TokenOwner): JunieExecut
265265
if (process.env.LINEAR_API_TOKEN && process.env.ALL_INPUTS) {
266266
try {
267267
const allInputs = JSON.parse(process.env.ALL_INPUTS);
268-
if (allInputs.action === LINEAR_EVENT_ACTION) {
268+
if (allInputs.action === LINEAR_EVENT_ACTION || (allInputs.issue_id && allInputs.issue_title)) {
269+
console.log("✓ Detected Linear issue data in push event inputs - promoting to Linear event context");
269270
return extractLinearEventData({ inputs: allInputs } as any, commonFields);
270271
}
271-
if (allInputs.action === JIRA_EVENT_ACTION) {
272+
if (allInputs.action === JIRA_EVENT_ACTION || (allInputs.issue_key && allInputs.issue_summary)) {
273+
console.log("✓ Detected Jira issue data in push event inputs - promoting to Jira event context");
272274
return extractJiraEventData({ inputs: allInputs } as any, commonFields);
273275
}
274276
} catch (e) {
@@ -578,6 +580,11 @@ export function isMinorFixEvent(context: JunieExecutionContext) {
578580
export function isTriggeredByUserInteraction(
579581
context: JunieExecutionContext,
580582
): context is UserInitiatedEventContext {
583+
// Exclude push events from "user interaction" because they don't have trigger phrases usually
584+
// and we want to avoid unnecessary permission checks on every push
585+
if (context.eventName === "push") {
586+
return false;
587+
}
581588
return USER_TRIGGERED_EVENTS.includes(context.eventName as UserTriggeredEventName);
582589
}
583590

src/github/junie/prepare-junie.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,14 @@ export async function initializeJunieExecution({
110110

111111
async function shouldHandle(context: JunieExecutionContext, octokit: Octokits): Promise<boolean> {
112112
console.log(`Checking if Junie should handle event: ${context.eventName}`);
113+
114+
// Check for Linear/Jira first, regardless of event type (support push event triggers for tests)
113115
if (isLinearWorkflowDispatchEvent(context)) {
114116
console.log("✓ Linear task detected - handling task");
115117
try {
116118
getLinearClient(); // Just to verify token early
117119
} catch (e) {
118120
console.warn(`Linear client initialization failed: ${e instanceof Error ? e.message : String(e)}`);
119-
// We don't return false here because we still want to try running the action
120121
}
121122
return true;
122123
}

0 commit comments

Comments
 (0)