fix(autofix): preserve unrelated cron jobs

This commit is contained in:
yiliang114 2026-07-31 03:49:45 +08:00
parent dc0f3ba521
commit 8a190858bb
2 changed files with 12 additions and 1 deletions

View file

@ -694,6 +694,15 @@ describe('BundledSkillLoader', () => {
expiresAt: 2,
jitterMs: 0,
},
{
id: 'similar-prefix-job',
cronExpr: '*/10 * * * *',
prompt: 'autofix tickets weekly',
recurring: true,
createdAt: 1,
expiresAt: 2,
jitterMs: 0,
},
);
const result = await invokeAutofix('off');
@ -702,6 +711,7 @@ describe('BundledSkillLoader', () => {
expect(scheduler.delete).toHaveBeenCalledTimes(2);
expect(scheduler.list).toHaveBeenCalledTimes(2);
expect(scheduler.delete).not.toHaveBeenCalledWith('ordinary-job');
expect(scheduler.delete).not.toHaveBeenCalledWith('similar-prefix-job');
expect(result).toEqual({
type: 'message',
messageType: 'info',

View file

@ -53,9 +53,10 @@ export type CurrentAutofixPullRequestResult =
const AUTOFIX_PROMPT_PATTERN =
/^autofix tick repo=([^\s]+) pr=([1-9]\d*) mode=(propose-only|auto-commit|auto-push) rounds=(\d+) infra-reruns=(\d+)$/;
const OWNER_REPO_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
const AUTOFIX_NAMESPACE_PATTERN = /^autofix tick(?:\s|$)/;
export function isAutofixCronJob(job: Pick<CronJob, 'prompt'>): boolean {
return job.prompt.startsWith('autofix tick');
return AUTOFIX_NAMESPACE_PATTERN.test(job.prompt);
}
export function parseAutofixWatcher(job: CronJob): AutofixWatcher | null {