Skip to content

Commit b040ebe

Browse files
aaronshafclaude
andcommitted
feat: skip local iterations when build is already running
When resuming with --resume and the build is already running or pending on the remote, there's no point running local iterations. We should skip directly to polling the build status. This prevents wasting time and API calls by: 1. Detecting when build is already pending/running during resume check 2. Setting skipToRemotePolling flag in ResumeCheckResult 3. Skipping executeIterations() and going directly to executeFinalPublishStep() 4. Which then polls the build status and handles results Before this fix: - Build is running → runs local iterations anyway → publishes → polls - Wastes time and potentially interferes with running build After this fix: - Build is running → skips local iterations → goes straight to polling - Much faster and cleaner UX Changes: - do-iteration.ts: Add skipToRemotePolling field to ResumeCheckResult - do-iteration.ts: Set skipToRemotePolling=true when build is pending/running - do.ts: Check skipToRemotePolling and skip executeIterations when true 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4bfd48f commit b040ebe

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/cli/commands/do-iteration.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export interface ResumeCheckResult {
1515
completedIterations: number;
1616
/** If true, work is complete and no further action needed */
1717
isComplete: boolean;
18+
/** If true, skip local iterations and go straight to remote polling */
19+
skipToRemotePolling: boolean;
1820
/** Reason for the result (for user feedback) */
1921
reason: string;
2022
}
@@ -149,6 +151,7 @@ export const inferPreviousIterations = (
149151
return {
150152
completedIterations: commitCount,
151153
isComplete: true,
154+
skipToRemotePolling: false,
152155
reason: 'Build passed on remote',
153156
};
154157
}
@@ -158,15 +161,17 @@ export const inferPreviousIterations = (
158161
return {
159162
completedIterations: commitCount,
160163
isComplete: false,
164+
skipToRemotePolling: false,
161165
reason: 'Build failed - needs remote iteration fixes',
162166
};
163167
}
164168

165-
// pending or running - treat as incomplete
166-
console.log(chalk.yellow(`⏳ Build is ${buildResult.state} - treating as incomplete`));
169+
// pending or running - skip local iterations and go straight to polling
170+
console.log(chalk.yellow(`⏳ Build is ${buildResult.state} - will skip to remote polling`));
167171
return {
168172
completedIterations: commitCount,
169173
isComplete: false,
174+
skipToRemotePolling: true,
170175
reason: `Build is ${buildResult.state}`,
171176
};
172177
}
@@ -178,6 +183,7 @@ export const inferPreviousIterations = (
178183
return {
179184
completedIterations: commitCount,
180185
isComplete: false,
186+
skipToRemotePolling: false,
181187
reason: `Unstaged changes detected after ${commitCount} iteration(s)`,
182188
};
183189
}
@@ -187,6 +193,7 @@ export const inferPreviousIterations = (
187193
return {
188194
completedIterations: commitCount,
189195
isComplete: false,
196+
skipToRemotePolling: false,
190197
reason: `${commitCount} iteration(s) completed, ready to continue`,
191198
};
192199
}
@@ -198,6 +205,7 @@ export const inferPreviousIterations = (
198205
return {
199206
completedIterations: 0,
200207
isComplete: false,
208+
skipToRemotePolling: false,
201209
reason: 'Unstaged changes detected, iteration 1 in progress',
202210
};
203211
}
@@ -206,6 +214,7 @@ export const inferPreviousIterations = (
206214
return {
207215
completedIterations: 0,
208216
isComplete: false,
217+
skipToRemotePolling: false,
209218
reason: 'No previous work found',
210219
};
211220
} catch (error) {
@@ -214,6 +223,7 @@ export const inferPreviousIterations = (
214223
return {
215224
completedIterations: 0,
216225
isComplete: false,
226+
skipToRemotePolling: false,
217227
reason: `Error checking previous work: ${error}`,
218228
};
219229
}

src/cli/commands/do.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ export const doCommandEffect = (issueKey: string, options: DoCommandOptions = {}
219219
// If --resume flag is set, infer where we left off and check if complete
220220
options.resume
221221
? inferPreviousIterations(workingDirectory, issueInfo.key, projectConfig)
222-
: Effect.succeed({ completedIterations: 0, isComplete: false, reason: 'Starting fresh' }),
222+
: Effect.succeed({
223+
completedIterations: 0,
224+
isComplete: false,
225+
skipToRemotePolling: false,
226+
reason: 'Starting fresh',
227+
}),
223228
Effect.flatMap((resumeResult) => {
224229
// If work is already complete (build passed), skip everything
225230
if (resumeResult.isComplete) {
@@ -240,6 +245,22 @@ export const doCommandEffect = (issueKey: string, options: DoCommandOptions = {}
240245
});
241246
}
242247

248+
// If build is running/pending, skip local iterations and go straight to remote polling
249+
if (resumeResult.skipToRemotePolling) {
250+
console.log(chalk.blue(`\n⏭️ Skipping local iterations - build is already ${resumeResult.reason}`));
251+
console.log(chalk.dim(' Going straight to remote build polling...'));
252+
253+
return pipe(
254+
executeFinalPublishStep(workingDirectory, issueInfo, [], remote.type, projectConfig, [], options),
255+
Effect.map(({ safetyReport, prResult }) => ({
256+
workingDirectory,
257+
allResults: [],
258+
safetyReport,
259+
prResult,
260+
})),
261+
);
262+
}
263+
243264
const iterations = options.iterations || 2;
244265
const startingIteration = resumeResult.completedIterations;
245266

0 commit comments

Comments
 (0)