Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(chat): add an opt-in radial context menu on the transcript background

Linuxdazhaoa440b77982cd
diff --git a/apps/desktop/electron/main/runtime/provider-catalog.ts b/apps/desktop/electron/main/runtime/provider-catalog.ts
index 51d51dc22..082ad59d8 100644
--- a/apps/desktop/electron/main/runtime/provider-catalog.ts
+++ b/apps/desktop/electron/main/runtime/provider-catalog.ts
@@ -3,6 +3,8 @@ import {
SESSION_THINKING_LEVELS,
defaultCommandShellForPlatform,
isCommandShellId,
+ normalizeRadialMenuPreferences,
+ radialMenuWriteError,
validateNetworkProxy,
validateSpeechSettings,
type CommandShellId,
@@ -166,7 +168,7 @@ export function createProviderCatalogRuntime({
): T & { defaultCommandShell: CommandShellId } => {
const value = (
settings && typeof settings === "object" ? settings : {}
- ) as T & { defaultCommandShell?: unknown };
+ ) as T & { defaultCommandShell?: unknown; radialMenu?: unknown };
return {
...(value as T),
infiniteProviderRetry: (value as T & { infiniteProviderRetry?: unknown })
@@ -180,6 +182,7 @@ export function createProviderCatalogRuntime({
(value as T & { transcriptDisplayMode?: unknown }).transcriptDisplayMode === "fully-folded"
? (value as T & { transcriptDisplayMode?: unknown }).transcriptDisplayMode
: "fully-folded",
+ radialMenu: normalizeRadialMenuPreferences(value.radialMenu),
defaultCommandShell: isCommandShellId(value.defaultCommandShell)
? value.defaultCommandShell
: defaultCommandShellForPlatform(process.platform),
@@ -200,6 +203,7 @@ export function createProviderCatalogRuntime({
networkProxy?: unknown;
macosWindowTranslucency?: unknown;
transcriptDisplayMode?: unknown;
+ radialMenu?: unknown;
};
if (
Object.prototype.hasOwnProperty.call(value, "defaultCommandShell") &&
@@ -251,6 +255,12 @@ export function createProviderCatalogRuntime({
errorCode: ErrorCodes.INVALID_PARAMS,
});
}
+ const radialMenuProblem = radialMenuWriteError(value.radialMenu);
+ if (radialMenuProblem) {
+ throw Object.assign(new Error(radialMenuProblem), {
+ errorCode: ErrorCodes.INVALID_PARAMS,
+ });
+ }
if (
Object.prototype.hasOwnProperty.call(value, "updatePreference") &&
value.updatePreference !== "automatic" &&
diff --git a/apps/desktop/src/components/RadialMenu.tsx b/apps/desktop/src/components/RadialMenu.tsx
new file mode 100644
index 000000000..aa059a0fc
--- /dev/null
+++ b/apps/desktop/src/components/RadialMenu.tsx
@@ -0,0 +1,301 @@
+/**
+ * The radial menu a right-click opens on the empty transcript background.
+ *
+ * Four directions, one action each, keyed by the pointer's direction from the
+ * click point. It is not a replacement for `ContextMenu`: the list stays the
+ * menu for rows, links, and file references, where the item count varies per
+ * target. This surface only renders when the user opts in through
+ * `AppSettings.radialMenu`, and it keeps the same floating-layer contract —
+ * viewport-fixed portal, measured before reveal, clamped inside the window,
+ * Escape and outside-press dismissal, and keyboard reachability.
+ */
+import {
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+ type KeyboardEvent as ReactKeyboardEvent,
+ type ReactNode,
+} from "react";
+import { portalToBody } from "../lib/portal-visibility";
+import { CONTEXT_MENU_MARGIN, type ContextMenuPoint } from "../lib/context-menu";
+
+export type RadialMenuItem = {
+ id: string;
+ label: string;
+ icon: ReactNode;
+ onSelect: () => void;
+};
+/** A slot the current conversation cannot fill keeps its sector and does not run. */
+export type RadialMenuSlot = RadialMenuItem & { disabled?: boolean };
+
+/** Ring geometry, in CSS px. The four item slots sit on the ring's mid-line. */
+const OUTER_RADIUS = 160;
+const INNER_RADIUS = 56;
+const ITEM_RADIUS = 108;
+const ITEM_SIZE = 80;
+
+/** Clockwise from the top; matches `RADIAL_MENU_DIRECTIONS`. */
+const ITEM_ANGLES = [-90, 0, 90, 180] as const;
+const SECTOR_ANGLES = [
+ [-135, -45],
+ [-45, 45],
+ [45, 135],
+ [135, 225],
+] as const;
+
+const rad = (degrees: number) => (degrees * Math.PI) / 180;
+
+function sectorPath(startAngle: number, endAngle: number): string {
+ const center = OUTER_RADIUS;
+ const at = (radius: number, angle: number) => [
+ center + radius * Math.cos(rad(angle)),
+ center + radius * Math.sin(rad(angle)),
+ ];
+ const [innerStartX, innerStartY] = at(INNER_RADIUS, startAngle);
+ const [outerStartX, outerStartY] = at(OUTER_RADIUS, startAngle);
+ const [outerEndX, outerEndY] = at(OUTER_RADIUS, endAngle);
+ const [innerEndX, innerEndY] = at(INNER_RADIUS, endAngle);
+ return [
+ `M ${innerStartX} ${innerStartY}`,
+ `L ${outerStartX} ${outerStartY}`,
+ `A ${OUTER_RADIUS} ${OUTER_RADIUS} 0 0 1 ${outerEndX} ${outerEndY}`,
+ `L ${innerEndX} ${innerEndY}`,
+ `A ${INNER_RADIUS} ${INNER_RADIUS} 0 0 0 ${innerStartX} ${innerStartY}`,
+ "Z",
+ ].join(" ");
+}
+
+/** Which slot the pointer is over, or null in the hub, the margin, or outside. */
+function slotAt(offsetX: number, offsetY: number): number | null {
+ const distance = Math.hypot(offsetX, offsetY);
+ if (distance < INNER_RADIUS || distance > OUTER_RADIUS) return null;
+ const degrees = (Math.atan2(offsetY, offsetX) * 180) / Math.PI;
+ // atan2 measures from the +x axis; shift so "up" starts at -135°.
+ const shifted = (degrees + 135 + 360) % 360;
+ return Math.floor(shifted / 90);
+}
+
+export function RadialMenu({
+ point,
+ items,
+ label,
+ onClose,
+}: {
+ point: ContextMenuPoint;
+ items: readonly RadialMenuSlot[];
+ label: string;
+ onClose: () => void;
+}) {
+ const rootRef = useRef<HTMLDivElement>(null);
+ const itemRefs = useRef<Array<HTMLButtonElement | null>>([]);
+ const [activeIndex, setActiveIndex] = useState<number | null>(null);
+ const [open, setOpen] = useState(false);
+
+ // The right-click interrupted whatever owned focus; closing puts it back so
+ // the ring never strands focus on `<body>`.
+ useEffect(() => {
+ const interrupted =
+ document.activeElement instanceof HTMLElement
+ ? document.activeElement
+ : null;
+ return () => {
+ if (interrupted?.isConnected) interrupted.focus();
+ };
+ }, []);
+
+ // Reveal on the frame after mount so the first paint is already placed; the
+ // CSS transition then runs from a measured surface, never the origin.
+ useEffect(() => {
+ const frame = requestAnimationFrame(() => setOpen(true));
+ return () => cancelAnimationFrame(frame);
+ }, []);
+
+ const select = useCallback(
+ (index: number | null) => {
+ if (index === null) {
+ onClose();
+ return;
+ }
+ const item = items[index];
+ if (!item || item.disabled) return;
+ onClose();
+ item.onSelect();
+ },
+ [items, onClose],
+ );
+
+ useEffect(() => {
+ const root = rootRef.current;
+ const onOutside = (event: Event) => {
+ if (event.target instanceof Node && root?.contains(event.target)) return;
+ onClose();
+ };
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (event.key !== "Escape") return;
+ event.preventDefault();
+ event.stopPropagation();
+ onClose();
+ };
+ window.addEventListener("pointerdown", onOutside, true);
+ window.addEventListener("contextmenu", onOutside, true);
+ window.addEventListener("scroll", onClose, true);
+ window.addEventListener("resize", onClose);
+ window.addEventListener("blur", onClose);
+ window.addEventListener("keydown", onKeyDown, true);
+ return () => {
+ window.removeEventListener("pointerdown", onOutside, true);
+ window.removeEventListener("contextmenu", onOutside, true);
+ window.removeEventListener("scroll", onClose, true);
+ window.removeEventListener("resize", onClose);
+ window.removeEventListener("blur", onClose);
+ window.removeEventListener("keydown", onKeyDown, true);
+ };
+ }, [onClose]);
+
+ // The ring owns the pointer, so the first item takes focus for the keyboard
+ // path and the hover fill follows whichever slot is active.
+ useEffect(() => {
+ itemRefs.current[0]?.focus({ preventScroll: true });
+ }, []);
+
+ useEffect(() => {
+ if (activeIndex === null) return;
+ itemRefs.current[activeIndex]?.focus({ preventScroll: true });
+ }, [activeIndex]);
+
+ const onKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {
+ if (event.key === "Tab") {
+ onClose();
+ return;
+ }
+ const step =
+ event.key === "ArrowRight" || event.key === "ArrowDown"
+ ? 1
+ : event.key === "ArrowLeft" || event.key === "ArrowUp"
+ ? -1
+ : 0;
+ if (!step) return;
+ event.preventDefault();
+ setActiveIndex((current) =>
+ ((current ?? 0) + step + items.length) % items.length,
+ );
+ };
+
+ const width = OUTER_RADIUS * 2;
+ const left = Math.round(
+ Math.max(
+ CONTEXT_MENU_MARGIN,
+ Math.min(
+ point.x - OUTER_RADIUS,
+ window.innerWidth - width - CONTEXT_MENU_MARGIN,
+ ),
+ ),
+ );
+ const top = Math.round(
+ Math.max(
+ CONTEXT_MENU_MARGIN,
+ Math.min(
+ point.y - OUTER_RADIUS,
+ window.innerHeight - width - CONTEXT_MENU_MARGIN,
+ ),
+ ),
+ );
+
+ return portalToBody(
+ <div
+ ref={rootRef}
+ className={`radial-menu${open ? " is-open" : ""}`}
+ style={{ top: `${top}px`, left: `${left}px`, width, height: width }}
+ role="menu"
+ aria-label={label}
+ onKeyDown={onKeyDown}
+ onPointerMove={(event) => {
+ const rect = event.currentTarget.getBoundingClientRect();
+ setActiveIndex(
+ slotAt(
+ event.clientX - rect.left - OUTER_RADIUS,
+ event.clientY - rect.top - OUTER_RADIUS,
+ ),
+ );
+ }}
+ onPointerLeave={() => setActiveIndex(null)}
+ onClick={(event) => {
+ // Resolve from the click, not from the last pointer move: a right-click
+ // followed immediately by a left click never moved the pointer.
+ const rect = event.currentTarget.getBoundingClientRect();
+ select(
+ slotAt(
+ event.clientX - rect.left - OUTER_RADIUS,
+ event.clientY - rect.top - OUTER_RADIUS,
+ ),
+ );
+ }}
+ onContextMenu={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ }}
+ >
+ <svg
+ className="radial-menu-ring"
+ viewBox={`0 0 ${width} ${width}`}
+ aria-hidden="true"
+ >
+ {SECTOR_ANGLES.map(([start, end], index) => (
+ <path
+ key={start}
+ className={`radial-menu-sector${activeIndex === index ? " is-active" : ""}`}
+ d={sectorPath(start, end)}
+ />
+ ))}
+ <circle
+ className="radial-menu-hub"
+ cx={OUTER_RADIUS}
+ cy={OUTER_RADIUS}
+ r={INNER_RADIUS}
+ />
+ <circle
+ className="radial-menu-dot"
+ cx={OUTER_RADIUS}
+ cy={OUTER_RADIUS}
+ r={4}
+ />
+ </svg>
+ {items.map((item, index) => {
+ const angle = rad(ITEM_ANGLES[index] ?? -90);
+ const x = OUTER_RADIUS + Math.cos(angle) * ITEM_RADIUS;
+ const y = OUTER_RADIUS + Math.sin(angle) * ITEM_RADIUS;
+ return (
+ <button
+ key={item.id}
+ ref={(node) => {
+ itemRefs.current[index] = node;
+ }}
+ type="button"
+ role="menuitem"
+ className="radial-menu-item"
+ data-active={activeIndex === index ? "true" : undefined}
+ disabled={item.disabled}
+ style={{
+ left: `${x}px`,
+ top: `${y}px`,
+ width: `${ITEM_SIZE}px`,
+ minHeight: `${ITEM_SIZE}px`,
+ }}
+ onClick={(event) => {
+ event.stopPropagation();
+ select(index);
+ }}
+ onFocus={() => setActiveIndex(index)}
+ onPointerEnter={() => setActiveIndex(index)}
+ >
+ <span className="radial-menu-icon" aria-hidden>
+ {item.icon}
+ </span>
+ <span className="radial-menu-label">{item.label}</span>
+ </button>
+ );
+ })}
+ </div>,
+ );
+}
diff --git a/apps/desktop/src/components/settings/RadialMenuSettings.tsx b/apps/desktop/src/components/settings/RadialMenuSettings.tsx
new file mode 100644
index 000000000..153469eeb
--- /dev/null
+++ b/apps/desktop/src/components/settings/RadialMenuSettings.tsx
@@ -0,0 +1,74 @@
+/**
+ * Settings → AI → Radial context menu.
+ *
+ * The ring is opt-in, and each direction is a user choice: the vocabulary is
+ * fixed to actions the empty transcript background can actually perform, so a
+ * saved value never names an action the surface cannot run. `none` empties a
+ * direction instead of forcing four.
+ */
+import { useTranslation } from "react-i18next";
+import {
+ RADIAL_MENU_ACTIONS,
+ RADIAL_MENU_DIRECTIONS,
+ type AppSettings,
+ type RadialMenuAction,
+ type RadialMenuPreferences,
+} from "@pi-desktop/shared";
+import { SettingsCard, SettingsRow } from "../../features/settings/primitives";
+import { SettingsToggle } from "../ui";
+import { SettingsMenuSelect } from "./SettingsMenuSelect";
+import {
+ RADIAL_MENU_ACTION_LABEL_KEYS,
+ RADIAL_MENU_DIRECTION_LABEL_KEYS,
+ resolveRadialMenu,
+} from "../../lib/radial-menu";
+
+export function RadialMenuSettings({
+ settings,
+ saveSettings,
+}: {
+ settings: AppSettings;
+ saveSettings: (patch: Partial<AppSettings>) => Promise<void>;
+}) {
+ const { t } = useTranslation();
+ const radial = resolveRadialMenu(settings);
+ const save = (patch: Partial<RadialMenuPreferences>) =>
+ void saveSettings({ radialMenu: { ...settings.radialMenu, ...patch } });
+ const actionOptions = RADIAL_MENU_ACTIONS.map((action) => ({
+ id: action,
+ label: t(RADIAL_MENU_ACTION_LABEL_KEYS[action]),
+ }));
+ return (
+ <SettingsCard
+ title={t("settings.radialMenu")}
+ description={t("settings.radialMenuDesc")}
+ >
+ <SettingsRow
+ title={t("settings.radialMenuEnable")}
+ description={t("settings.radialMenuEnableDesc")}
+ >
+ <SettingsToggle
+ checked={radial.enabled}
+ label={t("settings.radialMenuEnable")}
+ onChange={() => save({ enabled: !radial.enabled })}
+ />
+ </SettingsRow>
+ {RADIAL_MENU_DIRECTIONS.map((direction) => (
+ <SettingsRow
+ key={direction}
+ title={t(RADIAL_MENU_DIRECTION_LABEL_KEYS[direction])}
+ >
+ <SettingsMenuSelect
+ label={t(RADIAL_MENU_DIRECTION_LABEL_KEYS[direction])}
+ value={radial.slots[direction]}
+ options={actionOptions}
+ disabled={!radial.enabled}
+ onChange={(id) =>
+ save({ [direction]: id as RadialMenuAction })
+ }
+ />
+ </SettingsRow>
+ ))}
+ </SettingsCard>
+ );
+}
diff --git a/apps/desktop/src/features/chat/transcript/ChatTranscript.tsx b/apps/desktop/src/features/chat/transcript/ChatTranscript.tsx
index ec0d8381b..89632993f 100644
--- a/apps/desktop/src/features/chat/transcript/ChatTranscript.tsx
+++ b/apps/desktop/src/features/chat/transcript/ChatTranscript.tsx
@@ -1,12 +1,13 @@
-import { memo, useMemo, useRef, type MouseEvent as ReactMouseEvent } from "react";
+import { memo, useMemo, useRef, useState, type MouseEvent as ReactMouseEvent } from "react";
import { useTranslation } from "react-i18next";
-import type { PlanningState, UiMessage } from "@pi-desktop/shared";
+import type { PlanningState, RadialMenuAction, UiMessage } from "@pi-desktop/shared";
import { proposalKindForMode } from "@pi-desktop/shared";
import { ConversationMinimap } from "../../../components/ConversationMinimap";
+import { RadialMenu, type RadialMenuSlot } from "../../../components/RadialMenu";
import { PermissionCard } from "../../../components/PermissionCard";
import { TooltipButton } from "../../../components/ui";
import { TurnOutcomeCard } from "../../../components/TurnOutcomeCard";
-import { IconArrowDown } from "../../../components/icons";
+import { IconArrowDown, IconArrowUp, IconChat, IconCopy, IconTextSelect } from "../../../components/icons";
import { useAppStore } from "../../../stores/app-store";
import type { PendingPermission } from "../../../lib/pending-permissions";
import { TRANSCRIPT_SKELETON_ROWS } from "../../../lib/transcript-settle";
@@ -33,6 +34,11 @@ import {
useTranscriptMenu,
} from "./TranscriptMenu";
import { conversationMenuItems } from "./menu-items";
+import {
+ RADIAL_MENU_ACTION_LABEL_KEYS,
+ RADIAL_MENU_DIRECTIONS,
+ resolveRadialMenu,
+} from "../../../lib/radial-menu";
import { SlotSessionProvider } from "../../../plugins/renderer-slots/use-slots";
type ChatTranscriptProps = {
@@ -102,6 +108,17 @@ function TranscriptBody({
const openTranscriptMenu = useTranscriptMenu();
const { copyText, selectText } = useChatTextActions();
const showToast = useAppStore((state) => state.showToast);
+ const radialMenu = resolveRadialMenu(
+ useAppStore((state) => state.settings),
+ );
+ /*
+ The ring is a second presentation of the background menu, not a second
+ menu: it opens at the pointer and keeps the same conversation-level actions.
+ */
+ const [radialPoint, setRadialPoint] = useState<{
+ x: number;
+ y: number;
+ } | null>(null);
const transcriptRunning = isRunning && liveTail;
const latestTurnResult = useAppStore((state) =>
sessionId ? state.latestTurnResults[sessionId] : undefined,
@@ -229,7 +246,74 @@ function TranscriptBody({
}
};
+ /* The newest settled answer, for the ring's optional copy slot. */
+ const lastAnswer = useMemo(() => {
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
+ const message = messages[index];
+ if (message?.role === "assistant" && message.content.trim()) {
+ return message.content;
+ }
+ }
+ return "";
+ }, [messages]);
+
+ /*
+ One slot per direction, in ring order. An action the conversation cannot
+ fill (no answer yet, or the `none` placeholder) keeps its sector disabled
+ so the geometry does not depend on message state.
+ */
+ const buildRadialMenuItems = (): RadialMenuSlot[] =>
+ RADIAL_MENU_DIRECTIONS.map((direction) => {
+ const action: RadialMenuAction = radialMenu.slots[direction];
+ const id = `${direction}:${action}`;
+ const label = t(RADIAL_MENU_ACTION_LABEL_KEYS[action]);
+ switch (action) {
+ case "copy-conversation":
+ return { id, label, icon: <IconCopy size={18} />, onSelect: () => void copyConversation() };
+ case "select-conversation":
+ return {
+ id,
+ label,
+ icon: <IconTextSelect size={18} />,
+ onSelect: () => selectText(contentRef.current),
+ };
+ case "copy-last-answer":
+ return {
+ id,
+ label,
+ icon: <IconChat size={18} />,
+ disabled: !lastAnswer,
+ onSelect: () => void copyText(lastAnswer),
+ };
+ case "scroll-top":
+ return {
+ id,
+ label,
+ icon: <IconArrowUp size={18} />,
+ onSelect: () => scrollRef.current?.scrollTo({ top: 0 }),
+ };
+ case "scroll-bottom":
+ return {
+ id,
+ label,
+ icon: <IconArrowDown size={18} />,
+ onSelect: () => {
+ onReturnToLatest?.();
+ jumpToLatest();
+ },
+ };
+ default:
+ return { id, label, icon: <IconChat size={18} />, disabled: true, onSelect: () => {} };
+ }
+ });
+
const onContextMenu = (event: ReactMouseEvent<HTMLDivElement>) => {
+ if (radialMenu.enabled) {
+ event.preventDefault();
+ event.stopPropagation();
+ setRadialPoint({ x: event.clientX, y: event.clientY });
+ return;
+ }
openTranscriptMenu(event, {
label: t("chat.conversationMenu"),
items: conversationMenuItems({
@@ -390,6 +474,14 @@ function TranscriptBody({
</TooltipButton>
) : null}
</div>
+ {radialPoint ? (
+ <RadialMenu
+ point={radialPoint}
+ items={buildRadialMenuItems()}
+ label={t("chat.conversationMenu")}
+ onClose={() => setRadialPoint(null)}
+ />
+ ) : null}
</SlotSessionProvider>
</DisclosureAnchorContext.Provider>
</TranscriptSearchContext.Provider>
diff --git a/apps/desktop/src/features/settings/SettingsPage.tsx b/apps/desktop/src/features/settings/SettingsPage.tsx
index 3c1cf4948..b22710b40 100644
--- a/apps/desktop/src/features/settings/SettingsPage.tsx
+++ b/apps/desktop/src/features/settings/SettingsPage.tsx
@@ -38,6 +38,7 @@ import { KeyboardShortcutsSection } from "../../components/settings/KeyboardShor
import { FontFamilyRow } from "../../components/settings/FontFamilyRow";
import { ShowThinkingRow } from "../../components/settings/ShowThinkingRow";
import { TranscriptDisplayModeRow } from "../../components/settings/TranscriptDisplayModeRow";
+import { RadialMenuSettings } from "../../components/settings/RadialMenuSettings";
import { FontSizeRow } from "../../components/settings/FontSizeRow";
import { LanguageRow } from "../../components/settings/LanguageRow";
import { SettingsMenuSelect } from "../../components/settings/SettingsMenuSelect";
@@ -602,6 +603,11 @@ export function SettingsPage() {
/>
</SettingsCard>
+ <RadialMenuSettings
+ settings={settings}
+ saveSettings={saveSettings}
+ />
+
</div>
)}
diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.ts
index 5465a95ab..eeb901160 100644
--- a/apps/desktop/src/lib/api.ts
+++ b/apps/desktop/src/lib/api.ts
@@ -162,6 +162,8 @@ import {
normalizeMode,
normalizeNetworkProxy,
normalizeNetworkPolicy,
+ normalizeRadialMenuPreferences,
+ radialMenuWriteError,
resolveFontScale,
normalizeChatContentMaxWidth,
validateNetworkPolicy,
@@ -448,6 +450,7 @@ export function normalizeSettings(settings: AppSettings): AppSettings {
(settings as { largePasteThreshold?: unknown }).largePasteThreshold,
),
fontScale: resolveFontScale(settings),
+ radialMenu: normalizeRadialMenuPreferences(settings.radialMenu),
networkProxy: normalizeNetworkProxy(
(settings as { networkProxy?: unknown }).networkProxy,
),
@@ -483,6 +486,12 @@ export function validateSettingsWrite(settings: AppSettings): AppSettings {
errorCode: "INVALID_PARAMS",
});
}
+ const radialMenuProblem = radialMenuWriteError(settings.radialMenu);
+ if (radialMenuProblem) {
+ throw Object.assign(new Error(radialMenuProblem), {
+ errorCode: "INVALID_PARAMS",
+ });
+ }
const value = settings as AppSettings & {
defaultCommandShell?: unknown;
largePasteThreshold?: unknown;
diff --git a/apps/desktop/src/lib/radial-menu.ts b/apps/desktop/src/lib/radial-menu.ts
new file mode 100644
index 000000000..09d4427b7
--- /dev/null
+++ b/apps/desktop/src/lib/radial-menu.ts
@@ -0,0 +1,61 @@
+/**
+ * Resolution for the opt-in radial context menu on the empty transcript
+ * background.
+ *
+ * The setting is data, not component state: the menu reads a resolved shape so
+ * an absent object, an unknown action from a newer build, or a partial write
+ * all still produce four usable directions. `enabled` is deliberately opt-in —
+ * upgrading must not replace the vertical menu users already point at.
+ */
+import {
+ DEFAULT_RADIAL_MENU_SLOTS,
+ isRadialMenuAction,
+ RADIAL_MENU_DIRECTIONS,
+ type AppSettings,
+ type RadialMenuAction,
+ type RadialMenuDirection,
+} from "@pi-desktop/shared";
+
+/** Translation key per action, shared by the settings pickers and the ring. */
+export {
+ RADIAL_MENU_ACTIONS,
+ RADIAL_MENU_DIRECTIONS,
+} from "@pi-desktop/shared";
+
+export const RADIAL_MENU_ACTION_LABEL_KEYS: Record<RadialMenuAction, string> = {
+ "copy-conversation": "chat.copyConversation",
+ "select-conversation": "chat.selectConversationText",
+ "copy-last-answer": "chat.copyLastAnswer",
+ "scroll-top": "chat.scrollToTop",
+ "scroll-bottom": "chat.scrollToBottom",
+ none: "settings.radialMenuActionNone",
+};
+
+/** Row titles for the four settings pickers. */
+export const RADIAL_MENU_DIRECTION_LABEL_KEYS: Record<
+ RadialMenuDirection,
+ string
+> = {
+ up: "settings.radialMenuUp",
+ right: "settings.radialMenuRight",
+ down: "settings.radialMenuDown",
+ left: "settings.radialMenuLeft",
+};
+
+export type ResolvedRadialMenu = {
+ enabled: boolean;
+ slots: Record<RadialMenuDirection, RadialMenuAction>;
+};
+
+export function resolveRadialMenu(
+ settings: Pick<AppSettings, "radialMenu"> | null | undefined,
+): ResolvedRadialMenu {
+ const raw = settings?.radialMenu;
+ const slots = {} as Record<RadialMenuDirection, RadialMenuAction>;
+ for (const direction of RADIAL_MENU_DIRECTIONS) {
+ slots[direction] = isRadialMenuAction(raw?.[direction])
+ ? (raw?.[direction] as RadialMenuAction)
+ : DEFAULT_RADIAL_MENU_SLOTS[direction];
+ }
+ return { enabled: raw?.enabled === true, slots };
+}
diff --git a/apps/desktop/src/lib/settings-search.ts b/apps/desktop/src/lib/settings-search.ts
index 7c4c1cf00..7830d528e 100644
--- a/apps/desktop/src/lib/settings-search.ts
+++ b/apps/desktop/src/lib/settings-search.ts
@@ -127,6 +127,15 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [
"settings.contextUsageDisplay",
"settings.contextUsageDisplayRemaining",
"settings.contextUsageDisplayUsed",
+ "settings.radialMenu",
+ "settings.radialMenuDesc",
+ "settings.radialMenuEnable",
+ "settings.radialMenuEnableDesc",
+ "settings.radialMenuUp",
+ "settings.radialMenuRight",
+ "settings.radialMenuDown",
+ "settings.radialMenuLeft",
+ "settings.radialMenuActionNone",
"settings.largePasteThreshold",
],
},
diff --git a/apps/desktop/src/styles/ui-kit.css b/apps/desktop/src/styles/ui-kit.css
index 58f333b14..ea73cf45c 100644
--- a/apps/desktop/src/styles/ui-kit.css
+++ b/apps/desktop/src/styles/ui-kit.css
@@ -354,6 +354,116 @@
background: var(--ds-border-subtle);
}
+/* Radial context menu on the empty transcript background (opt-in through
+ Settings → AI → Defaults). It joins the same floating-layer family as
+ `.context-menu`: viewport-fixed, measured before reveal, clamped inside the
+ window. The four sectors are one SVG plate; the buttons on top carry the
+ icons, labels, focus, and hit targets. */
+.radial-menu {
+ position: fixed;
+ z-index: 60; /* body-level menu layer, above pane stacking */
+ opacity: 0;
+ pointer-events: none;
+ visibility: hidden;
+ transform: scale(0.94);
+ transition:
+ opacity var(--motion-duration-fast) var(--motion-ease-out),
+ transform var(--motion-duration-fast) var(--motion-ease-out);
+}
+
+.radial-menu.is-open {
+ opacity: 1;
+ pointer-events: auto;
+ visibility: visible;
+ transform: scale(1);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .radial-menu {
+ transition: none;
+ transform: none;
+ }
+}
+
+.radial-menu-ring {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ overflow: visible;
+}
+
+.radial-menu-sector {
+ fill: var(--ds-bg-elevated-opaque);
+ stroke: var(--ds-border-subtle);
+ stroke-width: 1;
+ transition: fill var(--motion-duration-fast) var(--motion-ease-out);
+}
+
+.radial-menu-sector.is-active {
+ fill: var(--ds-bg-hover);
+}
+
+.radial-menu-hub {
+ fill: var(--ds-bg-elevated-opaque);
+ stroke: var(--ds-border-subtle);
+ stroke-width: 1;
+}
+
+.radial-menu-dot {
+ fill: var(--ds-text-faint);
+}
+
+.radial-menu-item {
+ position: absolute;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 2px;
+ transform: translate(-50%, -50%);
+ border-radius: var(--radius-lg);
+ padding: 4px;
+ color: var(--ds-text-primary);
+ text-align: center;
+}
+
+.radial-menu-item[data-active="true"] {
+ background: var(--ds-bg-hover);
+}
+
+/* An action the conversation cannot fill keeps its direction visible instead of
+ collapsing the ring into three unrelated sectors. */
+.radial-menu-item:disabled {
+ color: var(--ds-text-faint);
+ cursor: not-allowed;
+}
+
+.radial-menu-item:disabled .radial-menu-icon,
+.radial-menu-item:disabled .radial-menu-label {
+ color: var(--ds-text-faint);
+}
+
+.radial-menu-item:focus-visible {
+ outline: 2px solid var(--ds-focus);
+ outline-offset: 2px;
+}
+
+.radial-menu-icon {
+ display: inline-flex;
+ color: var(--ds-text-secondary);
+}
+
+.radial-menu-label {
+ max-width: 100%;
+ overflow: hidden;
+ color: var(--ds-text-muted);
+ font-size: var(--text-2xs);
+ line-height: var(--leading-tight);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
/* Shared labeled selections keep native input semantics, not platform paint. */
.ui-checkbox {
display: inline-flex;
diff --git a/apps/desktop/test/radial-menu.test.mjs b/apps/desktop/test/radial-menu.test.mjs
new file mode 100644
index 000000000..8c3e3c274
--- /dev/null
+++ b/apps/desktop/test/radial-menu.test.mjs
@@ -0,0 +1,48 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import { register } from "node:module";
+import test from "node:test";
+register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));
+const { resolveRadialMenu } = await import("../src/lib/radial-menu.ts");
+
+test("the radial menu is opt-in and keeps the released direction defaults", () => {
+ assert.deepEqual(resolveRadialMenu(undefined), {
+ enabled: false,
+ slots: {
+ up: "copy-conversation",
+ right: "select-conversation",
+ down: "scroll-bottom",
+ left: "scroll-top",
+ },
+ });
+ assert.equal(resolveRadialMenu({ radialMenu: {} }).enabled, false);
+ assert.equal(
+ resolveRadialMenu({ radialMenu: { enabled: true } }).enabled,
+ true,
+ );
+});
+
+test("an unknown action or a missing direction resolves per slot", () => {
+ const resolved = resolveRadialMenu({
+ radialMenu: { enabled: true, up: "none", down: "not-an-action" },
+ });
+ assert.deepEqual(resolved.slots, {
+ up: "none",
+ right: "select-conversation",
+ down: "scroll-bottom",
+ left: "scroll-top",
+ });
+});
+
+test("the transcript keeps the vertical menu unless the ring is enabled", () => {
+ const source = readFileSync(
+ new URL(
+ "../src/features/chat/transcript/ChatTranscript.tsx",
+ import.meta.url,
+ ),
+ "utf8",
+ );
+ assert.match(source, /if \(radialMenu\.enabled\) \{/);
+ assert.match(source, /<RadialMenu/);
+ assert.match(source, /openTranscriptMenu\(event, \{/);
+});
diff --git a/apps/desktop/test/settings-roundtrip.test.mjs b/apps/desktop/test/settings-roundtrip.test.mjs
index 5db8556fc..9c81b7209 100644
--- a/apps/desktop/test/settings-roundtrip.test.mjs
+++ b/apps/desktop/test/settings-roundtrip.test.mjs
@@ -128,6 +128,50 @@ test("transcript display mode defaults to fully folded and validates its three v
}
});
+test("radial menu preferences normalize per direction and reject unknown actions", () => {
+ const previousWindow = globalThis.window;
+ globalThis.window = { piDesktop: { platform: "win32" } };
+ try {
+ const base = { defaultMode: "agent", theme: "light", enterToSend: true };
+ assert.deepEqual(renderer.normalizeSettings(base).radialMenu, {});
+ assert.deepEqual(main.normalizeSettings(base).radialMenu, {});
+ const radialMenu = {
+ enabled: true,
+ up: "copy-last-answer",
+ right: "none",
+ down: "scroll-bottom",
+ left: "scroll-top",
+ };
+ assert.deepEqual(
+ renderer.normalizeSettings({ ...base, radialMenu }).radialMenu,
+ radialMenu,
+ );
+ assert.deepEqual(
+ main.normalizeSettings({ ...base, radialMenu }).radialMenu,
+ radialMenu,
+ );
+ assert.equal(
+ renderer.validateSettingsWrite({ ...base, radialMenu }).radialMenu.up,
+ "copy-last-answer",
+ );
+ assert.throws(
+ () => renderer.validateSettingsWrite({ radialMenu: { up: "nope" } }),
+ /radialMenu\.up is invalid/,
+ );
+ assert.throws(
+ () => main.validateSettingsWrite({ radialMenu: { up: "nope" } }),
+ /radialMenu\.up is invalid/,
+ );
+ assert.throws(
+ () => renderer.validateSettingsWrite({ radialMenu: { enabled: "yes" } }),
+ /radialMenu\.enabled is invalid/,
+ );
+ } finally {
+ if (previousWindow === undefined) delete globalThis.window;
+ else globalThis.window = previousWindow;
+ }
+});
+
test("settings write round-trips command folding through the preload boundary", async () => {
const previousWindow = globalThis.window;
const calls = [];
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index bd6cd6271..5496ef75a 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -339,6 +339,15 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (
standard 240px field-column cap. Labels stay on one line; when space is
insufficient, the control moves below the title and whole options wrap
within the available pane width without horizontal overflow.
+- **Radial context menu** is a card in AI after Defaults with one switch
+ (**Enable on the transcript background**) and four direction pickers
+ (**Up**, **Right**, **Down**, **Left**). The switch is off when
+ `AppSettings.radialMenu.enabled` is absent or false, which keeps the vertical
+ background menu. Each picker stores one `RadialMenuAction`: copy conversation,
+ select conversation text, copy the last answer, scroll to top, jump to
+ latest, or **Leave empty**. Pickers are disabled while the switch is off and
+ keep their stored directions for when it is turned back on. Settings search
+ indexes the card and its rows.
- The **Command shell** row in Defaults uses the host-discovered catalog of native
PowerShell 5.1, PowerShell 7, cmd, Git Bash, and Bash with IDs
`windows-powershell`, `windows-pwsh`, `cmd`, `git-bash`, and
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index 56d24b67d..e1efee32c 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -684,6 +684,34 @@ may be retained while exactly one workspace supplies the visible shell context.
close buttons, and focus handling remain authoritative; native selection is
not prevented and no pointer capture is added for dismissal.
+### 1.11 Transcript background radial menu (opt-in)
+
+- **Settings → AI → Radial context menu** carries one switch and four
+ direction pickers. The switch is off unless `AppSettings.radialMenu.enabled`
+ is true, so an upgrade keeps the vertical menu every earlier build shipped.
+- With the switch on, a right-click on the empty transcript background opens a
+ four-sector ring centred on the pointer instead of the vertical conversation
+ menu. Message rows, markdown links, file references, tool rows, the sidebar,
+ and the work panel keep their vertical menus.
+- The vocabulary is the conversation-level set: copy conversation, select
+ conversation text, copy the last answer, scroll to top, jump to latest, and
+ **Leave empty**. A direction with no action renders a disabled sector rather
+ than reshaping the ring; an action the conversation cannot fill (copy last
+ answer before any answer text exists) is visible and disabled.
+- The sector under the pointer highlights; clicking it runs the action and
+ closes the ring. A click on the hub or outside closes without running.
+ Arrow keys move the highlight clockwise and counter-clockwise, Enter runs the
+ highlighted action, and Escape or Tab dismisses. Focus returns through the
+ same outside-press, scroll, resize, and blur listeners as `ContextMenu`.
+- Placement follows the shared floating-layer contract: a viewport-fixed portal
+ measured before reveal, clamped inside the window with the same 8px margin,
+ so a right-click near an edge moves the ring rather than clipping it.
+- An absent preference, a non-boolean `enabled`, or an unknown action resolves
+ per direction to the defaults (up: copy conversation, right: select
+ conversation text, down: jump to latest, left: scroll to top). Settings
+ writes naming an unknown action are rejected by both the renderer and
+ Electron Main.
+
## 2. Streaming message behavior
### 2.1 Token rendering
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 0b6ed5423..50f03091b 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -5230,6 +5230,41 @@ window; opening a normal panel afterward must still work.
`chat-context-menu-items.test.mjs`, `chat-context-menu-surface.test.mjs`);
full UI scenario Draft
+#### E2E-CHAT-radial-background-menu: Radial menu on the empty transcript background
+
+- **Preconditions**: Settings → AI → Radial context menu is available. A
+ session has a completed user prompt, a completed assistant answer, and enough
+ history to scroll.
+- **Steps**: 1) With the switch off, right-click empty space below the last
+ turn and confirm the vertical conversation menu. 2) Turn the switch on and
+ right-click the same space; inspect the four sectors. 3) Move the pointer
+ through each sector and click Copy conversation. 4) Set Up to Copy last
+ answer and Right to Leave empty, then reopen the ring. 5) Click the hub
+ without moving, then reopen and press Escape; repeat with an outside click,
+ a scroll, and a window resize. 6) Reopen with Shift+F10, walk the sectors
+ with the arrow keys, and run one with Enter. 7) Restart the app, confirm the
+ switch and the four directions persist, then write an unknown action for one
+ direction into the settings file and confirm that direction resolves to its
+ default.
+- **Expected**: With the switch off the vertical menu opens unchanged. With it
+ on, a four-sector ring centred on the pointer replaces it and stays fully
+ inside the window near an edge. Each sector highlights under the pointer;
+ clicking runs that action, closes the ring, and shows the usual toast where
+ the action copies. A **Leave empty** direction renders a disabled sector and
+ runs nothing; Copy last answer is disabled until an answer exists. A click on
+ the hub, an outside press, Escape, Tab, scroll, and resize all dismiss the
+ ring without running anything. Arrow keys move the highlight and Enter runs
+ the highlighted action. The switch and the four directions survive a restart,
+ and an unknown stored action falls back to that direction's default. Message
+ rows, links, file references, the sidebar, and the work panel keep their
+ vertical menus.
+- **Specs linked**: `04-ux/09-interaction-patterns.md` §1.11,
+ `04-ux/06-settings-ia.md`
+- **Acceptance**: C (chat stream), Quality
+- **Milestone**: M5
+- **Status**: Unit-covered (`radial-menu.test.mjs`,
+ `settings-roundtrip.test.mjs`); full UI scenario Draft
+
### E2E-CHAT-delete-turn-preserves-other-live-outputs
- **Preconditions**: A session has three completed turns. The renderer has
diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.md
index ba4d05a3c..b26d6744d 100644
--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md
+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md
@@ -139,6 +139,12 @@
「全折叠显示」让命令留在所属组内,只有普通进度文字会拆分活动组。三者都只渲染一个
过程披露,只改变展示,并在渲染时读取,因此切换后立即重绘转录。已弃用的
`keepCommandsExpanded` 布尔值不再暴露,也不再参与渲染读取。设置搜索会索引该行。
+- **环形右键菜单**是 AI 页中默认项卡之后的一张卡,包含一个开关(**在对话空白处启用**)
+ 和四个方向选择器(**上**、**右**、**下**、**左**)。`AppSettings.radialMenu.enabled`
+ 缺失或为 false 时开关关闭,保留纵向的背景菜单。每个选择器保存一个
+ `RadialMenuAction`:复制整段对话、全选对话文本、复制最后一条回复、跳到顶部、
+ 回到最新,或**留空**。开关关闭时选择器禁用,但保留已存的方向,重新开启时继续使用。
+ 设置搜索会索引该卡及其各行。
- 语音绑定(`AppSettings.speech`)**不属于设置页面**(ADR 0291)。宿主仍保留语音能力与
`speech/*` IPC,供插件和已存绑定使用;这里不再提供转写/朗读的服务、协议、模型或音色
选择,设置搜索也不再索引语音相关键。
diff --git a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
index 9d548f198..dedc0b068 100644
--- a/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
+++ b/docs/zh-CN/spec/04-ux/09-interaction-patterns.md
@@ -494,6 +494,26 @@
转义或背景,并将焦点恢复到调用控件。
- D126 标签版本发布所有平台清单和安装程序。打包的 macOS、Windows NSIS 和 Linux AppImage 使用应用内通道;Linux deb/rpm 和 Windows ZIP 保持通知和链接传递模式。
+### 1. 11 转录背景环形菜单(可选)
+
+- **设置 → AI → 环形右键菜单**包含一个开关和四个方向选择器。只有
+ `AppSettings.radialMenu.enabled` 为 true 时开关才开启,因此升级不会替换此前版本
+ 一直提供的纵向菜单。
+- 开关开启后,在对话正文空白处右键会在指针位置弹出四扇区环形菜单,取代纵向的对话
+ 菜单。消息行、markdown 链接、文件引用、工具行、侧边栏和工作面板仍使用各自的纵向
+ 菜单。
+- 动作词汇限定为对话级操作:复制整段对话、全选对话文本、复制最后一条回复、跳到顶部、
+ 回到最新,以及**留空**。没有动作的方向渲染为禁用扇区,而不是改变环形布局;当前对话
+ 无法执行的动作(例如尚无任何回答文本时的复制最后一条回复)仍然可见但禁用。
+- 指针所在扇区高亮;点击后执行该动作并关闭菜单。点击中心圆或菜单外会直接关闭,不执行
+ 任何动作。方向键顺时针、逆时针移动高亮,Enter 执行当前动作,Escape 或 Tab 关闭。
+ 外部按下、滚动、窗口尺寸变化和失焦的监听与 `ContextMenu` 相同。
+- 定位沿用共享的浮动层契约:视口固定 portal、显示前先测量、以同样的 8px 边距限制在
+ 窗口内,因此靠近边缘右键时是移动整个环形菜单,而不是裁掉扇区。
+- 设置缺失、`enabled` 不是布尔值,或动作未知时,按方向回退到默认值(上:复制整段对话;
+ 右:全选对话文本;下:回到最新;左:跳到顶部)。写入未知动作会被渲染器和 Electron
+ Main 两侧拒绝。
+
## 2. 流消息行为
### 2. 1 Token渲染
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 0d853866b..fef2f7000 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -2681,6 +2681,16 @@ MainChat 弥补了缺口。 Maximized/fullscreen 调用保留最新的
- **完整历史回归**:打开包含 140 条消息的会话,不向上翻页,选择复制整个对话;剪贴板必须包含第 1–140 条消息。从搜索上下文窗口和长消息截断预览重复验证。保留当前可见的生成中文字;读取失败时提示错误,剪贴板保持不变。仅在选择复制后读取完整历史,不改变阅读位置。运行 `node scripts/e2e-copy-conversation.mjs`。
- 编辑时复制应使用草稿选区,无选区时复制整份草稿;选中消息文本应选中草稿。菜单不提供编辑、删除或版本切换;取消后原消息及其菜单保持不变。自动化验证:`node scripts/e2e-message-edit-copy.mjs`。
+#### E2E-CHAT-radial-background-menu:对话空白处的环形菜单
+
+- **前提条件**:设置 → AI → 环形右键菜单可用;会话中有一条已完成的用户提示、一条已完成的助手回答,且历史足以滚动。
+- **步骤**:1)关闭开关,右键最后一回合下方的空白处,确认弹出纵向对话菜单。2)打开开关,右键同一位置,检查四个扇区。3)让指针经过各扇区,点击复制整段对话。4)把「上」设为复制最后一条回复、「右」设为留空,重新打开环形菜单。5)不移动指针直接点击中心圆;再重新打开后依次按 Escape、点击外部、滚动、调整窗口尺寸。6)用 Shift+F10 打开,用方向键遍历扇区,按 Enter 执行一项。7)重启应用,确认开关和四个方向都保留;再把某个方向的未知动作写入设置文件,确认该方向回退到默认值。
+- **预期**:开关关闭时纵向菜单原样打开。开关开启后,以指针为圆心的四扇区环形菜单取代它,靠近窗口边缘时仍完整可见。指针所在扇区高亮;点击后执行该动作、关闭菜单,复制类动作照常弹出提示。「留空」方向渲染为禁用扇区且不执行任何动作;尚无回答文本时复制最后一条回复为禁用。点击中心圆、外部按下、Escape、Tab、滚动和窗口尺寸变化都只关闭菜单。方向键移动高亮,Enter 执行当前动作。开关和四个方向在重启后保留,存储中的未知动作回退到该方向的默认值。消息行、链接、文件引用、侧边栏和工作面板仍使用各自的纵向菜单。
+- **关联规范**:`04-ux/09-interaction-patterns.md` §1.11、`04-ux/06-settings-ia.md`
+- **验收**:C(聊天流)、质量
+- **里程碑**:M5
+- **状态**:单元覆盖(`radial-menu.test.mjs`、`settings-roundtrip.test.mjs`);完整 UI 场景草稿
+
#### E2E-CHAT-delete-turn-preserves-other-live-outputs:删除回合后保留其他实时输出
- **前提条件**:会话有三个已完成的回合。渲染器包含这三个回合的助手和工具输出,但由于 outbox 追加仍在等待,持久化内容至少缺少一条输出。
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index d4673ecfc..db7333402 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -412,6 +412,7 @@ export const de = {
"conversationMenu": "Gesprächsaktionen",
"selectMessageText": "Nachrichtentext auswählen",
"copyConversation": "Gespräch kopieren",
+ "copyLastAnswer": "Letzte Antwort kopieren",
"sessionReference": "Unterhaltung",
"sessionReferenceOpen": "Unterhaltung {{title}} öffnen",
"selectConversationText": "Gesprächstext auswählen",
@@ -1487,6 +1488,15 @@ sklm: {
"showThinkingDesc": "Zeigt den Denkprozess des Modells. Wenn aus, bleibt die Live-Denk-Anzeige sichtbar und abgeschlossene Denkzeilen und Auszüge werden ausgeblendet.",
"transcriptDisplayMode": "Prozessanzeige",
"transcriptDisplayModeDesc": "Legt fest, wie der Assistentenprozess im Transkript gruppiert wird.",
+ "radialMenu": "Radiales Kontextmenü",
+ "radialMenuDesc": "Ein Rechtsklick in den leeren Bereich unter der Unterhaltung öffnet ein Menü mit vier Richtungen statt einer Liste.",
+ "radialMenuEnable": "Auf dem Transkript-Hintergrund aktivieren",
+ "radialMenuEnableDesc": "Ersetzt nur das vertikale Menü im leeren Bereich. Menüs auf Nachrichten, Links und Dateiverweisen bleiben unverändert.",
+ "radialMenuUp": "Richtung oben",
+ "radialMenuRight": "Richtung rechts",
+ "radialMenuDown": "Richtung unten",
+ "radialMenuLeft": "Richtung links",
+ "radialMenuActionNone": "Leer lassen",
"transcriptDisplayModeFlat": "Flach",
"transcriptDisplayModeCommandFirst": "Befehle zuerst",
"transcriptDisplayModeFullyFolded": "Vollständig eingeklappt",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 8f81407d0..97b6c3645 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -424,6 +424,7 @@ export const en = {
conversationMenu: "Conversation actions",
selectMessageText: "Select message text",
copyConversation: "Copy conversation",
+ copyLastAnswer: "Copy last answer",
sessionReference: "Conversation",
sessionReferenceOpen: "Open conversation {{title}}",
selectConversationText: "Select conversation text",
@@ -1501,6 +1502,15 @@ sklm: {
showThinkingDesc: "Show the model's reasoning. Off keeps the live thinking indicator visible and hides completed reasoning rows and excerpts.",
transcriptDisplayMode: "Transcript display",
transcriptDisplayModeDesc: "Choose how the assistant process is grouped in the transcript.",
+ radialMenu: "Radial context menu",
+ radialMenuDesc: "Right-click the empty space below the conversation to open a menu with four directions instead of a list.",
+ radialMenuEnable: "Enable on the transcript background",
+ radialMenuEnableDesc: "Replaces only the vertical menu that opens in empty space. Menus on messages, links, and file references stay unchanged.",
+ radialMenuUp: "Up direction",
+ radialMenuRight: "Right direction",
+ radialMenuDown: "Down direction",
+ radialMenuLeft: "Left direction",
+ radialMenuActionNone: "Leave empty",
transcriptDisplayModeFlat: "Flat",
transcriptDisplayModeCommandFirst: "Commands first",
transcriptDisplayModeFullyFolded: "Fully folded",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index 0b2d870b3..b737dd472 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -412,6 +412,7 @@ export const es = {
"conversationMenu": "Acciones de la conversación",
"selectMessageText": "Seleccionar el texto del mensaje",
"copyConversation": "Copiar la conversación",
+ "copyLastAnswer": "Copiar última respuesta",
"sessionReference": "Conversación",
"sessionReferenceOpen": "Abrir la conversación {{title}}",
"selectConversationText": "Seleccionar el texto de la conversación",
@@ -1487,6 +1488,15 @@ sklm: {
"showThinkingDesc": "Muestra el razonamiento del modelo. Desactivado, el indicador de razonamiento en vivo sigue visible y las filas y extractos de razonamiento completados quedan ocultos.",
"transcriptDisplayMode": "Visualización del proceso",
"transcriptDisplayModeDesc": "Elige cómo se agrupa el proceso del asistente en la transcripción.",
+ "radialMenu": "Menú contextual radial",
+ "radialMenuDesc": "Al hacer clic derecho en el espacio vacío bajo la conversación se abre un menú de cuatro direcciones en lugar de una lista.",
+ "radialMenuEnable": "Activar en el fondo de la transcripción",
+ "radialMenuEnableDesc": "Solo sustituye el menú vertical del espacio vacío. Los menús de mensajes, enlaces y referencias a archivos no cambian.",
+ "radialMenuUp": "Dirección arriba",
+ "radialMenuRight": "Dirección derecha",
+ "radialMenuDown": "Dirección abajo",
+ "radialMenuLeft": "Dirección izquierda",
+ "radialMenuActionNone": "Dejar vacío",
"transcriptDisplayModeFlat": "Plano",
"transcriptDisplayModeCommandFirst": "Comandos primero",
"transcriptDisplayModeFullyFolded": "Totalmente plegado",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index e4c1ed23c..33a4fc249 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -412,6 +412,7 @@ export const fr = {
"conversationMenu": "Actions de la conversation",
"selectMessageText": "Sélectionner le texte du message",
"copyConversation": "Copier la conversation",
+ "copyLastAnswer": "Copier la dernière réponse",
"sessionReference": "Conversation",
"sessionReferenceOpen": "Ouvrir la conversation {{title}}",
"selectConversationText": "Sélectionner le texte de la conversation",
@@ -1487,6 +1488,15 @@ sklm: {
"showThinkingDesc": "Affiche le raisonnement du modèle. Désactivé, l'indicateur de raisonnement en direct reste visible et les lignes et extraits de raisonnement terminés sont masqués.",
"transcriptDisplayMode": "Affichage du processus",
"transcriptDisplayModeDesc": "Choisit comment le processus de l'assistant est regroupé dans la transcription.",
+ "radialMenu": "Menu contextuel radial",
+ "radialMenuDesc": "Un clic droit dans l’espace vide sous la conversation ouvre un menu à quatre directions au lieu d’une liste.",
+ "radialMenuEnable": "Activer sur le fond de la conversation",
+ "radialMenuEnableDesc": "Remplace uniquement le menu vertical de l’espace vide. Les menus des messages, liens et références de fichiers restent inchangés.",
+ "radialMenuUp": "Direction haut",
+ "radialMenuRight": "Direction droite",
+ "radialMenuDown": "Direction bas",
+ "radialMenuLeft": "Direction gauche",
+ "radialMenuActionNone": "Laisser vide",
"transcriptDisplayModeFlat": "À plat",
"transcriptDisplayModeCommandFirst": "Commandes d'abord",
"transcriptDisplayModeFullyFolded": "Entièrement replié",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index df9576c0b..d47f1c369 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -424,6 +424,7 @@ export const ko = {
conversationMenu: "대화 작업",
selectMessageText: "메시지 텍스트 선택",
copyConversation: "대화 복사",
+ copyLastAnswer: "마지막 답변 복사",
sessionReference: "대화 참조",
sessionReferenceOpen: "대화 {{title}} 열기",
selectConversationText: "대화 텍스트 선택",
@@ -1497,6 +1498,15 @@ sklm: {
showThinkingDesc: "모델의 사고 과정을 표시합니다. 끄면 실시간 사고 표시기는 계속 보이고 완료된 사고 행과 발췌는 숨겨집니다.",
transcriptDisplayMode: "프로세스 표시",
transcriptDisplayModeDesc: "트랜스크립트에서 어시스턴트 프로세스를 묶는 방식을 선택합니다.",
+ radialMenu: "방사형 컨텍스트 메뉴",
+ radialMenuDesc: "대화 아래 빈 공간에서 마우스 오른쪽 버튼을 누르면 목록 대신 네 방향 메뉴가 열립니다.",
+ radialMenuEnable: "대화 배경에서 사용",
+ radialMenuEnableDesc: "빈 공간에서 열리는 세로 메뉴만 바뀝니다. 메시지, 링크, 파일 참조의 메뉴는 그대로입니다.",
+ radialMenuUp: "위 방향",
+ radialMenuRight: "오른쪽 방향",
+ radialMenuDown: "아래 방향",
+ radialMenuLeft: "왼쪽 방향",
+ radialMenuActionNone: "비워 두기",
transcriptDisplayModeFlat: "평면 표시",
transcriptDisplayModeCommandFirst: "명령 우선",
transcriptDisplayModeFullyFolded: "전체 접기",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index ccef8e9a3..578693752 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -411,6 +411,7 @@ export const ptBR = {
conversationMenu: "Ações da conversa",
selectMessageText: "Selecionar texto da mensagem",
copyConversation: "Copiar conversa",
+ copyLastAnswer: "Copiar última resposta",
sessionReference: "Conversa",
sessionReferenceOpen: "Abrir a conversa {{title}}",
selectConversationText: "Selecionar texto da conversa",
@@ -1460,6 +1461,15 @@ export const ptBR = {
showThinkingDesc: "Mostra o raciocínio do modelo. Quando desativado, o indicador de raciocínio ao vivo continua visível e as linhas e trechos de raciocínio concluídos ficam ocultos.",
transcriptDisplayMode: "Exibição do processo",
transcriptDisplayModeDesc: "Escolha como o processo do assistente é agrupado na transcrição.",
+ radialMenu: "Menu de contexto radial",
+ radialMenuDesc: "Clicar com o botão direito no espaço vazio abaixo da conversa abre um menu de quatro direções em vez de uma lista.",
+ radialMenuEnable: "Ativar no fundo da conversa",
+ radialMenuEnableDesc: "Substitui apenas o menu vertical do espaço vazio. Os menus de mensagens, links e referências de arquivo não mudam.",
+ radialMenuUp: "Direção para cima",
+ radialMenuRight: "Direção para a direita",
+ radialMenuDown: "Direção para baixo",
+ radialMenuLeft: "Direção para a esquerda",
+ radialMenuActionNone: "Deixar vazio",
transcriptDisplayModeFlat: "Plano",
transcriptDisplayModeCommandFirst: "Comandos primeiro",
transcriptDisplayModeFullyFolded: "Totalmente recolhido",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 88726748a..b072c500e 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -424,6 +424,7 @@ export const tr = {
conversationMenu: "Konuşma işlemleri",
selectMessageText: "Mesaj metnini seç",
copyConversation: "Konuşmayı kopyala",
+ copyLastAnswer: "Son yanıtı kopyala",
sessionReference: "Konuşma",
sessionReferenceOpen: "{{title}} konuşmasını aç",
selectConversationText: "Konuşma metnini seç",
@@ -1491,6 +1492,15 @@ sklm: {
showThinkingDesc: "Modelin düşünmesini gösterir. Kapalıyken canlı düşünme göstergesi görünür kalır; tamamlanan düşünme satırları ve alıntılar gizlenir.",
transcriptDisplayMode: "Süreç görünümü",
transcriptDisplayModeDesc: "Asistan sürecinin transkriptte nasıl gruplanacağını seçer.",
+ radialMenu: "Dairesel bağlam menüsü",
+ radialMenuDesc: "Konuşmanın altındaki boş alana sağ tıklamak, liste yerine dört yönlü bir menü açar.",
+ radialMenuEnable: "Transkript arka planında etkinleştir",
+ radialMenuEnableDesc: "Yalnızca boş alanda açılan dikey menüyü değiştirir. Mesaj, bağlantı ve dosya referansı menüleri aynı kalır.",
+ radialMenuUp: "Yukarı yön",
+ radialMenuRight: "Sağ yön",
+ radialMenuDown: "Aşağı yön",
+ radialMenuLeft: "Sol yön",
+ radialMenuActionNone: "Boş bırak",
transcriptDisplayModeFlat: "Düz",
transcriptDisplayModeCommandFirst: "Önce komutlar",
transcriptDisplayModeFullyFolded: "Tamamen katlanmış",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index 551cc80ff..425dabeb5 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -417,6 +417,7 @@ export const zhCN = {
conversationMenu: "对话操作",
selectMessageText: "选中消息文本",
copyConversation: "复制整个对话",
+ copyLastAnswer: "复制最后一条回复",
sessionReference: "会话引用",
sessionReferenceOpen: "打开会话 {{title}}",
selectConversationText: "选中对话文本",
@@ -1481,6 +1482,15 @@ sklm: {
showThinkingDesc: "显示模型的推理内容。关闭后仍显示实时思考指示器,并隐藏已完成的推理行和摘要。",
transcriptDisplayMode: "过程显示",
transcriptDisplayModeDesc: "选择助手过程在对话中的分组方式。",
+ radialMenu: "环形右键菜单",
+ radialMenuDesc: "在对话下方的空白处右键时,弹出四向菜单,而不是纵向列表。",
+ radialMenuEnable: "在对话空白处启用",
+ radialMenuEnableDesc: "只替换空白处弹出的纵向菜单;消息、链接和文件引用的菜单不变。",
+ radialMenuUp: "上",
+ radialMenuRight: "右",
+ radialMenuDown: "下",
+ radialMenuLeft: "左",
+ radialMenuActionNone: "留空",
transcriptDisplayModeFlat: "平铺显示",
transcriptDisplayModeCommandFirst: "命令工具优先",
transcriptDisplayModeFullyFolded: "全折叠显示",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index 6e962a278..0d20c206f 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -417,6 +417,7 @@ export const zhTW = {
conversationMenu: "對話操作",
selectMessageText: "選取訊息文字",
copyConversation: "複製整段對話",
+ copyLastAnswer: "複製最後一則回覆",
sessionReference: "對話引用",
sessionReferenceOpen: "開啟對話 {{title}}",
selectConversationText: "選取對話文字",
@@ -1481,6 +1482,15 @@ sklm: {
showThinkingDesc: "顯示模型的推理內容。關閉後仍顯示即時思考指示器,並隱藏已完成的推理列和摘要。",
transcriptDisplayMode: "過程顯示",
transcriptDisplayModeDesc: "選擇助理過程在對話中的分組方式。",
+ radialMenu: "環形右鍵選單",
+ radialMenuDesc: "在對話下方的空白處按右鍵時,彈出四向選單,而不是直向清單。",
+ radialMenuEnable: "在對話空白處啟用",
+ radialMenuEnableDesc: "只替換空白處彈出的直向選單;訊息、連結與檔案參照的選單不變。",
+ radialMenuUp: "上",
+ radialMenuRight: "右",
+ radialMenuDown: "下",
+ radialMenuLeft: "左",
+ radialMenuActionNone: "留空",
transcriptDisplayModeFlat: "平鋪顯示",
transcriptDisplayModeCommandFirst: "命令工具優先",
transcriptDisplayModeFullyFolded: "全摺疊顯示",
diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts
index ce210f32c..cb2b9d1af 100644
--- a/packages/shared/src/index.ts
+++ b/packages/shared/src/index.ts
@@ -60,6 +60,7 @@ export * from "./gen-ui.js";
export * from "./image-generation.js";
export * from "./font-size.js";
export * from "./chat-content-width.js";
+export * from "./radial-menu.js";
export * from "./racp.js";
export * from "./trusted-extensions.js";
export * from "./provider-retry.js";
diff --git a/packages/shared/src/radial-menu.ts b/packages/shared/src/radial-menu.ts
new file mode 100644
index 000000000..f6526a706
--- /dev/null
+++ b/packages/shared/src/radial-menu.ts
@@ -0,0 +1,81 @@
+/**
+ * Vocabulary and normalization for `AppSettings.radialMenu`, shared by the
+ * renderer and Electron Main so both sides accept exactly the same values.
+ */
+import type {
+ RadialMenuAction,
+ RadialMenuDirection,
+ RadialMenuPreferences,
+} from "./types/settings.js";
+
+/** Clockwise from the top, the order the ring renders and the keyboard walks. */
+export const RADIAL_MENU_DIRECTIONS = [
+ "up",
+ "right",
+ "down",
+ "left",
+] as const satisfies readonly RadialMenuDirection[];
+
+export const RADIAL_MENU_ACTIONS = [
+ "copy-conversation",
+ "select-conversation",
+ "copy-last-answer",
+ "scroll-top",
+ "scroll-bottom",
+ "none",
+] as const satisfies readonly RadialMenuAction[];
+
+export const DEFAULT_RADIAL_MENU_SLOTS: Record<
+ RadialMenuDirection,
+ RadialMenuAction
+> = {
+ up: "copy-conversation",
+ right: "select-conversation",
+ down: "scroll-bottom",
+ left: "scroll-top",
+};
+
+export function isRadialMenuAction(value: unknown): value is RadialMenuAction {
+ return (
+ typeof value === "string" &&
+ (RADIAL_MENU_ACTIONS as readonly string[]).includes(value)
+ );
+}
+
+/**
+ * Normalizes a whole preference for persistence. Unknown actions and a
+ * non-boolean flag are dropped rather than copied forward, so a settings file
+ * touched by a newer build keeps a shape this build can read.
+ */
+export function normalizeRadialMenuPreferences(
+ value: unknown,
+): RadialMenuPreferences {
+ if (!value || typeof value !== "object") return {};
+ const raw = value as Record<string, unknown>;
+ const next: RadialMenuPreferences = {};
+ if (typeof raw.enabled === "boolean") next.enabled = raw.enabled;
+ for (const direction of RADIAL_MENU_DIRECTIONS) {
+ if (isRadialMenuAction(raw[direction])) {
+ next[direction] = raw[direction] as RadialMenuAction;
+ }
+ }
+ return next;
+}
+
+/** True when the write carries a `radialMenu` field this build cannot read. */
+export function radialMenuWriteError(value: unknown): string | null {
+ if (value === undefined) return null;
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
+ return "radialMenu is invalid";
+ }
+ const raw = value as Record<string, unknown>;
+ if (raw.enabled !== undefined && typeof raw.enabled !== "boolean") {
+ return "radialMenu.enabled is invalid";
+ }
+ for (const direction of RADIAL_MENU_DIRECTIONS) {
+ if (raw[direction] !== undefined && !isRadialMenuAction(raw[direction])) {
+ return `radialMenu.${direction} is invalid`;
+ }
+ }
+ return null;
+}
diff --git a/packages/shared/src/types/settings.ts b/packages/shared/src/types/settings.ts
index be644eee2..cc762514a 100644
--- a/packages/shared/src/types/settings.ts
+++ b/packages/shared/src/types/settings.ts
@@ -226,6 +226,12 @@ export type AppSettings = {
sidebarSessionTime?: boolean;
/** Voice input settings (D-voice-runtime). */
voice?: VoiceInputSettings;
+ /**
+ * Opt-in radial context menu for the empty transcript background. Absent
+ * keeps the vertical menu; see `RadialMenuPreferences` for the direction
+ * defaults.
+ */
+ radialMenu?: RadialMenuPreferences;
onboardingDismissed: boolean;
};
@@ -246,3 +252,31 @@ export type VoiceInputSettings = {
export type LinkOpenTarget = "workpanel" | "external";
export type ContextUsageDisplay = "remaining" | "used";
+
+/**
+ * One action the transcript background radial menu can place on a direction.
+ * `none` leaves that direction empty, so a ring can carry fewer than four
+ * actions without inventing a fifth one.
+ */
+export type RadialMenuAction =
+ | "copy-conversation"
+ | "select-conversation"
+ | "copy-last-answer"
+ | "scroll-top"
+ | "scroll-bottom"
+ | "none";
+
+export type RadialMenuDirection = "up" | "right" | "down" | "left";
+
+/**
+ * Per-direction placement for the transcript background radial menu.
+ * Absent fields fall back to the released defaults; `enabled` is opt-in, so an
+ * absent object keeps the vertical context menu every existing build ships.
+ */
+export type RadialMenuPreferences = {
+ enabled?: boolean;
+ up?: RadialMenuAction;
+ right?: RadialMenuAction;
+ down?: RadialMenuAction;
+ left?: RadialMenuAction;
+};