Repository navigation
feat(chat): opt-in radial context menu on the transcript background - #1919
Merged
Merged
Conversation
Owner
|
感谢 PR,我会尽快审核! |
muzimu217
reviewed
Oct 27, 2026
muzimu217
left a comment
Contributor
There was a problem hiding this comment.
Read the geometry, the interaction model, and the settings path. The parts that usually go wrong in a radial control are right:
- Opt-in is real and defensive.
resolveRadialMenu(lib/radial-menu.ts) gates onraw?.enabled === trueand resolves each direction independently throughisRadialMenuAction, so a partial write, an unknown action from a newer build, or a missing object still yields four usable slots rather than a ring with holes. - The hit test agrees with the drawing.
ITEM_ANGLES = [-90, 0, 90, 180](up/right/down/left) matchesslotAt's(degrees + 135 + 360) % 360mapping, and the ±45° boundaries fall exactly on the drawnSECTOR_ANGLES, so a click near a seam lands in the sector the user sees highlighted. - Click resolves from the click point, not the last pointer move. That is the case a right-click followed immediately by a left-click would otherwise miss, and it is easy to get wrong.
- Dismissal covers the floating-layer contract — outside pointerdown and contextmenu, scroll in capture, resize, blur, Escape with
stopPropagation— and the ring restores focus to whatever owned it before the right-click instead of stranding focus on body. - It is a second presentation, not a second menu. The interception sits inside the existing background handler, so message rows, links and file references keep the vertical list.
Three non-blocking observations:
- A disabled slot is silent:
select()returns without feedback and the sector stays clickable. A configured action that the current conversation cannot fill (for example copy-conversation on an empty thread) will look like a broken ring.aria-disabledon the item plus a dimmed sector would say "nothing to copy" rather than "the menu did nothing". onPointerMovedrivesactiveIndex, and the effect atRadialMenu.tsxfocusesitemRefs[activeIndex], so sweeping the pointer moves DOM focus.preventScroll: truealready limits the damage, but if this ring ever opens over the settings dialog the focus churn will be visible. Consider focusing only for keyboard-driven changes (amodalityflag).- The viewport clamp is
Math.max(MARGIN, Math.min(point - OUTER_RADIUS, innerWidth - width - MARGIN)). Below2 * OUTER_RADIUS + 2 * MARGIN(336 px) the outermaxwins and the 320 px ring extends past the right or bottom edge. Clamping the far edge after the near edge would keep it inside at any width.
The settings card placement under AI, after Defaults, matches how the other opt-in surfaces are grouped, and putting the four pickers next to the switch is what makes this discoverable without a second screen.
Keep keyboard navigation usable when a ring direction is disabled, and match the transcript menu by disabling copy for empty sessions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the radial menu proposed in #1909, with the settings customization you asked for: one switch plus four direction pickers, so each user decides what their ring carries.
Closes #1909.
What it does
AppSettings.radialMenu.enableddefaults to off, so upgrading keeps the vertical background menu. The card lives in Settings → AI → Radial context menu, after Defaults.RadialMenuAction: copy conversation, select conversation text, copy last answer, scroll to top, jump to latest, open the built-in browser, open the work panel, open the project folder, or Leave empty. An empty direction renders a disabled sector instead of reshaping the ring. Actions the surface cannot run stay visible and disabled: copy last answer before answer text exists, and the three open actions on a remote session (open project folder also without a project path). The work panel direction follows the panel: Open work panel while collapsed, Close work panel while open. There is no terminal action because the work panel ships no terminal surface.ContextMenu: viewport-fixed portal measured before reveal, clamped inside the window with the 8 px margin.Settings and validation
AppSettings.radialMenuis added to@pi-desktop/shared, with the action vocabulary and normalization shared by the renderer and Electron Main.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).INVALID_PARAMS).Specs and tests
docs/spec/04-ux/09-interaction-patterns.md§1.11 (new),docs/spec/04-ux/06-settings-ia.md, and the mirrored zh-CN pages.E2E-CHAT-radial-background-menuindocs/spec/06-delivery/04-e2e-test-plan.mdand its zh-CN mirror.apps/desktop/test/radial-menu.test.mjs;settings-roundtrip.test.mjsnow covers normalization and rejection on both sides.packages/i18nkey-parity and renderer-key checks pass.Validation
pnpm --filter @pi-desktop/desktop typecheck— passpnpm --filter @pi-desktop/desktop build— passpnpm --filter @pi-desktop/desktop lint(style tokens) — passpnpm --filter @pi-desktop/i18n test— 31 passnode --testonradial-menu,settings-roundtrip, and the threechat-context-menusuites — 27 passpnpm test:e2e:radial-menu— pass. The probe renders the real component in Chromium and checks the four labels, pointer highlight, click and hub paths, the disabled sector, Escape, arrow-key focus, and viewport clamping.node --test test/*.test.mjs— 4423 pass, 2 fail, both environmental: the SSH askpass test reads this shell'sSSH_ASKPASS=/usr/bin/false, and one MCP slow-server timeout passes when the file is rerun alone.pnpm check:pr-base— head is the base (5aa253883c4e)Manual run (macOS dev build, seeded local session)
Risks and gaps
E2E-CHAT-radial-background-menupath through a real session and Settings is not automated.radialMenuis not added to the host-core portable application fields, so config sync would not carry this preference between machines. Say the word if that is in scope for this change.