Skip to content
Closed
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
30 changes: 30 additions & 0 deletions packages/core/src/tools/task-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,36 @@ describe('TaskListTool', () => {
expect(result.llmContent).toContain('Legacy');
});

it('treats a blank owner filter as omitted', async () => {
const t = await createTask(TEAM, {
subject: 'Owned',
description: 'desc',
});
await updateTask(TEAM, t.id, { owner: 'alice' });

const invocation = tool.build({ owner: ' ' });
const result = await invocation.execute(new AbortController().signal);
expect(result.llmContent).toContain('Owned');
expect(result.llmContent).not.toContain('No tasks found');
});

it('treats a blank blockedBy filter as omitted', async () => {
const dependency = await createTask(TEAM, {
subject: 'Dependency',
description: 'desc',
});
const blocked = await createTask(TEAM, {
subject: 'Blocked',
description: 'desc',
});
await updateTask(TEAM, blocked.id, { addBlockedBy: [dependency.id] });

const invocation = tool.build({ blockedBy: '' });
const result = await invocation.execute(new AbortController().signal);
expect(result.llmContent).toContain('Blocked');
expect(result.llmContent).not.toContain('No tasks found');
});

it('rejects owner filters that sanitize to empty', async () => {
const invocation = tool.build({ owner: '!!!' });
const result = await invocation.execute(new AbortController().signal);
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/tools/task-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ class TaskListInvocation extends BaseToolInvocation<
};
}

const ownerParam = this.params.owner?.trim() || undefined;
const blockedByParam = this.params.blockedBy?.trim() || undefined;

let ownerFilter: string | undefined;
if (this.params.owner !== undefined) {
ownerFilter = sanitizeName(this.params.owner);
if (ownerParam !== undefined) {
ownerFilter = sanitizeName(ownerParam);
if (!ownerFilter) {
const msg =
'Cannot filter by owner: owner must include at least one ' +
Expand All @@ -84,7 +87,7 @@ class TaskListInvocation extends BaseToolInvocation<
const tasks = await listTasks(teamName, {
status: this.params.status,
owner: ownerFilter,
blockedBy: this.params.blockedBy,
blockedBy: blockedByParam,
});

if (tasks.length === 0) {
Expand Down
Loading