дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 10:07:11 +02:00
Порівняти коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
c144dd225a | ||
|
|
151b88aa89 |
No files matched your search
@@ -169,7 +169,7 @@ test("short prompts fit before and after a completed agent exchange", async ({ w
|
||||
await expect.poll(overflow).toEqual({ x: 0, y: 0 });
|
||||
|
||||
await page.getByRole("button", { name: "Agents", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New Agent Task", exact: true }).click();
|
||||
await page.getByLabel("New Agent Task", { exact: true }).click();
|
||||
await expect(box.locator(".cm-placeholder")).toBeVisible();
|
||||
await expect(scroller).toHaveCSS("overflow-x", "hidden");
|
||||
await expect.poll(overflow).toEqual({ x: 0, y: 0 });
|
||||
|
||||
@@ -52,7 +52,7 @@ test.beforeEach(async ({ workbench: page }) => {
|
||||
});
|
||||
});
|
||||
await page.getByRole("button", { name: "Agents", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New Agent Task", exact: true }).click();
|
||||
await page.getByLabel("New Agent Task", { exact: true }).click();
|
||||
await expectVersion(page, "18.20.0");
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ test("refreshes an upgraded agent's version on window focus without losing the d
|
||||
test("refreshes an upgraded agent's version when New Task is reopened", async ({ workbench: page }) => {
|
||||
await page.getByRole("button", { name: "Close Tab", exact: true }).click();
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("test:agent-upgraded")));
|
||||
await page.getByRole("button", { name: "New Agent Task", exact: true }).click();
|
||||
await page.getByLabel("New Agent Task", { exact: true }).click();
|
||||
await expectVersion(page, "18.20.2");
|
||||
});
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ test("the main toolbar compresses long labels before a short branch name", async
|
||||
|
||||
await page.setViewportSize({ width: 1150, height: 620 });
|
||||
const expanded = await Promise.all(labels.map(width));
|
||||
await page.setViewportSize({ width: 690, height: 620 });
|
||||
await page.setViewportSize({ width: 820, height: 620 });
|
||||
// The label cap is applied in a ResizeObserver's animation frame, so wait until both long labels shrank.
|
||||
await expect
|
||||
.poll(async () => (await Promise.all([width(project), width(run)])).every((w) => w.shown < w.preferred))
|
||||
|
||||
@@ -84,7 +84,12 @@ test("the Center group is centred in the main toolbar", async ({ workbench: page
|
||||
...settings,
|
||||
appearance: {
|
||||
...settings?.appearance,
|
||||
mainToolbar: { left: [], center: ["project"], right: ["action:navigate.searchEverywhere"], hidden: [] },
|
||||
mainToolbar: {
|
||||
left: [],
|
||||
center: ["project"],
|
||||
right: ["action:navigate.searchEverywhere"],
|
||||
hidden: ["agents.newTask"],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -120,7 +125,12 @@ test("the project colour gradient follows the Project widget", async ({ workbenc
|
||||
const settings = useProject.getState().settings;
|
||||
useProject.setState({ settings: { ...settings, appearance: { ...settings?.appearance, mainToolbar } } });
|
||||
}, mainToolbar);
|
||||
await layout({ left: [], center: ["project"], right: ["action:navigate.searchEverywhere"], hidden: [] });
|
||||
await layout({
|
||||
left: [],
|
||||
center: ["project"],
|
||||
right: ["action:navigate.searchEverywhere"],
|
||||
hidden: ["agents.newTask"],
|
||||
});
|
||||
for (const width of [1400, 900]) {
|
||||
await page.setViewportSize({ width, height: 700 });
|
||||
await expect(async () => {
|
||||
@@ -132,7 +142,12 @@ test("the project colour gradient follows the Project widget", async ({ workbenc
|
||||
await page.screenshot({ path: "test-results/project-gradient-center.png", animations: "disabled" });
|
||||
|
||||
// Without the widget the gradient goes back to the frame's corner.
|
||||
await layout({ left: [], center: [], right: ["action:navigate.searchEverywhere"], hidden: ["project"] });
|
||||
await layout({
|
||||
left: [],
|
||||
center: [],
|
||||
right: ["action:navigate.searchEverywhere"],
|
||||
hidden: ["project", "agents.newTask"],
|
||||
});
|
||||
await expect(icon).toHaveCount(0);
|
||||
await expect.poll(anchor).toBe("");
|
||||
});
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
.root {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: var(--space-0-5);
|
||||
margin-inline-start: var(--space-3);
|
||||
}
|
||||
/* Splits the button from its ▾, as the toolbar's split buttons do. */
|
||||
.root::after {
|
||||
content: "";
|
||||
order: 1;
|
||||
flex: none;
|
||||
width: 1px;
|
||||
height: var(--space-4);
|
||||
background: var(--border-strong);
|
||||
}
|
||||
.main {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
gap: var(--space-1-5);
|
||||
font-size: var(--fs-chrome);
|
||||
}
|
||||
.label {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.chevron {
|
||||
order: 2;
|
||||
width: var(--space-4);
|
||||
height: var(--h-toolbar-widget);
|
||||
border-radius: var(--radius-toolbar-button);
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
/* A narrow window keeps the toolbar's existing widgets; New Agent Task stays on ⇧⌘I and the Agents tool window. */
|
||||
@media (max-width: 560px) {
|
||||
.root {
|
||||
margin-inline-start: 0;
|
||||
}
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.root {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import type { AgentProvider } from "@/bindings";
|
||||
import { registerActions } from "@/platform/actions";
|
||||
import { NewTaskTitleItem } from "./NewTaskTitleItem";
|
||||
import { useAgents } from "./store";
|
||||
|
||||
const store = vi.hoisted(() => ({ openHome: vi.fn() }));
|
||||
vi.mock("./store", async (original) => ({
|
||||
...(await original<typeof import("./store")>()),
|
||||
openHome: store.openHome,
|
||||
}));
|
||||
|
||||
const provider = (id: string, name: string, installed = true) => ({ id, name, installed }) as AgentProvider;
|
||||
|
||||
describe("NewTaskTitleItem", () => {
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
|
||||
it("starts a task with the selected agent, or picks another one from the menu", () => {
|
||||
const newTask = vi.fn();
|
||||
const dispose = registerActions([{ id: "agents.newTask", title: "New Agent Task", run: newTask }]);
|
||||
useAgents.setState((s) => ({
|
||||
providers: [provider("claude", "Claude Code"), provider("codex", "Codex"), provider("gemini", "Gemini", false)],
|
||||
draft: { ...s.draft, provider: "claude" },
|
||||
}));
|
||||
render(<NewTaskTitleItem />);
|
||||
|
||||
const main = screen.getByRole("button", { name: "New Agent Task" });
|
||||
expect(main).toHaveAttribute("data-tooltip", "New Agent Task with Claude Code");
|
||||
fireEvent.click(main);
|
||||
expect(newTask).toHaveBeenCalledOnce();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Choose Agent" }));
|
||||
expect(screen.queryByText("Gemini")).toBeNull();
|
||||
fireEvent.click(screen.getByText("Codex"));
|
||||
expect(useAgents.getState().draft.provider).toBe("codex");
|
||||
expect(store.openHome).toHaveBeenCalledOnce();
|
||||
dispose();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { BarButton, Icon, IconButton, Menu, type MenuItem } from "@/ui";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { useChromeIconSize } from "@/ui/density";
|
||||
import { providerIcon } from "./model";
|
||||
import { openHome, updateDraft, useAgents } from "./store";
|
||||
import styles from "./NewTaskTitleItem.module.css";
|
||||
|
||||
/** Main toolbar: New Agent Task with the selected agent, and ▾ to start one with another agent. */
|
||||
export function NewTaskTitleItem() {
|
||||
const tx = useTx();
|
||||
const iconSize = useChromeIconSize();
|
||||
const providers = useAgents((s) => s.providers);
|
||||
const selectedId = useAgents((s) => s.draft.provider);
|
||||
const [open, setOpen] = useState(false);
|
||||
const chevron = useRef<HTMLButtonElement>(null);
|
||||
const installed = providers.filter((p) => p.installed);
|
||||
const selected = providers.find((p) => p.id === selectedId) ?? providers[0];
|
||||
|
||||
const items: MenuItem[] = [
|
||||
...installed.map((p) => ({
|
||||
id: p.id,
|
||||
label: p.name,
|
||||
verbatim: true,
|
||||
icon: providerIcon(p.id),
|
||||
checked: p.id === selected?.id,
|
||||
run: () => {
|
||||
if (p.id !== selected?.id) updateDraft({ provider: p.id, config: {} });
|
||||
openHome();
|
||||
},
|
||||
})),
|
||||
...(installed.length ? [{ kind: "separator" } as const] : []),
|
||||
{ kind: "action", action: "agents.addAgent" },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<BarButton
|
||||
variant="title"
|
||||
className={styles.main}
|
||||
tooltip={selected ? tx`New Agent Task with ${selected.name}` : tx("New Agent Task")}
|
||||
shortcut={shortcutLabel("agents.newTask")}
|
||||
onClick={() => void executeAction("agents.newTask")}
|
||||
>
|
||||
<Icon name={selected ? providerIcon(selected.id) : "toolwindow-agents"} size={iconSize} />
|
||||
<span className={styles.label} data-toolbar-label="">
|
||||
{tx("New Agent Task")}
|
||||
</span>
|
||||
</BarButton>
|
||||
<IconButton
|
||||
ref={chevron}
|
||||
icon="chevron-down"
|
||||
iconSize={12}
|
||||
className={styles.chevron}
|
||||
title="Choose Agent"
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
/>
|
||||
<Menu open={open} onClose={() => setOpen(false)} anchor={chevron} items={items} aria-label="Choose Agent" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -23,10 +23,12 @@ import {
|
||||
registerOverlay,
|
||||
registerRunningAgentTasksProvider,
|
||||
registerStatusItem,
|
||||
registerTitleItem,
|
||||
registerToolWindow,
|
||||
toolWindowService,
|
||||
} from "@/workbench/contributions";
|
||||
import { AgentsStatus } from "./AgentsStatus";
|
||||
import { NewTaskTitleItem } from "./NewTaskTitleItem";
|
||||
import { activateSettingsPages } from "./settingsPages";
|
||||
import {
|
||||
AUTOMATIONS_KIND,
|
||||
@@ -265,6 +267,13 @@ export function activate(): () => void {
|
||||
icon: "toolwindow-agents",
|
||||
when: "projectOpen && vcsAvailable && commitAgentButton",
|
||||
}),
|
||||
registerTitleItem({
|
||||
id: "agents.newTask",
|
||||
title: "New Agent Task",
|
||||
align: "right",
|
||||
priority: 10,
|
||||
component: NewTaskTitleItem,
|
||||
}),
|
||||
registerStatusItem({ id: "agents.status", align: "right", priority: 3, title: "Agents", component: AgentsStatus }),
|
||||
registerMenuGroup({
|
||||
id: "agents.send",
|
||||
|
||||
@@ -2547,6 +2547,8 @@
|
||||
"too old, needs JDK {version}+ · {path}": "too old, needs JDK {version}+ · {path}",
|
||||
"Close Agent Task": "Close Agent Task",
|
||||
"Close and New Agent Task": "Close and New Agent Task",
|
||||
"New Agent Task with {name}": "New Agent Task with {name}",
|
||||
"Choose Agent": "Choose Agent",
|
||||
"Focus Agent Input": "Focus Agent Input",
|
||||
"Focuses the message input of the current agent task, or of the one on screen when focus is elsewhere and no panel claims the shortcut, without moving the caret.": "Focuses the message input of the current agent task, or of the one on screen when focus is elsewhere and no panel claims the shortcut, without moving the caret.",
|
||||
"Cycle Agent Effort": "Cycle Agent Effort",
|
||||
|
||||
@@ -5267,6 +5267,8 @@
|
||||
"New Agent Task": "新建 Agent 任务",
|
||||
"Close Agent Task": "关闭 Agent 任务",
|
||||
"Close and New Agent Task": "关闭并新建 Agent 任务",
|
||||
"New Agent Task with {name}": "使用 {name} 新建 Agent 任务",
|
||||
"Choose Agent": "选择 Agent",
|
||||
"Focus Agent Input": "聚焦 Agent 输入框",
|
||||
"Focuses the message input of the current agent task, or of the one on screen when focus is elsewhere and no panel claims the shortcut, without moving the caret.": "聚焦当前 Agent 任务的消息输入框;焦点在其他位置且没有面板占用该快捷键时,聚焦屏幕上显示的任务的输入框。不移动光标。",
|
||||
"Cycle Agent Effort": "循环切换 Agent 思考强度",
|
||||
|
||||
Reference in new issue
Заблокувати користувача