Skip to content

Plugin API: selection-action slot for the diff and file-preview selection menus #7013

Description

@kolsha

The workflow

A plugin wants to add an item to the text-selection menu in the code-review diff and in the file preview — the same way messageAction contributes items to the timeline selection menu. Motivating case: the side-chat plugin's "Reply in side chat" on review selections (#6166) — quote a selected diff hunk into a side chat. #3342 (reply to selected Markdown in the document preview) is the same shape on another surface.

What happens today

A plugin cannot add an entry to the diff or file-preview selection menus at all:

  • The only selection-capable slot is messageAction. Its context documents selectedText as "the exact text the user highlighted inside message" (app-contract.ts#L3451-L3468), so it is defined only for timeline messages.
  • All three surfaces render the same shared menu component, TimelineSelectionMenu, which already accepts a pluginActions prop (TimelineSelectionMenu.tsx#L38) — but only the timeline call site passes them. The diff menu (PierreLineSelectionActions.tsx#L563) and the file-preview menu (SecondaryPanelSelectionActions.tsx#L260) expose only the core onSelectionAddToChat callback and pass no plugin actions.
  • The only escape hatch is experimental_diffRenderer — replacing the entire diff renderer (virtualization, lazy patch loading, highlighting) to own one menu item. Not practical.

What you would expect

A versioned slot analogous to messageAction, but for content surfaces instead of timeline messages:

app.slots.experimental_selectionAction({
  id: "reply-in-side-chat",
  label: "Reply in side chat",
  icon,
  surfaces: ["diff", "file-preview"],
  isEnabled?: (context) => boolean,
  run: (context) => void | Promise<void>,
});

// context: {
//   selectedText: string;
//   surface: "diff" | "file-preview";
//   threadId: string | null;   // owning thread for a review diff; null for a plain file preview
//   filePath?: string;
//   experimental_panel: ...;   // same panel handle messageAction gets
// }

Acceptance criteria:

  • Registered actions render in the existing diff and file-preview selection menus after the built-in entries, reusing the pluginActions mechanism TimelineSelectionMenu already has; ordering across multiple plugins follows the same rules as timeline plugin actions.
  • run receives the exact selected text, the surface kind, the owning thread id when the surface belongs to a thread, and the file path when known.
  • Per AGENTS.md, the new SDK member ships experimental_-prefixed with a docs/api_to_audit.md entry, and is listed in plugins/plugin-api-docs/src/surfaces.ts with a Plugin Guide example.
  • Unit tests cover that a registered action appears in each surface's menu and receives the correct context, mirroring the existing TimelineSelectionMenu plugin-action tests.

Context and alternatives

  • Add "Reply in side chat" to code-review (git-diff) selections #6166 has a working core prototype and an open design question — "drive the side-chat plugin id + its RPC from core, or prefer a generic selection-action surface?". This slot is the generic answer: with it (plus composer-draft targeting, filed separately as its own issue) "Reply in side chat" from review becomes a pure plugin feature with zero core↔plugin-id coupling, and the same slot unblocks Reply to selected Markdown text without leaving the document preview #3342 and any future selection-driven plugin.
  • Ruled out: experimental_diffRenderer (full renderer rewrite for one menu item); messageAction (documented and implemented as timeline-message-only).
  • All code references are at main d060de8e30f3310417054a74510a774dd2909e2b.

Checks

AGENT GENERATED

Activity

  1. added
    plugins
    on Nov 4, 2026
  2. bb-slop-cop commented on Nov 4, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied classification:

    • Type: Feature
    • Priority: Medium — useful plugin capability with limited scope and existing core selection actions.
    • Effort: High — introduces a public SDK interaction surface across multiple content menus, with context contracts, documentation, and tests.
    • Labels: plugins

    All classification fields were previously unset; no existing values were replaced. Final Type verified as Feature. Reproduction report and fix skipped; no pull request because this requests new functionality rather than correcting unexpected behavior.

    AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugins

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions