Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(projects): assign selected tasks after the picker closes (#7258)

Will Hutchinson6464662d3d16
diff --git a/apps/web/src/features/projects/views/project-picker.test.tsx b/apps/web/src/features/projects/views/project-picker.test.tsx
index c1b86d827c..6984bc860a 100644
--- a/apps/web/src/features/projects/views/project-picker.test.tsx
+++ b/apps/web/src/features/projects/views/project-picker.test.tsx
@@ -1,4 +1,5 @@
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { createSignal, Show } from 'solid-js';
import { afterEach, expect, it, vi } from 'vitest';
import { ProjectPicker } from './project-picker';
@@ -59,6 +60,36 @@ it('closes, then assigns only the given tasks', async () => {
expect(mock.failure).not.toHaveBeenCalled();
});
+it('assigns every selected task after the picker closes', async () => {
+ mock.assignTasks.mockResolvedValue([
+ { taskId: 'task-a' },
+ { taskId: 'task-b' },
+ ]);
+ const [assigning, setAssigning] = createSignal<{ ids: string[] } | undefined>(
+ { ids: ['task-a', 'task-b'] }
+ );
+
+ render(() => (
+ <Show when={assigning()}>
+ {(current) => (
+ <ProjectPicker
+ taskIds={current().ids}
+ onClose={() => setAssigning(undefined)}
+ />
+ )}
+ </Show>
+ ));
+
+ fireEvent.click(screen.getByText('Editable'));
+ await vi.waitFor(() =>
+ expect(mock.assignTasks).toHaveBeenCalledWith('editable', [
+ 'task-a',
+ 'task-b',
+ ])
+ );
+ expect(mock.failure).not.toHaveBeenCalled();
+});
+
it('clears the project and reports per-task failures', async () => {
mock.assignTasks.mockResolvedValue([
{ taskId: 'task', error: 'You need edit access to this task.' },
diff --git a/apps/web/src/features/projects/views/project-picker.tsx b/apps/web/src/features/projects/views/project-picker.tsx
index 871efa00fb..dd0fbe0f2d 100644
--- a/apps/web/src/features/projects/views/project-picker.tsx
+++ b/apps/web/src/features/projects/views/project-picker.tsx
@@ -38,10 +38,12 @@ export function ProjectPicker(props: {
let listRef: HTMLDivElement | undefined;
const assign = async (projectId?: string) => {
+ // The selection that owns these ids unmounts as soon as the picker closes.
+ const taskIds = [...props.taskIds];
// Close first like the other property editors; the save settles after.
props.onClose();
try {
- const results = await commands.assignTasks(projectId, props.taskIds);
+ const results = await commands.assignTasks(projectId, taskIds);
const failed = results.filter((item) => item.error);
if (!failed.length) return;
toast.failure(