Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/orchestration/taskScheduler.cancel.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { homedir } from 'node:os';
import { resolve } from 'node:path';
import { TaskScheduler } from './taskScheduler.js';
import type { TaskItem } from './decisionEngine.js';
import type { PipelineResult } from '../agents/pairPipeline.js';
Expand Down Expand Up @@ -58,6 +60,22 @@ describe('TaskScheduler cancellation', () => {
expect(b.wasAborted()).toBe(false);
});

it('cancelProjectTasks matches home-expanded project paths', () => {
const d = deferredExecutor();
sched.startTask(task('home'), resolve(homedir(), 'dev/WAVE'), d.exec);
const n = sched.cancelProjectTasks('~/dev/WAVE');
expect(n).toBe(1);
expect(d.wasAborted()).toBe(true);
});

it('cancelProjectTasks matches relative project paths', () => {
const d = deferredExecutor();
sched.startTask(task('relative'), resolve(process.cwd(), 'relative-WAVE'), d.exec);
const n = sched.cancelProjectTasks('./relative-WAVE');
expect(n).toBe(1);
expect(d.wasAborted()).toBe(true);
});

it("a cancelled result is not counted as failed", async () => {
const d = deferredExecutor();
const events: string[] = [];
Expand Down
8 changes: 7 additions & 1 deletion src/orchestration/taskScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
// ============================================

import { EventEmitter } from 'node:events';
import { homedir } from 'node:os';
import { resolve } from 'node:path';
import type { TaskItem } from './decisionEngine.js';
import type { PipelineResult } from '../agents/pairPipeline.js';

function normalizeProjectPath(path: string): string {
const normalized = path.replace(/\\/g, '/').replace(/\/+$/g, '');
const slashed = path.replace(/\\/g, '/');
const expanded = slashed === '~' || slashed.startsWith('~/')
? `${homedir()}${slashed.slice(1)}`
: slashed;
const normalized = resolve(expanded).replace(/\\/g, '/').replace(/\/+$/g, '');
return normalized || '/';
}

Expand Down
Loading