Skip to content

Editor parts: several editor parts per window, and embedded editor parts - #345074

Closed
Sandeep Somavarapu (sandy081) wants to merge 3 commits into
mainfrom
agents/editor-parts-embedded
Closed

Sandeep Somavarapu (sandy081) wants to merge 3 commits into
mainfrom
agents/editor-parts-embedded

Conversation

@sandy081

@sandy081 Sandeep Somavarapu (sandy081) commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Infrastructure, no user-visible change.

Lets a window host several editor parts and lets a feature create editor parts of its own, embedded in its UI. It's the first infrastructure block for chat windows (#344666), which are behind sessions.chatWindows.enabled.

  • Several editor parts per window:
    • Scoped instantiation services are keyed by part instead of by window id.
    • getPart(element) resolves the part by ancestry first, then by document.
    • Owned (isTransient) parts are left out of persisted state, labels, working sets and window restore.
    • Webview and notebook clipping use the part that contains the editor.
    • The new OwnedEditorPart base class holds what the auxiliary editor part did, unchanged: closing a floating window's last group still activates the second most recently active group.
  • createEditorPart: creates an embedded editor part that a feature owns and lays out. bindEditorPartsToWindow ties such parts to an auxiliary window.
    • An embedded part keeps its last group.
    • Its groups have no Lock/Unlock Group, no Close Group for the only group, and no move into a new window.
    • These menus are gated on editorPartEmbedded, which is never set outside embedded parts, so they're unchanged everywhere else.

Nothing in VS Code creates an embedded part yet.

How to test

No UI change: floating editor windows, the modal editor, webviews and notebooks behave as before.

Validation (alone on main 6eb26fe)

  • npm run typecheck-client: passed at every commit
  • npm run build-fast -- --client-only: passed
  • ./scripts/test.sh --runGlob "vs/sessions/**/*.test.js": 9299 passing
  • ./scripts/test.sh --runGlob "vs/workbench/services/**/*.test.js": 2905 passing
  • ./scripts/test.sh --runGlob "vs/workbench/test/**/*.test.js": 733 passing

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved embedded-editor defects can dispose groups mid-batch, route editors and drops to the wrong part, and disrupt layout and owner notifications.

8 open issues
What changed in this PR

Adds infrastructure for multiple editor parts in one window and feature-owned embedded editor areas, preparing for chat windows in #344666. No feature creates embedded parts yet, so existing UI behavior is intended to remain unchanged.

Changes:

  • Adds embedded-part creation, scoped services, editor redirection and window-lifecycle binding.
  • Updates part lookup, persistence and clipping for multiple parts per window.
  • Gates embedded-part menus and adds lifecycle, routing and state tests.
File Description
src/​vs/​workbench/​test/​browser/​workbenchTestServices.ts Adds embedded-part API stubs.
src/​vs/​workbench/​test/​browser/​parts/​editor/​embeddedEditorPartMenus.test.ts Tests terminal menu gating.
src/​vs/​workbench/​services/​editor/​test/​browser/​modalEditorGroup.test.ts Tests part lookup within a shared document.
src/​vs/​workbench/​services/​editor/​test/​browser/​embeddedEditorPart.test.ts Tests embedded-part services, routing, state and lifecycle.
src/​vs/​workbench/​services/​editor/​common/​editorGroupsService.ts Defines embedded-part interfaces and creation options.
src/​vs/​workbench/​services/​editor/​browser/​editorPartWindowBinding.ts Binds embedded parts to auxiliary-window closure.
src/​vs/​workbench/​contrib/​webviewPanel/​browser/​webviewEditor.ts Uses the containing part for webview clipping.
src/​vs/​workbench/​contrib/​terminal/​browser/​terminalMenus.ts Hides panel-transfer actions in embedded parts.
src/​vs/​workbench/​contrib/​notebook/​browser/​notebookEditorWidget.ts Uses the containing part for notebook clipping.
src/​vs/​workbench/​common/​contextkeys.ts Adds the embedded-part context key.
src/​vs/​workbench/​browser/​parts/​editor/​ownedEditorPart.ts Extracts shared owned-part closing behavior.
src/​vs/​workbench/​browser/​parts/​editor/​embeddedEditorPart.ts Implements embedded parts and their factory.
src/​vs/​workbench/​browser/​parts/​editor/​editorParts.ts Adds per-part service scoping, lookup and persistence handling.
src/​vs/​workbench/​browser/​parts/​editor/​editorPart.ts Adds the transient-part marker.
src/​vs/​workbench/​browser/​parts/​editor/​editorGroupView.ts Redirects editor opens, moves and copies.
src/​vs/​workbench/​browser/​parts/​editor/​editor.ts Adds the editor-redirection contract.
src/​vs/​workbench/​browser/​parts/​editor/​editor.contribution.ts Gates group and window actions for embedded parts.
src/​vs/​workbench/​browser/​parts/​editor/​auxiliaryEditorPart.ts Reuses the shared owned-part implementation.

Review effort: Balanced

Several editor parts can live in one window, so assumptions of a single part
per window are replaced:
- scoped instantiation services are keyed by part instead of by window id
- `getPart(element)` resolves by ancestry first (strict descendants only, the
  container itself falls back to the document lookup) and then by document
- editor parts that are owned by someone else (`isTransient`) are excluded from
  persisted state, labels, working sets and window restore, and keep their
  position in the most recently active list when state is restored
- webview and notebook clipping use the part that contains the editor
- adds the `OwnedEditorPart` base class shared by owner-managed parts, which
  the auxiliary editor part now extends with unchanged behavior

Co-authored-by: Copilot <[email protected]>
…r parts

Adds `IEditorGroupsService.createEditorPart({ container, label?, groupViewOptions?, state?, primary? })`
which creates an editor part inside a container owned by the caller (for example a grid cell in
an auxiliary window). The part has its own scoped instantiation and editor services, is always
excluded from working sets, window restore and persisted state, and closes by merging
editors that need confirmation into the main part.

`primary` makes the part the active one for its window when focus is in no part.
`bindEditorPartsToWindow` ties the parts to an auxiliary window: it vetoes closing the window when an
editor cannot be moved and closes the parts on unload.

The part's own groups are laid out by its owner: an embedded part keeps its last group, also as closing all
its editors closes empty groups, and its groups (editorPartEmbedded) offer no Lock or Unlock Group, no Close
Group for their only group, and no moving of their editors into a new window or, for terminals, into the panel.
Elsewhere, editorPartEmbedded never holds, so these menus are unchanged.

`redirectEditor` limits the editors a part takes: an editor it does not take opens in the group of another
part that it returns, however the editor gets to the part (opened there, including as the active group or to
the side of one of its groups, moved, copied or dropped there), and a group of the part left without editors
that way is removed. The group views enforce it as they open, move and copy editors. Parts without it, such
as the main part, take every editor as before.

Co-authored-by: Copilot <[email protected]>
- openEditors routes each redirected editor to its destination group, with that group's indices and resulting pane, and removes a group left empty only after the whole batch
- announce every group of a part created with state
- getPart resolves the closest part, including the root of an embedded part
- release an embedded part after its onWillClose listeners were notified
- enforce no auto locking in embedded parts
- add the part and editor classes to the root of an embedded part

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants