From aa9c9d83bd00a0236b4618b3f56d4b23c35126c5 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:14:16 +0800 Subject: [PATCH] feat(agents): reorder the task menu and polish selection and images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Task menu: Pin, Rename, Mark as Unread/Read; Fork, Group; Archive (⇧⌘E in the task list), Archive All Below, Delete. Terminal and Open in New Window leave the menu. Hovering a task row shows Pin and Archive beside its age. - Reply text: no stripe under the unselected start of a line when a selection runs on past it; inline code keeps its side insets inside the selection. A double or triple click no longer selects into the next message. - Images: tool-read images show as same-height thumbnails; the remove button on attached images stays opaque on hover. --- src/features/agents/Agents.module.css | 37 +++++ src/features/agents/AgentsView.test.tsx | 45 ++++-- src/features/agents/AgentsView.tsx | 52 +++++- src/features/agents/Composer.module.css | 6 + src/features/agents/Session.module.css | 32 ++-- src/features/agents/session/Stream.tsx | 14 ++ .../agents/session/clampSelection.test.ts | 46 ++++++ src/features/agents/session/clampSelection.ts | 39 +++++ src/features/agents/store.ts | 5 + src/features/agents/taskActions.ts | 152 ++++++++++++------ src/features/agents/taskListFocus.ts | 11 ++ src/platform/keymaps/eclipse-windows.ts | 1 + src/platform/keymaps/intellij-macos.ts | 2 + src/platform/keymaps/intellij-windows.ts | 2 + src/platform/keymaps/vscode-macos.ts | 2 + src/platform/locales/text/en.json | 7 +- src/platform/locales/text/zh.json | 7 +- src/ui/icons.tsx | 1 + src/ui/openidea/general/archive.svg | 4 + 19 files changed, 386 insertions(+), 79 deletions(-) create mode 100644 src/features/agents/session/clampSelection.test.ts create mode 100644 src/features/agents/session/clampSelection.ts create mode 100644 src/features/agents/taskListFocus.ts create mode 100644 src/ui/openidea/general/archive.svg diff --git a/src/features/agents/Agents.module.css b/src/features/agents/Agents.module.css index d3575fb56f..86d93983c6 100644 --- a/src/features/agents/Agents.module.css +++ b/src/features/agents/Agents.module.css @@ -91,6 +91,43 @@ font-size: var(--fs-small); font-variant-numeric: tabular-nums; } +/* Pin and Archive appear beside the age while the pointer is on the row. */ +.rowActions { + display: none; + flex: none; + margin-left: auto; + margin-right: var(--space-2); + gap: var(--space-2); +} +.row:hover .rowActions, +.rowActions:focus-within { + display: flex; +} +.row:hover .age, +.row:has(.rowActions:focus-within) .age { + margin-left: 0; +} +.rowAction { + display: flex; + align-items: center; + justify-content: center; + width: 16px; + height: 16px; + padding: 0; + border: none; + background: none; + color: var(--fg-subtle); + --icon-color: currentColor; + cursor: pointer; +} +.rowAction:hover { + color: var(--fg-strong); +} +.rowAction:focus-visible { + outline: 2px solid var(--focus-ring); + outline-offset: 1px; + border-radius: var(--radius-small); +} .ready { color: var(--success); } diff --git a/src/features/agents/AgentsView.test.tsx b/src/features/agents/AgentsView.test.tsx index 36241ffa1f..57a3b79fcb 100644 --- a/src/features/agents/AgentsView.test.tsx +++ b/src/features/agents/AgentsView.test.tsx @@ -338,7 +338,7 @@ describe("Agents bulk actions", () => { select("one"); select("three", { shiftKey: true }); context("two"); - fireEvent.click(screen.getByRole("menuitem", { name: "Archive (1)" })); + fireEvent.click(screen.getByRole("menuitem", { name: /^Archive \(1\)/ })); await waitFor(() => expect(archiveTask).toHaveBeenCalledExactlyOnceWith("two")); }); @@ -388,24 +388,39 @@ describe("Agents task menu", () => { expect(menu).not.toContainEqual(expect.objectContaining({ action: "agents.undockTask" })); // A click opens the task: the menu doesn't repeat it. expect(menu).not.toContainEqual(expect.objectContaining({ action: "agents.openTask" })); - expect(menu[0]).toMatchObject({ action: "agents.renameTask" }); + expect(menu).toContainEqual(expect.objectContaining({ action: "agents.renameTask" })); }); - it("offers Terminal for worktree or off-root tasks and hides it for local-checkout tasks at the project root", () => { - const localMenu = taskMenu([{ ...task("one", "ready", "local"), projectRoot: "/project", cwd: "/project" }]); - expect(localMenu).not.toContainEqual(expect.objectContaining({ action: "terminal.openAt" })); - - const worktree = { ...task("two", "ready", "worktree"), cwd: "/worktrees/two" }; - const worktreeMenu = taskMenu([worktree]); - expect(worktreeMenu).toContainEqual( - expect.objectContaining({ action: "terminal.openAt", label: "Terminal", arg: "/worktrees/two" }), + it("orders the single-task menu: pin, rename, unread; fork, group; archive, archive below, delete", () => { + const one = useAgents.getState().tasks.get("one")!; + const two = useAgents.getState().tasks.get("two")!; + const menu = taskMenu([{ ...one, capabilities: { fork: true } }], [two]); + const names = menu.map((item) => + item.kind === "separator" ? "-" : "action" in item ? item.action : (item as { id?: string }).id, ); + expect(names).toEqual([ + "agents.pinTasks", + "agents.renameTask", + "agents.markTasksUnread", + "-", + "agents.forkTask", + "move-to-group", + "-", + "agents.archiveTasks", + "archive-below", + "agents.deleteTasks", + ]); + expect(menu).not.toContainEqual(expect.objectContaining({ action: "terminal.openAt" })); + expect(menu).not.toContainEqual(expect.objectContaining({ action: "agents.moveToNewWindow" })); + }); - const subfolder = { ...task("three", "ready", "local"), projectRoot: "/project", cwd: "/project/packages/api" }; - const subfolderMenu = taskMenu([subfolder]); - expect(subfolderMenu).toContainEqual( - expect.objectContaining({ action: "terminal.openAt", label: "Terminal", arg: "/project/packages/api" }), - ); + it("marks tasks unread, then offers to mark them read", async () => { + await taskActions.find((action) => action.id === "agents.markTasksUnread")!.run({ ctx: {}, arg: ["one"] }); + expect(useAgents.getState().unread.has("one")).toBe(true); + const menu = taskMenu([useAgents.getState().tasks.get("one")!]); + expect(menu).toContainEqual(expect.objectContaining({ action: "agents.markTasksRead", label: "Mark as Read" })); + await taskActions.find((action) => action.id === "agents.markTasksRead")!.run({ ctx: {}, arg: ["one"] }); + expect(useAgents.getState().unread.has("one")).toBe(false); }); }); diff --git a/src/features/agents/AgentsView.tsx b/src/features/agents/AgentsView.tsx index a9838519dd..0281ac936f 100644 --- a/src/features/agents/AgentsView.tsx +++ b/src/features/agents/AgentsView.tsx @@ -41,7 +41,8 @@ import { showImportSessions, useAgents, } from "./store"; -import { groupMenu, taskMenu } from "./taskActions"; +import { canArchive, groupMenu, taskMenu } from "./taskActions"; +import { setFocusedTaskList } from "./taskListFocus"; import { matchTask } from "./taskSearch"; import { SessionEditor } from "./SessionEditor"; import { HomeEditor } from "./HomeEditor"; @@ -186,7 +187,13 @@ export function AgentsView() { const task = sessionTask(maybeEditorService()?.activeInput?.()); return new Set(task ? [task] : []); }); + const selectedRef = useRef(selected); + useEffect(() => { + selectedRef.current = selected; + }, [selected]); + useEffect(() => () => setFocusedTaskList(null), []); const organize = useAgents((s) => s.organize); + const pinned = useMemo(() => new Set(organize.pinned), [organize.pinned]); const [query, setQuery] = useState(""); const treeRef = useRef(null); // Follow the active session tab. @@ -263,8 +270,40 @@ export function AgentsView() { const dragTask = (e: ReactPointerEvent, task: string) => startPointerDrag(e, e.currentTarget, { type: TASK_DRAG, payload: task }); + // The tasks under `task` in its section, for Archive All Below. + const tasksBelow = (task: string): AgentTask[] => { + for (const root of roots) { + const members = root.kind === "group" ? root.group.tasks : root.kind === "task" ? [] : root.tasks; + const at = members.findIndex((t) => t.id === task); + if (at >= 0) return members.slice(at + 1); + } + return []; + }; + const rowButton = (label: string, icon: "pin" | "archive", run: () => void) => ( + + ); + const taskList = ( -
+
setFocusedTaskList(() => [...selectedRef.current])} + onBlur={(e) => { + if (!(e.relatedTarget instanceof Element && e.currentTarget.contains(e.relatedTarget))) + setFocusedTaskList(null); + }} + > {tasks.size > 0 && ( { switch (n.kind) { @@ -393,6 +432,13 @@ export function AgentsView() { {n.task.isolation === "worktree" && ( {branchLabel(n.task.branch)} )} + + {pinned.has(n.task.id) + ? rowButton("Unpin", "pin", () => pinTasks([n.task.id], false)) + : rowButton("Pin", "pin", () => pinTasks([n.task.id], true))} + {canArchive(n.task) && + rowButton("Archive", "archive", () => void executeAction("agents.archiveTasks", [n.task.id]))} + {age(n.task.updatedMs ?? 0)} ); diff --git a/src/features/agents/Composer.module.css b/src/features/agents/Composer.module.css index 8fcb375916..234774c3a6 100644 --- a/src/features/agents/Composer.module.css +++ b/src/features/agents/Composer.module.css @@ -470,6 +470,7 @@ border: 0; border-radius: 50%; background: var(--bg-popup); + box-shadow: 0 0 0 1px var(--border); color: var(--fg); cursor: pointer; opacity: 0; @@ -478,6 +479,11 @@ .removeImage:focus-visible { opacity: 1; } +/* Opaque on hover too: the icon button's own hover fill is translucent over the image. */ +.image .removeImage:not(:disabled):hover { + background: color-mix(in srgb, var(--fg-strong) 8%, var(--bg-popup)); + color: var(--fg-strong); +} /* Attached files and the current-file suggestion: one height, like the chips in the text. */ .attachment, diff --git a/src/features/agents/Session.module.css b/src/features/agents/Session.module.css index e75068dfde..972e55cb50 100644 --- a/src/features/agents/Session.module.css +++ b/src/features/agents/Session.module.css @@ -515,12 +515,21 @@ it doesn't leave light boxes the way an opaque near-white fill does. */ --md-code-bg: color-mix(in srgb, var(--fg) 7%, transparent); } +/* Each text block paints its own selection: WebKit otherwise fills the gap under a block's + last selected line across the whole block, a stripe below the unselected start of the line. + Not inside SVG (Mermaid labels): WebKit draws transformed foreignObject content at the origin. */ +.markdown :global(:is(p, li, h1, h2, h3, h4, h5, h6):not(foreignObject *)) { + transform: translateX(0); +} .markdown :global(code) { font-family: var(--font-mono); font-size: var(--agent-fs-small, var(--fs-small)); - padding: 0 2px; border-radius: 3px; background: var(--md-code-bg); + /* Side insets as shadows, not padding: a selection leaves inline padding unpainted. */ + box-shadow: + -2px 0 0 var(--md-code-bg), + 2px 0 0 var(--md-code-bg); } .markdown :global(pre) { margin: 0 0 8px; @@ -531,8 +540,8 @@ } .markdown :global(pre code) { display: block; - padding: 0; background: none; + box-shadow: none; } .codeBlock { position: relative; @@ -1203,14 +1212,13 @@ border: 1px solid var(--border); border-radius: var(--radius-small); } -.toolImages, -.toolImages .imageItem, -.toolImages .imageButton { - max-width: 100%; -} +/* Images a tool read (screenshots, crops): one row height whatever their size; a click shows the whole image. */ .toolImages .image { - max-width: min(100%, 640px); - max-height: 320px; + width: auto; + height: 96px; + max-width: 200px; + object-fit: cover; + object-position: top left; } .removeImage { position: absolute; @@ -1224,9 +1232,15 @@ border: 0; border-radius: 50%; background: var(--bg-popup); + box-shadow: 0 0 0 1px var(--border); color: var(--fg); cursor: pointer; } +/* Opaque on hover too: the icon button's own hover fill is translucent over the image. */ +.imageItem .removeImage:not(:disabled):hover { + background: color-mix(in srgb, var(--fg-strong) 8%, var(--bg-popup)); + color: var(--fg-strong); +} .attachments { display: flex; diff --git a/src/features/agents/session/Stream.tsx b/src/features/agents/session/Stream.tsx index 2b35e81ac9..8e8486a02e 100644 --- a/src/features/agents/session/Stream.tsx +++ b/src/features/agents/session/Stream.tsx @@ -27,6 +27,7 @@ import { type RefObject, } from "react"; import { useAgentSettings } from "../agentSettings"; +import { clampSelectionToRow } from "./clampSelection"; import { ImageStrip } from "../ImageStrip"; import { entriesKey, @@ -204,6 +205,12 @@ function scrollsUpInside(target: EventTarget | null, root: HTMLElement): boolean /** A wheel gesture's events arrive closer together than this; a pause starts a new one. */ const WHEEL_GESTURE_MS = 150; +/** Keeps a double- or triple-click selection within the message it was made in. */ +function clampMultiClick(target: EventTarget) { + const row = target instanceof Element ? target.closest(`.${styles.conversationRow}`) : null; + if (row) clampSelectionToRow(document.getSelection(), row); +} + export function Stream({ loadError, task, @@ -623,6 +630,13 @@ export function Stream({ markUserScroll(); scrollingUp.current = false; }} + onMouseDown={(e) => { + // WebKit makes a double- or triple-click selection after this handler. + if (e.detail >= 2) setTimeout(() => clampMultiClick(e.target)); + }} + onMouseUp={(e) => { + if (e.detail >= 2) clampMultiClick(e.target); + }} onScroll={(e) => { const el = e.currentTarget; trimSlack(); diff --git a/src/features/agents/session/clampSelection.test.ts b/src/features/agents/session/clampSelection.test.ts new file mode 100644 index 0000000000..c4c40a7529 --- /dev/null +++ b/src/features/agents/session/clampSelection.test.ts @@ -0,0 +1,46 @@ +import { afterEach, describe, expect, it } from "vitest"; +import { clampSelectionToRow } from "./clampSelection"; + +function conversation() { + document.body.innerHTML = ` +

First paragraph.

Last paragraph.

+
Nov 11 05:58 PM
+
Next message
`; + const text = (id: string) => document.getElementById(id)!.firstChild as Text; + return { + reply: document.getElementById("reply")!, + last: text("last"), + next: document.querySelector("#user span")!.firstChild as Text, + }; +} + +afterEach(() => { + document.getSelection()?.removeAllRanges(); + document.body.innerHTML = ""; +}); + +describe("clampSelectionToRow", () => { + it("ends a selection that ran into the next message at the row's last selectable text", () => { + const { reply, last, next } = conversation(); + const selection = document.getSelection()!; + selection.setBaseAndExtent(last, 0, next, 4); + clampSelectionToRow(selection, reply); + expect(selection.toString()).toBe("Last paragraph."); + }); + + it("leaves a selection inside the row alone", () => { + const { reply, last } = conversation(); + const selection = document.getSelection()!; + selection.setBaseAndExtent(last, 0, last, 4); + clampSelectionToRow(selection, reply); + expect(selection.toString()).toBe("Last"); + }); + + it("collapses a selection made entirely outside the row", () => { + const { reply, next } = conversation(); + const selection = document.getSelection()!; + selection.setBaseAndExtent(next, 0, next, 4); + clampSelectionToRow(selection, reply); + expect(selection.isCollapsed).toBe(true); + }); +}); diff --git a/src/features/agents/session/clampSelection.ts b/src/features/agents/session/clampSelection.ts new file mode 100644 index 0000000000..40a007f81a --- /dev/null +++ b/src/features/agents/session/clampSelection.ts @@ -0,0 +1,39 @@ +/** + * Keeps a double- or triple-click selection inside the conversation row it was made in. WebKit + * extends a word or paragraph at the end of a message past its unselectable footer, into the next + * message. + */ +export function clampSelectionToRow(selection: Selection | null, row: Element) { + if (!selection?.rangeCount) return; + const range = selection.getRangeAt(0); + const startInside = row.contains(range.startContainer); + const endInside = row.contains(range.endContainer); + if (startInside && endInside) return; + const texts = selectableTexts(row); + const first = texts[0]; + const last = texts.at(-1); + if (!first || !last) return; + if (!startInside && !endInside) { + // The whole selection went past the row: none of the row's text is in it. + selection.collapse(last, last.length); + return; + } + const [startNode, startOffset] = startInside ? [range.startContainer, range.startOffset] : [first, 0]; + const [endNode, endOffset] = endInside ? [range.endContainer, range.endOffset] : [last, last.length]; + const backward = selection.anchorNode === range.endContainer && selection.anchorOffset === range.endOffset; + if (backward) selection.setBaseAndExtent(endNode, endOffset, startNode, startOffset); + else selection.setBaseAndExtent(startNode, startOffset, endNode, endOffset); +} + +function selectableTexts(row: Element): Text[] { + const texts: Text[] = []; + const walker = row.ownerDocument.createTreeWalker(row, NodeFilter.SHOW_TEXT); + for (let node = walker.nextNode(); node; node = walker.nextNode()) { + const parent = node.parentElement; + if (!node.nodeValue?.trim() || !parent) continue; + const style = getComputedStyle(parent); + if (style.userSelect === "none" || style.webkitUserSelect === "none") continue; + texts.push(node as Text); + } + return texts; +} diff --git a/src/features/agents/store.ts b/src/features/agents/store.ts index 39d6ad3e9c..5d8930e487 100644 --- a/src/features/agents/store.ts +++ b/src/features/agents/store.ts @@ -369,6 +369,11 @@ function setUnread(task: string, value: boolean) { useAgents.setState({ unread }); } +/** Marks tasks read or unread from the list's menu. */ +export function setTasksUnread(tasks: readonly string[], value: boolean) { + for (const task of tasks) setUnread(task, value); +} + function markUnread(task: string) { const current = useAgents.getState().tasks.get(task); if (current && current.status !== "archived" && !viewing(task) && !quietTasks.has(task)) setUnread(task, true); diff --git a/src/features/agents/taskActions.ts b/src/features/agents/taskActions.ts index 1bd8bd55de..4f6be0b49f 100644 --- a/src/features/agents/taskActions.ts +++ b/src/features/agents/taskActions.ts @@ -1,12 +1,10 @@ import type { AgentTask } from "@/bindings"; -import type { Action } from "@/platform/actions"; -import { t, tx } from "@/platform/i18n"; -import { auxiliaryWindow } from "@/platform/auxWindow"; -import { useProject } from "@/platform/project"; +import { executeActionFrom, type Action } from "@/platform/actions"; +import { tx } from "@/platform/i18n"; import type { MenuItem } from "@/ui"; import { confirm, showError, confirmChecked } from "@/workbench/messages"; import { promptInput } from "@/workbench/inputDialogs"; -import { hasTaskTerminal, isBusy } from "./model"; +import { isBusy } from "./model"; import { groupNameError, type OrganizeGroup } from "./organize"; import { archiveTask, @@ -25,10 +23,12 @@ import { openTaskInEditorLocation, renameTask, setSessionLocation, + setTasksUnread, showImportSessions, undockTask, useAgents, } from "./store"; +import { focusedTaskListSelection } from "./taskListFocus"; /** The Agents tool window's options menu: where conversations open, a new list group, importing sessions. */ export function useAgentsHeaderMenu(): MenuItem[] { @@ -43,10 +43,11 @@ export function useAgentsHeaderMenu(): MenuItem[] { ]; } -const canArchive = (task: AgentTask) => !isBusy(task.status) && task.status !== "archived"; +export const canArchive = (task: AgentTask) => !isBusy(task.status) && task.status !== "archived"; const canFork = (task: AgentTask) => canArchive(task) && !!task.capabilities?.fork; function resolveTasks(arg: unknown): AgentTask[] { + if (arg == null) arg = focusedTaskListSelection(); if (!Array.isArray(arg)) return []; return [...new Set(arg)].flatMap((id: unknown) => { const task = typeof id === "string" ? useAgents.getState().tasks.get(id) : undefined; @@ -133,10 +134,9 @@ async function confirmRemoveGroup(group: string) { deleteTaskGroup(group); } -/** Pins and unpins of the selected tasks, then where they go. */ -function arrangeMenu(tasks: AgentTask[], ids: string[]): MenuItem[] { - const { groups, groupOf, pinned } = useAgents.getState().organize; - const isPinned = new Set(pinned); +/** Pins and unpins of the selected tasks. */ +function pinMenu(tasks: AgentTask[]): MenuItem[] { + const isPinned = new Set(useAgents.getState().organize.pinned); const toPin = tasks.filter((t) => !isPinned.has(t.id)); const toUnpin = tasks.filter((t) => isPinned.has(t.id)); return [ @@ -162,20 +162,40 @@ function arrangeMenu(tasks: AgentTask[], ids: string[]): MenuItem[] { }, ] satisfies MenuItem[]) : []), + ]; +} + +/** Marks the tasks unread, or read when they all are unread already. */ +function unreadMenu(ids: string[]): MenuItem[] { + const unread = useAgents.getState().unread; + const allUnread = ids.every((id) => unread.has(id)); + return [ { - kind: "item", - id: "move-to-group", - label: "Group", - icon: "folder", - submenu: groupSubmenu( - ids, - groups, - ids.map((id) => groupOf[id]), - ), + kind: "action", + action: allUnread ? "agents.markTasksRead" : "agents.markTasksUnread", + label: allUnread ? "Mark as Read" : "Mark as Unread", + icon: "", + arg: ids, }, ]; } +/** Where the selected tasks go. */ +function groupMenuItem(ids: string[]): MenuItem { + const { groups, groupOf } = useAgents.getState().organize; + return { + kind: "item", + id: "move-to-group", + label: "Group", + icon: "folder", + submenu: groupSubmenu( + ids, + groups, + ids.map((id) => groupOf[id]), + ), + }; +} + /** The groups to move the tasks into; the one they all belong to is checked. */ function groupSubmenu(ids: string[], groups: OrganizeGroup[], current: Array): MenuItem[] { return [ @@ -313,6 +333,8 @@ export const taskActions: Action[] = [ title: "Archive Agent Tasks", category: "Agents", hidden: true, + // Without an argument the shortcut archives the task list's selection. + keyWhen: "agentTaskListFocus", run: ({ arg }) => runTasks(resolveTasks(arg).filter(canArchive), (task) => archiveTask(task.id), tx("Cannot archive agent tasks")), }, @@ -357,6 +379,28 @@ export const taskActions: Action[] = [ false, ), }, + { + id: "agents.markTasksUnread", + title: "Mark Agent Tasks as Unread", + category: "Agents", + hidden: true, + run: ({ arg }) => + setTasksUnread( + resolveTasks(arg).map((task) => task.id), + true, + ), + }, + { + id: "agents.markTasksRead", + title: "Mark Agent Tasks as Read", + category: "Agents", + hidden: true, + run: ({ arg }) => + setTasksUnread( + resolveTasks(arg).map((task) => task.id), + false, + ), + }, { id: "agents.newTaskGroup", title: "New Agent Task Group", @@ -385,49 +429,40 @@ export const taskActions: Action[] = [ }, ]; -export function taskMenu(tasks: AgentTask[]): MenuItem[] { +/** + * The task rows' menu. `below` lists the tasks under a single selected one in its section, + * for Archive All Below. + */ +export function taskMenu(tasks: AgentTask[], below: AgentTask[] = []): MenuItem[] { if (!tasks.length) return []; const ids = tasks.map((task) => task.id); const task = tasks[0]!; - const projectRoot = task.projectRoot ?? useProject.getState().project?.root ?? null; const multiple = tasks.length > 1; const archived = tasks.filter((task) => task.status === "archived").length; const archivable = tasks.filter(canArchive).length; + const archivableBelow = multiple ? [] : below.filter(canArchive); return [ + ...pinMenu(tasks), ...(!multiple ? ([ { kind: "action", action: "agents.renameTask", label: "Rename…", icon: "edit", arg: task.id }, - ...(!auxiliaryWindow() - ? ([ - { - kind: "action", - action: "agents.moveToNewWindow", - label: t("app.window.askNew"), - arg: task.id, - }, - ] satisfies MenuItem[]) - : []), - ...(hasTaskTerminal(task, projectRoot) - ? ([ - { kind: "action", action: "terminal.openAt", label: "Terminal", icon: "terminal", arg: task.cwd }, - ] satisfies MenuItem[]) - : []), - ...(task.capabilities?.fork && task.status !== "archived" - ? ([ - { - kind: "action", - action: "agents.forkTask", - label: "Fork", - icon: "branch", - arg: task.id, - disabled: !canFork(task), - }, - ] satisfies MenuItem[]) - : []), - { kind: "separator" }, ] satisfies MenuItem[]) : []), - ...arrangeMenu(tasks, ids), + ...unreadMenu(ids), + { kind: "separator" }, + ...(!multiple && task.capabilities?.fork && task.status !== "archived" + ? ([ + { + kind: "action", + action: "agents.forkTask", + label: "Fork", + icon: "branch", + arg: task.id, + disabled: !canFork(task), + }, + ] satisfies MenuItem[]) + : []), + groupMenuItem(ids), { kind: "separator" }, ...(archived ? ([ @@ -443,9 +478,26 @@ export function taskMenu(tasks: AgentTask[]): MenuItem[] { kind: "action", action: "agents.archiveTasks", label: multiple ? tx`Archive (${archivable})` : "Archive", + icon: "archive", arg: ids, disabled: !archivable, }, + ...(archivableBelow.length + ? ([ + { + kind: "item", + id: "archive-below", + label: "Archive All Below", + icon: "archive", + run: () => + void executeActionFrom( + "menu", + "agents.archiveTasks", + archivableBelow.map((t) => t.id), + ), + }, + ] satisfies MenuItem[]) + : []), { kind: "action", action: "agents.deleteTasks", diff --git a/src/features/agents/taskListFocus.ts b/src/features/agents/taskListFocus.ts new file mode 100644 index 0000000000..e1e792640f --- /dev/null +++ b/src/features/agents/taskListFocus.ts @@ -0,0 +1,11 @@ +/** The Agents task list holding focus, so its shortcuts act on the selected tasks. */ +import { setContext } from "@/platform/context"; + +let selection: (() => string[]) | null = null; + +export function setFocusedTaskList(get: (() => string[]) | null) { + selection = get; + setContext("agentTaskListFocus", !!get); +} + +export const focusedTaskListSelection = (): string[] => selection?.() ?? []; diff --git a/src/platform/keymaps/eclipse-windows.ts b/src/platform/keymaps/eclipse-windows.ts index 12217acdad..ff88415b24 100644 --- a/src/platform/keymaps/eclipse-windows.ts +++ b/src/platform/keymaps/eclipse-windows.ts @@ -34,6 +34,7 @@ export const eclipseWindows: Record = { "debug.jumpToSource": ["F12", "Shift+Ctrl+E"], "diff.jumpToSource": ["F12", "Shift+Ctrl+E"], "find.popup.openResult": ["F12", "Shift+Ctrl+E"], + "agents.archiveTasks": [], "editor.codeBlockEnd": ["Ctrl+]"], "code.deleteLine": ["Ctrl+D"], "code.duplicateLine": [], diff --git a/src/platform/keymaps/intellij-macos.ts b/src/platform/keymaps/intellij-macos.ts index c02723d8cf..b603225b1f 100644 --- a/src/platform/keymaps/intellij-macos.ts +++ b/src/platform/keymaps/intellij-macos.ts @@ -406,6 +406,8 @@ export const intellijMacos: Record = { "agents.cycleEffort": ["Alt+T"], "agents.showToolWindow": [], "agents.sendToAgent": [], + // Agents task list (when it has focus) + "agents.archiveTasks": ["Meta+Shift+E"], // Database tool window (when the tree has focus; `db.openConsole` anywhere). "db.openConsole": ["Meta+Shift+L"], "db.newDataSource": [], diff --git a/src/platform/keymaps/intellij-windows.ts b/src/platform/keymaps/intellij-windows.ts index 7c7de9d1e6..47bb182d8a 100644 --- a/src/platform/keymaps/intellij-windows.ts +++ b/src/platform/keymaps/intellij-windows.ts @@ -404,6 +404,8 @@ export const intellijWindows: Record = { "agents.cycleEffort": ["Alt+T"], "agents.showToolWindow": [], "agents.sendToAgent": [], + // Agents task list (when it has focus) + "agents.archiveTasks": ["Ctrl+Shift+E"], // Database tool window (when the tree has focus; `db.openConsole` anywhere). "db.openConsole": ["Ctrl+Shift+Q"], "db.newDataSource": [], diff --git a/src/platform/keymaps/vscode-macos.ts b/src/platform/keymaps/vscode-macos.ts index 2bf69bb15d..ce37898621 100644 --- a/src/platform/keymaps/vscode-macos.ts +++ b/src/platform/keymaps/vscode-macos.ts @@ -436,6 +436,8 @@ export const vscodeMacos: Record = { "agents.cycleEffort": ["Alt+T"], "agents.showToolWindow": [], "agents.sendToAgent": [], + // Agents task list (when it has focus) + "agents.archiveTasks": ["Meta+Shift+E"], // Python Console: VS Code's Shift+Enter would shadow typing in Python files, so unbound. "python.console.executeSelection": [], // Search fields (find bar, Find in Files): last, so they win over editor keys while one is focused. diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index c09e092d3a..48a0211026 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -3858,5 +3858,10 @@ "No stub or implementation found": "No stub or implementation found", "Implementation of {name} in {file}": "Implementation of {name} in {file}", "Stub of {name} in {file}": "Stub of {name} in {file}", - "This color can't be changed with the picker": "This color can't be changed with the picker" + "This color can't be changed with the picker": "This color can't be changed with the picker", + "Mark as Read": "Mark as Read", + "Mark as Unread": "Mark as Unread", + "Archive All Below": "Archive All Below", + "Mark Agent Tasks as Unread": "Mark Agent Tasks as Unread", + "Mark Agent Tasks as Read": "Mark Agent Tasks as Read" } diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index d759ebc702..49867e1531 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -10088,5 +10088,10 @@ "No stub or implementation found": "未找到存根或实现", "Implementation of {name} in {file}": "{file} 中 {name} 的实现", "Stub of {name} in {file}": "{file} 中 {name} 的存根", - "This color can't be changed with the picker": "无法用颜色选择器修改此颜色" + "This color can't be changed with the picker": "无法用颜色选择器修改此颜色", + "Mark as Read": "标记为已读", + "Mark as Unread": "标记为未读", + "Archive All Below": "归档下方全部", + "Mark Agent Tasks as Unread": "将 Agent 任务标记为未读", + "Mark Agent Tasks as Read": "将 Agent 任务标记为已读" } diff --git a/src/ui/icons.tsx b/src/ui/icons.tsx index cd9aff574c..95287b7566 100644 --- a/src/ui/icons.tsx +++ b/src/ui/icons.tsx @@ -332,6 +332,7 @@ const ICONS = { "actual-size": "openidea/general/actualZoom", chessboard: "openidea/general/chessboard", eyedropper: "openidea/general/eyedropper", + archive: "openidea/general/archive", minimize: "general/openInToolWindow", "main-menu": "openidea/general/mainMenu", "window-minimize": "openidea/general/windowMinimize", diff --git a/src/ui/openidea/general/archive.svg b/src/ui/openidea/general/archive.svg new file mode 100644 index 0000000000..59cbb4cd98 --- /dev/null +++ b/src/ui/openidea/general/archive.svg @@ -0,0 +1,4 @@ + + + +