The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
fix(ui): keep No project available in new composer (#15382)
Dottaee3c728b9568
diff --git a/ui/src/components/InlineEntitySelector.test.tsx b/ui/src/components/InlineEntitySelector.test.tsxindex 674a138d98..c831fc1d43 100644--- a/ui/src/components/InlineEntitySelector.test.tsx+++ b/ui/src/components/InlineEntitySelector.test.tsx@@ -352,6 +352,67 @@ describe("InlineEntitySelector", () => {});});+ it("keeps the no-selection action first when requested", async () => {+ const root = createRoot(container);+ const onChange = vi.fn();++ act(() => {+ root.render(+ <InlineEntitySelector+ value="project-1"+ options={[+ { id: "project-1", label: "Project One" },+ { id: "project-2", label: "Project Two" },+ ]}+ recentOptionIds={["project-2"]}+ placeholder="Project"+ noneLabel="No project"+ noneAtTop+ searchPlaceholder="Search projects..."+ emptyMessage="No projects found."+ onChange={onChange}+ />,+ );+ });++ const trigger = container.querySelector("button") as HTMLButtonElement;+ await act(() => trigger.click());++ const options = Array.from(+ document.querySelectorAll<HTMLButtonElement>("[data-mobile-entity-picker-list] > button"),+ );+ expect(options.map((option) => option.textContent)).toEqual([+ "No project",+ "Project One",+ "Project Two",+ ]);++ const searchInput = document.querySelector<HTMLInputElement>('input[placeholder="Search projects..."]');+ const nativeInputValue = Object.getOwnPropertyDescriptor(+ window.HTMLInputElement.prototype,+ "value",+ )?.set;+ await act(() => {+ nativeInputValue?.call(searchInput, "Two");+ searchInput?.dispatchEvent(new Event("input", { bubbles: true }));+ });++ const filteredOptions = Array.from(+ document.querySelectorAll<HTMLButtonElement>("[data-mobile-entity-picker-list] > button"),+ );+ expect(filteredOptions.map((option) => option.textContent)).toEqual([+ "No project",+ "Project Two",+ ]);++ await act(() => {+ searchInput?.dispatchEvent(new KeyboardEvent("keydown", { bubbles: true, key: "Enter" }));+ });+ expect(onChange).toHaveBeenCalledWith("project-2");++ act(() => root.unmount());+ });+it("does not open the popover when disabled", async () => {const root = createRoot(container);const onChange = vi.fn();diff --git a/ui/src/components/InlineEntitySelector.tsx b/ui/src/components/InlineEntitySelector.tsxindex c4f03356e0..8fccd9c327 100644--- a/ui/src/components/InlineEntitySelector.tsx+++ b/ui/src/components/InlineEntitySelector.tsx@@ -16,6 +16,8 @@ interface InlineEntitySelectorProps {options: InlineEntityOption[];placeholder: string;noneLabel: string;+ /** Keep the no-selection action before the selected and recent choices. */+ noneAtTop?: boolean;/** Keep the no-selection action after the project choices. */noneAtEnd?: boolean;searchPlaceholder: string;@@ -72,6 +74,7 @@ export const InlineEntitySelector = forwardRef<HTMLButtonElement, InlineEntitySeoptions,placeholder,noneLabel,+ noneAtTop = false,noneAtEnd = false,searchPlaceholder,emptyMessage,@@ -106,17 +109,19 @@ export const InlineEntitySelector = forwardRef<HTMLButtonElement, InlineEntitySeconst allOptions = useMemo<InlineEntityOption[]>(() => {const baseOptions = [{ id: "", label: noneLabel, searchText: noneLabel }, ...options];const ordered = orderItemsBySelectedAndRecent(baseOptions, value, recentOptionIds);+ if (noneAtTop) return [baseOptions[0]!, ...ordered.filter((option) => option.id)];return noneAtEnd ? [...ordered.filter((option) => option.id), baseOptions[0]!] : ordered;- }, [noneAtEnd, noneLabel, options, recentOptionIds, value]);+ }, [noneAtEnd, noneAtTop, noneLabel, options, recentOptionIds, value]);const filteredOptions = useMemo(() => {const term = query.trim().toLowerCase();if (!term) return allOptions;return allOptions.filter((option) => {+ if (noneAtTop && !option.id) return true;const haystack = `${option.label} ${option.searchText ?? ""}`.toLowerCase();return haystack.includes(term);});- }, [allOptions, query]);+ }, [allOptions, noneAtTop, query]);const currentOption = options.find((option) => option.id === value) ?? null;@@ -128,9 +133,14 @@ export const InlineEntitySelector = forwardRef<HTMLButtonElement, InlineEntitySeuseEffect(() => {if (!open) return;+ const firstSearchResultIndex = noneAtTop && query.trim()+ ? filteredOptions.findIndex((option) => option.id)+ : -1;const selectedIndex = filteredOptions.findIndex((option) => option.id === value);- setHighlightedIndexValue(selectedIndex >= 0 ? selectedIndex : 0);- }, [filteredOptions, open, setHighlightedIndexValue, value]);+ setHighlightedIndexValue(+ firstSearchResultIndex >= 0 ? firstSearchResultIndex : selectedIndex >= 0 ? selectedIndex : 0,+ );+ }, [filteredOptions, noneAtTop, open, query, setHighlightedIndexValue, value]);const commitSelection = (index: number, moveNext: boolean) => {const option = filteredOptions[index] ?? filteredOptions[0];diff --git a/ui/src/components/NewIssueDialog.test.tsx b/ui/src/components/NewIssueDialog.test.tsxindex b92e834bf3..a203a293e8 100644--- a/ui/src/components/NewIssueDialog.test.tsx+++ b/ui/src/components/NewIssueDialog.test.tsx@@ -199,13 +199,14 @@ vi.mock("./InlineEntitySelector", async () => {placeholder?: string;className?: string;triggerDataSlot?: string;+ noneAtTop?: boolean;options?: { id: string; label: string }[];onChange?: (id: string) => void;renderTriggerValue?: (option: { id: string; label: string } | null) => ReactNode;}- >(function InlineEntitySelectorMock({ value, placeholder, className, triggerDataSlot, renderTriggerValue, options = [], onChange }, ref) {+ >(function InlineEntitySelectorMock({ value, placeholder, className, triggerDataSlot, noneAtTop, renderTriggerValue, options = [], onChange }, ref) {return (- <button ref={ref} type="button" className={className} data-slot={triggerDataSlot} onClick={() => onChange?.(options[options.findIndex((option) => option.id === value) + 1]?.id ?? "")}>+ <button ref={ref} type="button" className={className} data-slot={triggerDataSlot} data-none-at-top={noneAtTop || undefined} onClick={() => onChange?.(options[options.findIndex((option) => option.id === value) + 1]?.id ?? "")}>{(renderTriggerValue?.(value ? { id: value, label: value } : null) ?? value) || placeholder}</button>);@@ -453,6 +454,23 @@ describe("NewIssueDialog", () => {act(() => next.root.unmount());});+ it("shows No project first and lets a selected project be cleared", async () => {+ dialogState.newIssueDefaults = { projectId: "project-1" };+ const { root } = renderDialog(container);+ await waitForAssertion(() => expect(container.querySelector('[data-slot="new-issue-compact-control"]')?.textContent).toContain("project-1"));++ const projectPicker = container.querySelector<HTMLButtonElement>('[data-slot="new-issue-compact-control"]')!;+ expect(projectPicker.dataset.noneAtTop).toBe("true");+ act(() => projectPicker.click());++ await typeTextareaValue(container.querySelector<HTMLTextAreaElement>('textarea[aria-label="Describe a task…"]')!, "Create without a project");+ act(() => container.querySelector<HTMLButtonElement>('[aria-label="Create task"]')!.click());+ await waitForAssertion(() => expect(mockIssuesApi.create).toHaveBeenCalled());+ expect(mockIssuesApi.create.mock.calls[0][1].projectId).toBeUndefined();+ expect(getLastProjectId("company-1")).toBe("");+ act(() => root.unmount());+ });+it("submits remembered effort with the agent's default model", async () => {mockAgentsApi.list.mockResolvedValue(defaultAgents.map((agent) => agent.id === "ceo"? { ...agent, adapterConfig: { model: "claude-opus-5" } } : agent));diff --git a/ui/src/components/NewIssueDialog.tsx b/ui/src/components/NewIssueDialog.tsxindex 0a18a57012..9967daeea8 100644--- a/ui/src/components/NewIssueDialog.tsx+++ b/ui/src/components/NewIssueDialog.tsx@@ -1349,7 +1349,7 @@ export function NewIssueDialog() {triggerDataSlot="new-issue-compact-control"contentStyle={entityPickerViewportStyle}noneLabel="No project"- noneAtEnd+ noneAtTopsearchPlaceholder="Search projects..."emptyMessage="No projects found."onChange={handleProjectChange}