Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai c51383d2f9 Merge remote-tracking branch 'origin/main' into t7015 2026-11-30 22:55:14 +08:00
l0ng-ai 9f1380cf04 fix(agents): edit user messages in place without layout jump (#7007)
Clicking Edit on a user message replaced the bubble with a full-width, left-aligned textarea and dropped the timestamp and You label, so the text jumped. Editing now stays inside the user message container: the header is kept, the editor takes the measured bubble width (bounded by the bubble max-width) with the same padding, and the actions sit under it.
2026-11-30 22:54:56 +08:00
l0ng-ai 23edb66193 fix(agents): align task controls and questions with workbench styling 2026-11-30 18:31:37 +08:00
18 змінених файлів з 684 додано та 189 видалено

No files matched your search

+65
Переглянути файл
@@ -0,0 +1,65 @@
import type { AgentTask } from "../src/bindings";
import { expect, test } from "./fixtures";
const task: AgentTask = {
id: "composer-icons",
title: "Composer icons",
provider: "codex",
status: "ready",
isolation: "local",
model: null,
cwd: "/dev/acme-api",
branch: null,
base: null,
baseCommit: null,
error: null,
createdMs: 0,
updatedMs: 0,
config: [],
commands: [],
usage: null,
queue: [],
};
for (const theme of ["light", "dark"] as const) {
test(`${theme}: Skills uses the same icon colour and size as peer composer actions`, async ({
workbench: page,
}, testInfo) => {
await page.evaluate(
async ({ task, theme }) => {
const storePath = "/src/features/agents/store.ts";
const themePath = "/src/workbench/theme.ts";
const store = await import(storePath);
await (await import(themePath)).setTheme(theme);
store.useAgents.setState({
loaded: true,
error: null,
tasks: new Map([[task.id, task]]),
entries: new Map([[task.id, []]]),
sessionLocation: "editor",
});
store.openTask(task.id);
},
{ task, theme },
);
await expect(page.locator("html")).toHaveAttribute("data-theme", theme);
await page.getByRole("button", { name: "Add Context" }).click();
const menu = page.getByRole("menu", { name: "Add Context" });
const skills = menu.getByRole("menuitem", { name: "Skills…" });
const memory = menu.getByRole("menuitem", { name: "Memory…" });
const peerColour = await memory.locator("svg circle").evaluate((el) => getComputedStyle(el).stroke);
await expect(skills.locator("svg path")).toHaveCSS("stroke", peerColour);
const peerSize = await memory.locator("svg").evaluate((el) => {
const { width, height } = getComputedStyle(el);
return { width, height };
});
await expect(skills.locator("svg")).toHaveCSS("width", peerSize.width);
await expect(skills.locator("svg")).toHaveCSS("height", peerSize.height);
await skills.hover();
await expect(skills.locator("svg path")).toHaveCSS("stroke", peerColour);
await menu.screenshot({ path: testInfo.outputPath("add-context.png"), animations: "disabled" });
await page.keyboard.press("Escape");
await expect(menu).toBeHidden();
});
}
+167
Переглянути файл
@@ -0,0 +1,167 @@
import type { AgentEntry, AgentTask } from "../src/bindings";
import { expect, test } from "./fixtures";
const base: AgentTask = {
id: "recovery-style",
title: "Recovery",
provider: "codex",
status: "ready",
isolation: "local",
model: null,
cwd: "/dev/acme-api",
branch: null,
base: null,
baseCommit: null,
error: null,
createdMs: 0,
updatedMs: 0,
config: [],
commands: [],
usage: null,
queue: [],
};
const question: AgentEntry = {
type: "question",
id: "question-style",
title: "Choose the implementation",
chosen: null,
questions: [
{
header: "Implementation",
question: "Which approach should I use?",
options: [
{
label: "Reuse existing controls (Recommended)",
description: "Keep the existing behavior and theme.",
preview: "Use shared Button and Input components.",
},
{
label: "Create a custom control",
description: "Requires additional maintenance.",
preview: "Introduce a new component.",
},
],
},
{
header: "Tests",
question: "Which tests should I run?",
multiSelect: true,
options: [
{ label: "Unit tests", description: "Run focused component tests." },
{ label: "Browser tests", description: "Verify the rendered workflow." },
],
},
],
};
for (const theme of ["light", "dark"] as const) {
test(`${theme}: agent recovery and question controls follow the workbench style`, async ({
workbench: page,
}, testInfo) => {
await page.evaluate(
async ({ base, question, theme }) => {
const storePath = "/src/features/agents/store.ts";
const themePath = "/src/workbench/theme.ts";
const store = await import(storePath);
await (await import(themePath)).setTheme(theme);
const recovery: AgentTask = { ...base, interrupted: { reason: "quit", atMs: Date.now() - 120_000 } };
const ask: AgentTask = { ...base, id: "ask-style", title: "Question" };
const entries: AgentEntry[] = [
{ type: "user", text: "Continue with the implementation.", attachments: [], recovery: "windowClose" },
{ type: "agent", text: "The implementation is ready to continue." },
];
store.useAgents.setState({
loaded: true,
error: null,
tasks: new Map([
[recovery.id, recovery],
[ask.id, ask],
]),
entries: new Map([
[recovery.id, entries],
[ask.id, [question]],
]),
sessionLocation: "editor",
});
store.openTask(recovery.id);
},
{ base, question, theme },
);
const resume = page.getByRole("button", { name: "Resume", exact: true });
await expect(resume).toBeVisible();
const resumeColor = await resume.evaluate((el) => getComputedStyle(el).color);
await expect(resume.locator("svg path")).toHaveCSS("stroke", resumeColor);
const record = page.getByRole("separator").filter({ hasText: "Resumed after window close" });
const recordColor = await record.evaluate((el) => getComputedStyle(el).color);
await expect(record.locator("svg path")).toHaveCSS("stroke", recordColor);
await page
.getByRole("tabpanel", { name: "Recovery" })
.screenshot({ path: testInfo.outputPath("recovery.png"), animations: "disabled" });
await page.evaluate(async () => {
const storePath = "/src/features/agents/store.ts";
const { useAgents } = await import(storePath);
const tasks = new Map(useAgents.getState().tasks);
const current = tasks.get("recovery-style") as AgentTask;
tasks.set(current.id, {
...current,
status: "running",
interrupted: null,
retry: {
attempt: 1,
maxRetries: null,
retryAtMs: Date.now() + 30_000,
deadlineMs: Date.now() + 3_600_000,
error: "Connection lost",
},
});
useAgents.setState({ tasks });
});
const resumeNow = page.getByRole("button", { name: "Resume Now", exact: true });
await expect(resumeNow).toBeVisible();
await expect(resumeNow.locator("svg path")).toHaveCSS("stroke", resumeColor);
await page.evaluate(async () => {
const storePath = "/src/features/agents/store.ts";
(await import(storePath)).openTask("ask-style");
});
const card = page.getByRole("form", { name: "Choose the implementation" });
await expect(card).toBeVisible();
await expect(card.getByRole("button", { name: "Submit" })).toBeDisabled();
const buttonHeight = await card
.getByRole("button", { name: "Submit" })
.evaluate((el) => getComputedStyle(el).height);
await expect(card.getByRole("button", { name: "Next" })).toHaveCSS("height", buttonHeight);
await expect(card.getByRole("button", { name: "Previous" })).toHaveCSS("height", buttonHeight);
await expect(card.getByText("Implementation", { exact: true })).toHaveCount(1);
const choice = card.getByRole("radio", { name: /^Reuse existing controls/ });
const row = choice.locator("xpath=ancestor::label");
await expect(row).toHaveCSS("border-top-width", "0px");
await card.screenshot({ path: testInfo.outputPath("question.png"), animations: "disabled" });
await row.click();
await expect(card.getByRole("tab", { name: "Tests" })).toHaveAttribute("aria-selected", "true");
const checkbox = card.getByRole("checkbox", { name: /^Unit tests/ });
const checkboxRow = checkbox.locator("xpath=ancestor::label");
await checkboxRow.click();
await expect(checkbox).toBeChecked();
const selectionColor = await page.evaluate(() => {
const probe = document.createElement("span");
probe.style.backgroundColor = "var(--bg-tree-selected)";
document.body.append(probe);
const color = getComputedStyle(probe).backgroundColor;
probe.remove();
return color;
});
await expect(checkboxRow).toHaveCSS("background-color", selectionColor);
await expect(card.getByRole("button", { name: "Submit" })).toBeEnabled();
await card.screenshot({ path: testInfo.outputPath("question-selected.png"), animations: "disabled" });
await page.setViewportSize({ width: 900, height: 800 });
const composer = card.locator("xpath=following-sibling::div[1]").locator("[data-owns-file-drop]:visible");
const cardBounds = await card.boundingBox();
const composerBounds = await composer.boundingBox();
expect(cardBounds).not.toBeNull();
expect(composerBounds).not.toBeNull();
expect(Math.abs(cardBounds!.x - composerBounds!.x)).toBeLessThan(2);
expect(Math.abs(cardBounds!.width - composerBounds!.width)).toBeLessThan(2);
await card.screenshot({ path: testInfo.outputPath("question-narrow.png"), animations: "disabled" });
});
}
+2 -2
Переглянути файл
@@ -458,7 +458,7 @@ export function AgentsView() {
}
return [];
};
const rowButton = (label: string, icon: "pin" | "archive" | "resume", run: () => void) => (
const rowButton = (label: string, icon: "pin" | "archive" | "agent-resume", run: () => void) => (
<button
type="button"
className={styles.rowAction}
@@ -645,7 +645,7 @@ export function AgentsView() {
)}
<span className={styles.rowActions}>
{(interrupted || isWaitingForNetwork(n.task)) &&
rowButton("Resume", "resume", () => void executeAction("agents.resumeTasks", [n.task.id]))}
rowButton("Resume", "agent-resume", () => void executeAction("agents.resumeTasks", [n.task.id]))}
{pinned.has(n.task.id)
? rowButton("Unpin", "pin", () => pinTasks([n.task.id], false))
: rowButton("Pin", "pin", () => pinTasks([n.task.id], true))}
+1 -1
Переглянути файл
@@ -224,7 +224,7 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
provider
? [
{ id: "mcp", label: "MCP Servers…", icon: "plugin", run: openMcp },
{ id: "skills", label: "Skills…", icon: "bulb", run: openSkills },
{ id: "skills", label: "Skills…", icon: "skills", run: openSkills },
{ id: "memory", label: "Memory…", icon: "history", run: openMemory },
]
: undefined
+164 -44
Переглянути файл
@@ -28,9 +28,15 @@
.fitWidth .stream > * {
width: 100%;
}
.fitWidth .userMessage > .user {
.fitWidth .userMessage > .user,
.fitWidth .userMessage > .editCard,
.fitWidth .userMessage > .editNote,
.fitWidth .userMessage > .editError {
max-width: var(--session-card-width);
}
.fitWidth .userMessage > .editCard {
width: var(--edit-width, var(--session-card-width));
}
.fitWidth .composerArea {
max-width: none;
}
@@ -149,19 +155,24 @@
color: var(--fg-subtle);
}
/* The archived / interrupted / waiting-for-network notice above the conversation. */
/* Inset session notices share the composer and permission card geometry. */
.banner {
flex: none;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-1) var(--space-2);
min-height: 36px;
padding: 9px 12px;
min-height: calc(var(--h-control) + var(--space-2) * 2);
padding: var(--space-1-5) var(--space-2);
background: var(--bg-feedback-warning);
border-bottom: 1px solid var(--border-feedback-warning);
border: 1px solid var(--border-feedback-warning);
border-radius: var(--radius-control);
color: var(--fg-strong);
}
.bannerNeutral {
background: var(--bg-elev);
border-color: var(--border-strong);
}
.bannerIcon {
flex: none;
color: var(--warning);
@@ -179,7 +190,9 @@
font-size: var(--fs-small);
}
.bannerActions {
flex: none;
flex: 0 1 auto;
min-width: 0;
max-width: 100%;
display: flex;
flex-wrap: wrap;
align-items: center;
@@ -206,9 +219,7 @@
align-items: center;
gap: var(--space-1-5);
padding: 2px var(--space-2);
border: 1px solid var(--border);
border-radius: var(--radius-small);
background: var(--bg-elev);
--icon-color: currentColor;
}
/* The conversation with its find bar. */
@@ -338,6 +349,15 @@
width: fit-content;
max-width: min(var(--session-card-width), 720px);
}
.userMessage > .editCard {
width: var(--edit-width, min(var(--session-card-width), 720px));
min-width: min(100%, 220px);
max-width: min(var(--session-card-width), 720px);
}
.userMessage > .editNote,
.userMessage > .editError {
max-width: min(var(--session-card-width), 720px);
}
.userMessage > .messageHead {
justify-content: flex-end;
}
@@ -518,33 +538,131 @@
overflow-wrap: anywhere;
}
/* In-place bubble editor: matches the Islands composer frame and keeps the text origin fixed. */
.editCard {
box-sizing: border-box;
display: flex;
flex-direction: column;
border-radius: var(--radius-tab);
background: var(--bg-elev);
box-shadow: inset 0 0 0 1px var(--border-popup);
cursor: text;
transition:
background var(--dur-fast) var(--ease),
box-shadow var(--dur-fast) var(--ease);
}
.editCard:focus-within {
background: var(--bg-field, var(--bg-button));
box-shadow:
inset 0 0 0 1px var(--focus-ring),
0 0 0 1px var(--focus-ring);
}
@media (prefers-reduced-motion: reduce) {
.editCard {
transition: none;
}
}
.editField {
display: grid;
grid-template-columns: minmax(0, 1fr);
min-width: 0;
max-height: 280px;
}
.editMirror,
.editMessage {
grid-area: 1 / 1;
min-width: 0;
margin: 0;
padding: 6px 10px 4px;
border: 0;
font: inherit;
line-height: 1.4;
white-space: pre-wrap;
overflow-wrap: anywhere;
box-sizing: border-box;
}
.editMirror {
visibility: hidden;
pointer-events: none;
max-height: 280px;
overflow: hidden;
-webkit-user-select: none;
user-select: none;
}
.editMessage {
width: 100%;
box-sizing: border-box;
padding: 6px 8px;
resize: vertical;
font: inherit;
height: 100%;
min-height: 0;
overflow-y: auto;
resize: none;
background: transparent;
color: var(--fg-strong);
background: var(--bg-input);
border: 1px solid var(--accent);
border-radius: var(--radius-control);
caret-color: var(--fg-strong);
outline: none;
}
.editBar {
.editImages {
padding: 0 10px 4px;
}
.editImages .images {
margin-top: 0;
}
.editFooter {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-2);
margin-top: 6px;
font-size: var(--fs-small);
padding: 2px 6px 6px 10px;
cursor: default;
}
.editHint {
display: inline-flex;
align-items: center;
gap: var(--space-0-5);
color: var(--fg-faint);
font-size: var(--fs-tiny, 11px);
-webkit-user-select: none;
user-select: none;
}
.editHint kbd {
display: inline-grid;
place-items: center;
min-width: 16px;
height: 16px;
padding: 0 3px;
border-radius: var(--radius-small);
background: var(--bg-hover);
color: var(--fg-muted);
font-family: var(--font-keys, inherit);
font-size: var(--fs-tiny, 11px);
}
.editButtons {
display: flex;
gap: var(--space-1-5);
display: inline-flex;
align-items: center;
gap: var(--space-1);
margin-left: auto;
}
.editError {
margin-top: var(--space-1-5);
font-size: var(--fs-small);
}
.editNote {
margin-top: var(--space-1);
color: var(--fg-subtle);
font-size: var(--fs-small);
line-height: 1.35;
text-align: right;
}
.markdown {
line-height: 1.4;
overflow-wrap: anywhere;
@@ -1620,12 +1738,12 @@
text-overflow: ellipsis;
}
/* An open AskUserQuestion: every question with its options, answered at once in the conversation. */
/* Questions and forms use the same inset selection rows as the workbench lists. */
.questionCard {
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: 12px;
padding: var(--space-3);
border: 1px solid var(--border-strong);
border-radius: var(--radius-control);
background: var(--bg-elev);
@@ -1639,12 +1757,11 @@
min-height: 0;
max-height: 50vh;
overflow-y: auto;
width: 100%;
width: calc(100% - var(--space-3) * 2);
max-width: var(--session-content-width);
margin: 0 auto 8px;
}
.fitWidth .questionCardPinned {
width: calc(100% - var(--space-3) * 2);
max-width: none;
}
.questionTabCheck {
@@ -1679,43 +1796,43 @@
border: 0;
}
.questionText {
margin-bottom: 6px;
margin-bottom: var(--space-1-5);
padding: 0;
color: var(--fg-strong);
font-weight: 600;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.questionTag {
margin: 0 8px 0 0;
padding: 1px 6px;
margin: 0 var(--space-2) 0 0;
padding: 1px var(--space-1-5);
border-radius: var(--radius-small);
background: var(--bg-hover);
color: var(--fg-muted);
font-size: var(--agent-fs-small, var(--fs-small));
font-weight: 400;
}
.questionLabel .questionTag {
margin: 0 0 0 8px;
margin: 0 0 0 var(--space-2);
}
.question .questionOption {
display: flex;
align-items: flex-start;
padding: 8px 10px;
border-radius: var(--radius-row);
min-height: var(--h-list-row);
padding: var(--space-1-5) var(--space-2);
border-radius: var(--radius-selection);
}
/* Each option is a card of its own: separate targets, not one list with hairlines. */
.question .questionChoices > * {
border: 1px solid var(--border);
border-radius: var(--radius-row);
.question .questionOption:not(:has(input:disabled)):hover {
background: var(--bg-tree-hover);
}
.question .questionChoices > *:hover {
border-color: var(--border-strong);
.question .questionOption:has(input:checked) {
background: var(--bg-tree-selected);
}
.question .questionChoices > *:has(input:checked) {
border-color: var(--accent);
background: var(--bg-hover);
.question .questionOption:has(input:checked):hover {
background: var(--bg-tree-selected);
}
.question .questionOption:hover {
background: var(--bg-hover);
.question .questionOption:has(input:disabled) {
opacity: 0.6;
}
.questionOption > :first-child {
margin-top: 1px;
@@ -1751,8 +1868,11 @@
color: var(--fg-subtle);
font-size: var(--agent-fs-small, var(--fs-small));
}
.questionOption:has(input:checked) :is(.questionDescription, .questionKey) {
color: var(--fg);
}
.questionOther {
margin: 2px 0 0 30px;
margin: var(--space-0-5) 0 0 calc(16px + var(--space-2) * 2);
}
.questionBody {
display: flex;
@@ -1779,7 +1899,7 @@
.questionPreview {
display: grid;
min-width: 0;
margin: 0 0 0 30px;
margin: 0 0 0 calc(16px + var(--space-2) * 2);
}
.questionPreviewItem {
display: flex;
+1
Переглянути файл
@@ -52,6 +52,7 @@ describe("SkillsPicker", () => {
const trigger = screen.getByRole("button", { name: "Skills" });
expect(trigger).toHaveTextContent("Skills3/4");
expect(trigger.querySelector("svg path")).toHaveAttribute("stroke", "currentColor");
fireEvent.click(trigger);
expect(await screen.findByText("Session Skills")).toBeInTheDocument();
+1 -1
Переглянути файл
@@ -78,7 +78,7 @@ export function SkillsPicker({
return (
<SessionPicker
icon="bulb"
icon="skills"
brand="Skills"
triggerTitles={{
plain: tx("Skills ({active}/{total} active)"),
+11
Переглянути файл
@@ -221,6 +221,17 @@ describe("New Task composer commands", () => {
expect(agentSkillsList).toHaveBeenCalledOnce();
});
it("uses a theme-coloured Skills icon in the Add Context menu", async () => {
agentCommands.mockResolvedValue({ status: "ok", data: [] });
render(<HomeEditor />);
fireEvent.click(screen.getByRole("button", { name: "Add Context" }));
const item = await screen.findByRole("menuitem", { name: "Skills…" });
expect(item.querySelector("svg path")).toHaveAttribute("stroke", "currentColor");
expect(item.querySelector("svg")!.innerHTML).not.toMatch(/#[0-9a-f]{6}/i);
fireEvent.click(item);
expect(await screen.findByText("Session Skills")).toBeInTheDocument();
});
it("names the icon-only Start action and disables it while starting", async () => {
agentCommands.mockResolvedValue({ status: "ok", data: [] });
let finish!: (value: unknown) => void;
+28
Переглянути файл
@@ -44,6 +44,7 @@ vi.mock("@tauri-apps/api/webview", () => ({
}));
import { SessionEditor } from "./SessionEditor";
import styles from "./Session.module.css";
import { textOf, typeIn } from "./composerTesting";
import { registerActions } from "@/platform/actions";
import { composerDraft, rollBackTo, rerunFrom, sendMessage, updateComposer, useAgents } from "./store";
@@ -463,6 +464,33 @@ describe("editing a sent agent message", () => {
expect(textOf(screen.getAllByRole("textbox", { name: "Message" })[0]!)).toBe("Original message");
},
);
it("edits in place inside the user message header and preserves the bubble width", async () => {
const { container } = render(
<SessionEditor input={{ kind: "agent-session", key: task.id, data: { task: task.id } }} />,
);
const user = userEvent.setup();
const editButton = await screen.findByRole("button", { name: "Edit" });
const bubble = container.querySelector<HTMLElement>(`.${styles.user}`)!;
vi.spyOn(bubble, "getBoundingClientRect").mockReturnValue(new DOMRect(100, 50, 272, 32));
const focusSpy = vi.spyOn(HTMLTextAreaElement.prototype, "focus");
try {
await user.click(editButton);
const message = container.querySelector(`.${styles.userMessage}`)!;
expect(message).toBeInTheDocument();
expect(message.querySelector(`.${styles.messageHead}`)).toBeInTheDocument();
expect(message.querySelector(`.${styles.role}`)).toHaveTextContent("You");
const card = message.querySelector<HTMLElement>(`.${styles.editCard}`)!;
expect(card).toBeInTheDocument();
expect(card.style.getPropertyValue("--edit-width")).toBe("272px");
const box = screen.getAllByRole("textbox", { name: "Message" })[0] as HTMLTextAreaElement;
expect(focusSpy).toHaveBeenCalledWith({ preventScroll: true });
expect(box.selectionStart).toBe("Original message".length);
expect(box.selectionEnd).toBe("Original message".length);
} finally {
focusSpy.mockRestore();
}
});
});
describe("session composer submission", () => {
+21 -19
Переглянути файл
@@ -286,7 +286,7 @@ export function QuestionForm({
);
const chooseByNumber = (number: number) => {
const answer = answers[position];
if (!answer) return;
if (!answer?.question.options.length) return;
const option = answer.question.options[number - 1];
if (option) choose(answer, option.label, !answer.picked.includes(option.label));
else if (number === answer.question.options.length + 1) chooseOther(answer, answer.other === null);
@@ -362,16 +362,20 @@ export function QuestionForm({
</span>
),
})),
{
key: group,
checked: item.other !== null,
onChange: (checked: boolean) => chooseOther(item, checked),
label: (
<span className={styles.questionLabel}>
<T>Other</T>
</span>
),
},
...(item.question.options.length
? [
{
key: group,
checked: item.other !== null,
onChange: (checked: boolean) => chooseOther(item, checked),
label: (
<span className={styles.questionLabel}>
<T>Other</T>
</span>
),
},
]
: []),
];
return (
<div
@@ -387,7 +391,9 @@ export function QuestionForm({
>
<fieldset className={styles.question} disabled={busy}>
<legend className={styles.questionText}>
{item.question.header && <span className={styles.questionTag}>{item.question.header}</span>}
{!multiple && item.question.header && (
<span className={styles.questionTag}>{item.question.header}</span>
)}
{item.question.question}
</legend>
<div className={clsx(styles.questionBody, hasPreviews && styles.questionBodyWithPreview)}>
@@ -427,7 +433,7 @@ export function QuestionForm({
{item.other !== null && (
<Input
autoFocus={entry.type === "permission" || item.question.options.length > 0}
className={styles.questionOther}
className={clsx(item.question.options.length > 0 && styles.questionOther)}
value={item.other}
placeholder="Type your answer"
onChange={(event) => update(item, { ...item, other: event.target.value })}
@@ -482,17 +488,13 @@ export function QuestionForm({
</Button>
{multiple && (
<div className={styles.questionPager}>
<Button size="small" disabled={busy || position === 0} onClick={() => goTo(position - 1, true)}>
<Button disabled={busy || position === 0} onClick={() => goTo(position - 1, true)}>
Previous
</Button>
<span className={styles.questionPage}>
{position + 1} / {answers.length}
</span>
<Button
size="small"
disabled={busy || position === answers.length - 1}
onClick={() => goTo(position + 1, true)}
>
<Button disabled={busy || position === answers.length - 1} onClick={() => goTo(position + 1, true)}>
Next
</Button>
</div>
+4 -4
Переглянути файл
@@ -95,7 +95,7 @@ function InterruptedBanner({ task }: { task: AgentTask }) {
<Button
size="small"
variant="primary"
icon="resume"
icon="agent-resume"
disabled={resuming}
onClick={() => {
setResuming(true);
@@ -142,7 +142,7 @@ function WaitingForNetworkBanner({ task }: { task: AgentTask }) {
<Button
size="small"
variant="primary"
icon="resume"
icon="agent-resume"
onClick={() =>
void resumeTask(task.id).catch((e: unknown) =>
notifications().notify({
@@ -387,7 +387,7 @@ export function SessionComposer({
return (
<div className={styles.composerArea}>
{task.status === "archived" && (
<div className={styles.banner}>
<div className={clsx(styles.banner, styles.bannerNeutral)}>
<span className={styles.bannerText}>
<T>This task is archived. Unarchive it to continue the conversation.</T>
</span>
@@ -433,7 +433,7 @@ export function SessionComposer({
disabled={task.status === "archived"}
addMenu={[
{ id: "mcp", label: "MCP Servers…", icon: "plugin", disabled: task.status === "archived", run: openMcp },
{ id: "skills", label: "Skills…", icon: "bulb", disabled: task.status === "archived", run: openSkills },
{ id: "skills", label: "Skills…", icon: "skills", disabled: task.status === "archived", run: openSkills },
{ id: "memory", label: "Memory…", icon: "history", disabled: task.status === "archived", run: openMemory },
]}
toolbar={
+164 -116
Переглянути файл
@@ -2,11 +2,12 @@ import type { AgentEntry, AgentImage, AgentTask } from "@/bindings";
import { useTx } from "@/platform/i18n";
import { isImeKey } from "@/platform/ime";
import { call, commands, isTauri } from "@/platform/ipc";
import { isMacHost } from "@/platform/keymap";
import { basename } from "@/platform/project";
import { Button, copyText, fileIconName, Icon, IconButton, T } from "@/ui";
import { notifications } from "@/workbench/contributions";
import clsx from "clsx";
import { memo, useLayoutEffect, useRef, useState, type RefObject } from "react";
import { memo, useLayoutEffect, useRef, useState, type CSSProperties, type RefObject } from "react";
import { AgentReply, MessageActions, ReplyActions } from "../AgentReply";
import { CliSignInDialog } from "@/workbench/CliSignInDialog";
import { ImageStrip } from "../ImageStrip";
@@ -287,12 +288,14 @@ function UserMessage({
}) {
const tx = useTx();
const [editing, setEditing] = useState(false);
const [editWidth, setEditWidth] = useState<number | null>(null);
const bubbleRef = useRef<HTMLDivElement>(null);
if (entry.recovery) {
return (
<div className={styles.recoveryDivider} role="separator">
<span className={styles.recoveryRule} aria-hidden="true" />
<span className={styles.recoveryPill}>
<Icon name="resume" size={12} />
<Icon name="agent-resume" size={12} />
<span>{tx(recoveryDividerLabel(entry.recovery))}</span>
<MessageTime sentMs={entry.sentMs ?? null} doneMs={null} />
</span>
@@ -310,20 +313,12 @@ function UserMessage({
// A copy up to an earlier turn drops the later ones from the copied session.
const canFork = idle && fork && (rollback || turn === turnCount - 1);
const text = userMessageText(entry.text);
if (editing && turn !== null) {
return (
<MessageEditor
initial={text}
initialImages={entry.images ?? []}
later={turn < turnCount - 1}
onCancel={() => setEditing(false)}
onSend={async (text, images) => {
if (await rerunFrom(task.id, turn, text, images)) setEditing(false);
}}
/>
);
}
const images = entry.images ?? [];
const startEditing = () => {
const width = bubbleRef.current?.getBoundingClientRect().width ?? 0;
setEditWidth(width > 0 ? width : null);
setEditing(true);
};
// Images are listed after the files in `attachments` and shown as thumbnails instead.
// Files mentioned in the text are chips there already.
const mentioned = new Set(
@@ -337,67 +332,80 @@ function UserMessage({
<div className={clsx(styles.message, styles.userMessage)}>
{/* Actions and the time sit beside the author on hover: the reply under it has the turn's duration. */}
<div className={styles.messageHead}>
<MessageActions>
<IconButton size="small" icon="copy" title="Copy" onClick={() => void copyText(text)} />
{inPlace && entry.text && (
<IconButton size="small" icon="edit" title="Edit" onClick={() => setEditing(true)} />
)}
{inPlace && (
<IconButton
size="small"
icon="diff-revert"
iconSize={14}
title="Roll Back to Here"
action="agents.rollBackToMessage"
actionArg={{ task: task.id, turn }}
/>
)}
{!archived && entry.text && entry.attachments.length === 0 && (
<IconButton
size="small"
icon="refresh"
title={inPlace ? "Run Again From Here" : "Send Again"}
onClick={() =>
void (
inPlace
? rerunFrom(task.id, turn, entry.text, images, {
title: "Run Again From Here",
later: turn < turnCount - 1,
})
: resendMessage(task.id, entry.text)
).catch(fail)
}
/>
)}
{canFork && (
<IconButton
size="small"
icon="branch"
title="Fork"
onClick={() => void forkTask(task.id, turn + 1).catch(failed("Couldn't fork the task"))}
/>
)}
</MessageActions>
{!(editing && turn !== null) && (
<MessageActions>
<IconButton size="small" icon="copy" title="Copy" onClick={() => void copyText(text)} />
{inPlace && entry.text && <IconButton size="small" icon="edit" title="Edit" onClick={startEditing} />}
{inPlace && (
<IconButton
size="small"
icon="diff-revert"
iconSize={14}
title="Roll Back to Here"
action="agents.rollBackToMessage"
actionArg={{ task: task.id, turn }}
/>
)}
{!archived && entry.text && entry.attachments.length === 0 && (
<IconButton
size="small"
icon="refresh"
title={inPlace ? "Run Again From Here" : "Send Again"}
onClick={() =>
void (
inPlace
? rerunFrom(task.id, turn, entry.text, images, {
title: "Run Again From Here",
later: turn < turnCount - 1,
})
: resendMessage(task.id, entry.text)
).catch(fail)
}
/>
)}
{canFork && (
<IconButton
size="small"
icon="branch"
title="Fork"
onClick={() => void forkTask(task.id, turn + 1).catch(failed("Couldn't fork the task"))}
/>
)}
</MessageActions>
)}
<MessageTime sentMs={entry.sentMs ?? null} doneMs={null} />
<span className={styles.role}>
<T>You</T>
</span>
</div>
<div className={styles.user}>
<ReferencedText text={text} cwd={task.cwd} />
<ImageStrip images={images} />
{files.length > 0 && (
<div className={styles.attachments}>
{files.map((a, i) => (
// oxlint-disable-next-line react/no-array-index-key -- attachments from different directories can share a basename
<span key={i} className={styles.attachment}>
<Icon name={fileIconName(a)} size={12} />
{a}
</span>
))}
</div>
)}
</div>
{editing && turn !== null ? (
<MessageEditor
initial={text}
initialImages={images}
initialWidth={editWidth}
later={turn < turnCount - 1}
onCancel={() => setEditing(false)}
onSend={async (nextText, nextImages) => {
if (await rerunFrom(task.id, turn, nextText, nextImages)) setEditing(false);
}}
/>
) : (
<div ref={bubbleRef} className={styles.user}>
<ReferencedText text={text} cwd={task.cwd} />
<ImageStrip images={images} />
{files.length > 0 && (
<div className={styles.attachments}>
{files.map((a, i) => (
// oxlint-disable-next-line react/no-array-index-key -- attachments from different directories can share a basename
<span key={i} className={styles.attachment}>
<Icon name={fileIconName(a)} size={12} />
{a}
</span>
))}
</div>
)}
</div>
)}
</div>
);
}
@@ -406,12 +414,15 @@ function UserMessage({
function MessageEditor({
initial,
initialImages,
initialWidth,
later,
onCancel,
onSend,
}: {
initial: string;
initialImages: AgentImage[];
/** Measured width of the bubble being replaced, so editing starts in place without jumping. */
initialWidth: number | null;
/** Turns follow it (they are dropped on send). */
later: boolean;
onCancel: () => void;
@@ -423,6 +434,25 @@ function MessageEditor({
const [sending, setSending] = useState(false);
const [error, setError] = useState<string | null>(null);
const pending = useRef(false);
const cardRef = useRef<HTMLDivElement>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
useLayoutEffect(() => {
const box = textareaRef.current;
if (!box) return;
// Avoid native autoFocus scroll jumps; only nudge if the expanded footer sits past the bottom edge.
box.focus({ preventScroll: true });
box.setSelectionRange(box.value.length, box.value.length);
const card = cardRef.current;
const scroller = card?.closest(`.${styles.stream}`);
if (card && scroller instanceof HTMLElement) {
const view = scroller.getBoundingClientRect();
const rect = card.getBoundingClientRect();
if (rect.bottom > view.bottom) {
const nudge = Math.min(rect.bottom - view.bottom + 8, Math.max(0, rect.top - view.top));
if (nudge > 0) scroller.scrollTop += nudge;
}
}
}, []);
const send = async () => {
if ((!text.trim() && images.length === 0) || pending.current) return;
pending.current = true;
@@ -442,59 +472,77 @@ function MessageEditor({
setSending(false);
}
};
const cardStyle = initialWidth ? ({ "--edit-width": `${initialWidth}px` } as CSSProperties) : undefined;
return (
<div className={styles.message}>
<textarea
className={styles.editMessage}
value={text}
rows={Math.min(Math.max(text.split("\n").length, 2), 12)}
autoFocus
readOnly={sending}
aria-label={tx("Message")}
onChange={(e) => setText(e.target.value)}
onFocus={(e) => e.currentTarget.setSelectionRange(text.length, text.length)}
onKeyDown={(e) => {
if (isImeKey(e.nativeEvent)) return;
if (e.key === "Escape") {
e.preventDefault();
e.stopPropagation();
if (!pending.current) onCancel();
} else if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
void send();
}
}}
/>
<ImageStrip images={images} onRemove={sending ? undefined : (i) => setImages(images.filter((_, j) => j !== i))} />
<>
<div ref={cardRef} className={styles.editCard} style={cardStyle}>
<div className={styles.editField}>
<div className={styles.editMirror} aria-hidden="true">
{text.endsWith("\n") ? `${text}\u200b` : text || "\u200b"}
</div>
<textarea
ref={textareaRef}
className={styles.editMessage}
value={text}
rows={1}
readOnly={sending}
aria-label={tx("Message")}
onChange={(e) => setText(e.target.value)}
onKeyDown={(e) => {
if (isImeKey(e.nativeEvent)) return;
if (e.key === "Escape") {
e.preventDefault();
e.stopPropagation();
if (!pending.current) onCancel();
} else if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
void send();
}
}}
/>
</div>
{images.length > 0 && (
<div className={styles.editImages}>
<ImageStrip
images={images}
onRemove={sending ? undefined : (i) => setImages(images.filter((_, j) => j !== i))}
/>
</div>
)}
<div className={styles.editFooter}>
<span className={styles.editHint} aria-hidden="true">
<kbd>{isMacHost() ? "⌘" : "Ctrl"}</kbd>
<kbd>↵</kbd>
</span>
<span className={styles.editButtons}>
<IconButton icon="close" title="Cancel" disabled={sending} onClick={onCancel} />
<SubmitButton
label="Send"
pending={sending}
disabled={(!text.trim() && images.length === 0) || sending}
onClick={() => void send()}
/>
</span>
</div>
</div>
{error && (
<div className={styles.error} role="alert">
<div className={clsx(styles.error, styles.editError)} role="alert">
<Icon name="error" size={14} />
<span>
<T>Couldn't send the message</T>: {error}
</span>
</div>
)}
<div className={styles.editBar}>
<span className={styles.muted}>
{later ? (
<T>
The messages after this one are replaced, and the files the agent changed since go back to how they were
before this message was sent.
</T>
) : (
<T>The files the agent changed since go back to how they were before this message was sent.</T>
)}
</span>
<span className={styles.editButtons}>
<IconButton icon="close" title="Cancel" disabled={sending} onClick={onCancel} />
<SubmitButton
label="Send"
pending={sending}
disabled={(!text.trim() && images.length === 0) || sending}
onClick={() => void send()}
/>
</span>
<div className={styles.editNote}>
{later ? (
<T>
The messages after this one are replaced, and the files the agent changed since go back to how they were
before this message was sent.
</T>
) : (
<T>The files the agent changed since go back to how they were before this message was sent.</T>
)}
</div>
</div>
</>
);
}
+16
Переглянути файл
@@ -1348,6 +1348,7 @@ describe("an asynchronous Codex question", () => {
it("accepts a typed answer without suggested choices", async () => {
const answerKey = freeQuestion();
const card = await screen.findByRole("form", { name: "What deadline?" });
expect(within(card).queryByRole("radio")).toBeNull();
const submit = within(card).getByRole("button", { name: "Submit" });
expect(submit).toBeDisabled();
fireEvent.change(within(card).getByPlaceholderText("Type your answer"), { target: { value: "Tomorrow" } });
@@ -1373,6 +1374,21 @@ describe("an asynchronous Codex question", () => {
expect(await screen.findByRole("form", { name: "Blocking question" })).not.toHaveClass(styles.questionCardPinned!);
});
it("uses the same pinned container for ACP forms as asynchronous questions", async () => {
const entry: AgentEntry = {
type: "permission",
id: 101,
title: "Project details",
options: [],
chosen: null,
form: { fields: [{ name: "project", title: "Project name", kind: "text", required: true }] },
};
backend.entries.set("A", [entry]);
useAgents.setState({ entries: new Map(backend.entries) });
render(<SessionEditor input={input("A")} />);
expect(await screen.findByRole("form", { name: "Project details" })).toHaveClass(styles.questionCardPinned!);
});
it("skips without submitting an answer", async () => {
freeQuestion();
const card = await screen.findByRole("form", { name: "What deadline?" });
+2 -2
Переглянути файл
@@ -353,7 +353,7 @@ export const taskActions: Action[] = [
id: "agents.resumeAllInterrupted",
title: "Resume All Interrupted Tasks",
category: "Agents",
icon: "resume",
icon: "agent-resume",
when: "projectOpen",
keywords: ["resume", "continue", "interrupted", "recover"],
run: async () => {
@@ -497,7 +497,7 @@ export function taskMenu(tasks: AgentTask[], below: AgentTask[] = []): MenuItem[
kind: "action",
action: "agents.resumeTasks",
label: multiple ? tx`Resume (${interrupted.length})` : "Resume",
icon: "resume",
icon: "agent-resume",
arg: interrupted.map((t) => t.id),
},
{
+26
Переглянути файл
@@ -122,6 +122,32 @@ describe("Icon", () => {
}
});
it("keeps the Skills action monochrome without changing the editor intention bulb", () => {
const { container } = render(
<>
<Icon name="skills" />
<Icon name="bulb" />
</>,
);
const [skills, intention] = container.querySelectorAll("svg");
expect(skills!.innerHTML).toContain('stroke="currentColor"');
expect(skills!.innerHTML).not.toMatch(/#[0-9a-f]{6}/i);
expect(intention!.innerHTML).toContain("#FFAF0F");
});
it("uses a theme-coloured agent resume action without changing the debugger resume icon", () => {
const { container } = render(
<>
<Icon name="agent-resume" />
<Icon name="resume" />
</>,
);
const [agent, debuggerIcon] = container.querySelectorAll("svg");
expect(agent!.innerHTML).toContain('stroke="currentColor"');
expect(agent!.innerHTML).not.toMatch(/#[0-9a-f]{6}/i);
expect(debuggerIcon!.innerHTML).toContain("#208A3C");
});
it("uses the 20px variant for large tool window icons", () => {
const { container } = render(<Icon name="toolwindow-project" size={20} />);
expect(container.querySelector("svg")!.getAttribute("viewBox")).toBe("0 0 20 20");
+2
Переглянути файл
@@ -409,6 +409,7 @@ const ICONS = {
keyboard: "general/keyboard",
bulb: "codeInsight/intentionBulb",
"bulb-fix": "codeInsight/quickfixBulb",
skills: "openidea/agents/skills",
package: "nodes/package",
plugin: "nodes/plugin",
"soft-wrap": "general/softWrap",
@@ -524,6 +525,7 @@ const ICONS = {
"restart-debug-filled": "run/restartDebug_stroke",
"stop-filled": "run/stop_stroke",
resume: "run/resume",
"agent-resume": "openidea/agents/resume",
pause: "run/pause",
"thread-running": "openidea/debugger/threadRunning",
"thread-suspended": "openidea/debugger/threadSuspended",
+5
Переглянути файл
@@ -0,0 +1,5 @@
<!-- OpenIDEA: resume an agent task, using the ordinary action icon palette. -->
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="2.5" y="3" width="3" height="10" rx="0.5" stroke="#6C707E"/>
<path d="M8.5 3.5L14 8L8.5 12.5V3.5Z" stroke="#6C707E" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

Після

Ширина:  |  Висота:  |  Розмір: 358 B

+4
Переглянути файл
@@ -0,0 +1,4 @@
<!-- OpenIDEA: Skills (an ordinary action, not the editor's intention indicator) -->
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.5 11V10.5C5.5 9.2 3.5 8.5 3.5 6A4.5 4.5 0 0 1 12.5 6C12.5 8.5 10.5 9.2 10.5 10.5V11H5.5ZM5.5 13H10.5M6.5 15H9.5" stroke="#6C707E" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

Після

Ширина:  |  Висота:  |  Розмір: 379 B