Adds an inline thinking-level selector to CustomModelDropdown and migrates existing model-selection surfaces (task form, quick entry, new agent dialog, model selection modal/tab) to use it instead of their own bespoke thinking-level controls. - CustomModelDropdown: add inline thinking-level control (CSS + component logic) - ModelSelectionModal / ModelSelectorTab: drop local thinking-level UI in favor of the dropdown's inline control - NewAgentDialog: migrate to the shared inline thinking-level control - QuickEntryBox: remove now-redundant thinking-level UI, delegate to CustomModelDropdown - TaskForm: migrate to the shared inline thinking-level control - Add/update tests for CustomModelDropdown, ModelSelectionModal, ModelSelectorTab, NewAgentDialog, QuickEntryBox, TaskForm - Add changeset for @runfusion/fusion (feature) - Update dashboard guide docs Files changed: .changeset/fn-7768-inline-thinking-dropdown.md | 7 ++ docs/dashboard-guide.md | 1 + .../app/components/CustomModelDropdown.css | 33 +++++++++ .../app/components/CustomModelDropdown.tsx | 69 ++++++++++++++++- .../app/components/ModelSelectionModal.tsx | 32 +------- .../dashboard/app/components/ModelSelectorTab.tsx | 33 +-------- .../dashboard/app/components/NewAgentDialog.tsx | 18 +---- .../dashboard/app/components/QuickEntryBox.tsx | 59 +-------------- packages/dashboard/app/components/TaskForm.tsx | 23 +----- .../__tests__/CustomModelDropdown.test.tsx | 72 ++++++++++++++++++ .../__tests__/ModelSelectionModal.test.tsx | 48 +++++++++--- .../components/__tests__/ModelSelectorTab.test.tsx | 3 +- .../components/__tests__/NewAgentDialog.test.tsx | 86 ++++++++++++++++++++++ .../components/__tests__/QuickEntryBox.test.tsx | 42 +++++++---- .../app/components/__tests__/TaskForm.test.tsx | 7 +- 15 files changed, 354 insertions(+), 179 deletions(-) Fusion-Task-Id: FN-7768 Fusion-Task-Lineage: 8f32731b-9865-4902-9420-62d3c0295805 Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
87 lines
2.8 KiB
TypeScript
87 lines
2.8 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { render, screen, waitFor, fireEvent } from "@testing-library/react";
|
|
import { NewAgentDialog } from "../NewAgentDialog";
|
|
|
|
vi.mock("../api", async () => {
|
|
const actual = await vi.importActual<typeof import("../api")>("../api");
|
|
return {
|
|
...actual,
|
|
fetchModels: vi.fn().mockResolvedValue({
|
|
models: [{ provider: "openai", id: "gpt-4o", name: "GPT-4o" }],
|
|
}),
|
|
fetchAgents: vi.fn().mockResolvedValue([]),
|
|
fetchPluginRuntimes: vi.fn().mockResolvedValue({ runtimes: [] }),
|
|
createAgent: vi.fn().mockResolvedValue({ id: "agent-1" }),
|
|
};
|
|
});
|
|
|
|
vi.mock("../CustomModelDropdown", () => ({
|
|
CustomModelDropdown: ({
|
|
thinkingLevel,
|
|
onThinkingLevelChange,
|
|
defaultThinkingLevel,
|
|
}: {
|
|
thinkingLevel?: string;
|
|
onThinkingLevelChange?: (value: string) => void;
|
|
defaultThinkingLevel?: string;
|
|
}) => (
|
|
<div data-testid="agent-model-dropdown">
|
|
<select
|
|
data-testid="custom-model-dropdown-thinking"
|
|
value={thinkingLevel || ""}
|
|
onChange={(e) => onThinkingLevelChange?.(e.target.value)}
|
|
>
|
|
{defaultThinkingLevel ? <option value="">Default ({defaultThinkingLevel})</option> : null}
|
|
<option value="off">Off</option>
|
|
<option value="minimal">Minimal</option>
|
|
<option value="low">Low</option>
|
|
<option value="medium">Medium</option>
|
|
<option value="high">High</option>
|
|
<option value="xhigh">Very High</option>
|
|
</select>
|
|
</div>
|
|
),
|
|
}));
|
|
|
|
vi.mock("../SkillMultiselect", () => ({
|
|
SkillMultiselect: () => <div data-testid="skill-multiselect" />,
|
|
}));
|
|
|
|
vi.mock("../AgentGenerationModal", () => ({
|
|
AgentGenerationModal: () => null,
|
|
}));
|
|
|
|
vi.mock("../ExperimentalAgentOnboardingModal", () => ({
|
|
ExperimentalAgentOnboardingModal: () => null,
|
|
}));
|
|
|
|
describe("NewAgentDialog thinking level", () => {
|
|
beforeEach(() => {
|
|
document.body.innerHTML = "";
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("uses CustomModelDropdown thinking control with concrete-only agent semantics", async () => {
|
|
render(<NewAgentDialog isOpen onClose={vi.fn()} onCreated={vi.fn()} />);
|
|
|
|
fireEvent.click(screen.getByTestId("agent-dialog-tab-custom"));
|
|
const thinkingSelect = await screen.findByTestId("custom-model-dropdown-thinking") as HTMLSelectElement;
|
|
|
|
expect(Array.from(thinkingSelect.options).map((option) => option.value)).toEqual([
|
|
"off",
|
|
"minimal",
|
|
"low",
|
|
"medium",
|
|
"high",
|
|
"xhigh",
|
|
]);
|
|
expect(thinkingSelect.value).toBe("off");
|
|
expect(screen.queryByText(/Default/)).toBeNull();
|
|
expect(screen.queryByLabelText("Thinking Level")).toBeNull();
|
|
|
|
fireEvent.change(thinkingSelect, { target: { value: "xhigh" } });
|
|
|
|
await waitFor(() => expect((screen.getByTestId("custom-model-dropdown-thinking") as HTMLSelectElement).value).toBe("xhigh"));
|
|
});
|
|
});
|