Then read the relevant spec for the area you are changing (see table below). If you modify the implementation, you must update the corresponding spec to keep it in sync.
Whenever the user flags a wrong pattern, rejects an approach, or gives design/rules feedback, automatically add it as a concise pitfall/learning to this Common Pitfalls section (or the most relevant spec doc) in the same change — without being asked again. Keep each entry 1–3 sentences: the anti-pattern, why it is wrong, and the preferred pattern.
-
Default/main chat title persistence differs per provider — don't unify them: For the agent host, the default (main) chat title is independent of the session title (AgentHostSessionAdapter._defaultChatTitleOverride, persisted on the host as customChatTitle:<defaultChatUri>); it must be seeded back on restore via restoreSession/_ensureDefaultChat (mirroring _restorePeerChats), or it reverts to the session title after a process restart / idle eviction. For the local chat sessions provider (localChatSessionsProvider), the primary chat and the session intentionally share one _title observable, so renaming the first/main chat updates the session title live — this is by design; do not "fix" it to be independent. Only additional (non-primary) local chats have their own title.
-
ISession.capabilities must be observable, not a live plain getter: capabilities can hydrate/change after a session first surfaces (e.g. an agent host whose root state arrives after the session's first SessionState). A plain getter cannot be tracked by the context-key autorun (setActiveSessionContextKeys reads it inside an autorun), so supportsMultipleChats/sessionSupportsFork would stay stale, and a multi-chat catalog processed while supportsMultipleChats was still false would stay collapsed to [defaultChat]. Expose capabilities as IObservable<ISessionCapabilities> (agent host derives it from connection.rootState via observableFromEvent + derivedOpts with structuralEquals; static providers use constObservable), have consumers read .read(reader)/.get(), and re-apply the chat catalog from the last SessionState in an autorun on capability change. Do not fix this by firing _onDidChangeSessions — the active-session context autorun tracks the session's own observables, not the provider's session-list event.
-
A managed/default editor tab must be re-ensured every sync, not opened once: the per-session editor working-set restore (baseSessionLayoutController [B2] _applyWorkingSet) runs on session activation and is not docked-gated, so it reinstates the session's saved editor set and will close any tab not in it (e.g. a set persisted before a new tab existed). A controller that opens a default tab once (guarded by a Set of initialized sessions) therefore loses it permanently after the restore. Ensure managed tabs (the pinned Changes tab, the default File tab) idempotently on every sync (group.editors.some(e => e instanceof X) → open if absent), exactly like the Changes tab — never with an open-once Set. Also: IEditorService.openEditor(input, group) on a typed EditorInput binds group to the options param (overload is (editor, options?, group?)); pass openEditor(input, undefined, group).
-
A "keep the editor closed" rule must not react to the editor's visibility transition: the single-pane new-session rule (R1, _registerSinglePaneNewSessionRules) must drive its hide off the session + active editor, never off onDidChangePartVisibility/an editorVisibleObs. onWillOpenEditor reveals the editor before the opened file becomes the active editor, and toggling the detail panel off reveals the empty editor via setAuxiliaryBarHidden — both fire the visibility event synchronously with the active editor still stale (managed empty tab). A rule that re-runs on that transition re-hides the editor the user just asked to show (file never appears; the whole side pane vanishes on detail-toggle). Hide only when the active editor is non-real content, read the current visibility untracked when deciding to hide, and block spurious width-based reveals at the source with setSuppressDockedEditorRevealSync(true) rather than a visibility backstop. Refinement: dropping the visibility trigger entirely loses the backstop for automatic post-activation reveals (working-set restore, an editor left visible across a session switch), so the editor can appear in a fresh new-session view. Keep the visibility trigger but gate the hide on an explicit-reveal flag: the workbench records _editorRevealedExplicitly (set true only on onWillOpenEditor and the detail-toggle reveal, cleared on any hide and on the suppress false->true transition so a stale cross-session flag can't leak) and exposes isEditorRevealedExplicitly(); R1 re-hides only when the editor is visible and the reveal was not explicit.
-
When the docked editor is hidden while the detail stays visible, clear the sidebar-grow snapshots: hiding the editor resizes the docked node down to the detail width (_dockedAuxiliaryBarWidth). Any _editorSizeGrownForSidebarHide/_detailWidthGrownForSidebarHide snapshot captured earlier (while the editor was visible and the sessions list was hidden) is now stale — restoring it when the sessions list is later shown re-inflates the node so the detail fills the whole side pane instead of the chat reclaiming the freed editor width. setEditorHidden(true) must drop both snapshots in the detail-still-visible branch.
-
Overriding a workbench toolbar hover needs matching specificity: the core rule .monaco-workbench .monaco-action-bar:not(.vertical) .action-label:not(.disabled):hover (and the :hover outline rule) sets the toolbar hover background/outline at ~6-7 class specificity. An action-item label that needs to override that hover (either to suppress it for a non-interactive label, or to re-skin it) must use an equal-or-higher-specificity selector (prefix .monaco-workbench ... .monaco-action-bar:not(.vertical) .action-item.<class> .action-label:hover), not a short .<class> .action-label:hover that loses the cascade. (The single-pane diff-stats pill was once suppressed this way while static; it is now a clickable action that opens the multi-file diff, so it keeps the standard --vscode-toolbar-hoverBackground hover.)
-
A docked-detail editor must not reveal the editor area while the detail panel is already showing its content — model it as a base editor input the single-pane workbench recognises: the empty Files placeholder (EmptyFileEditorInput) and the Changes multi-diff (SessionChangesEditorInput) surface their content in the docked detail panel (auxiliary bar). Activating one (closing a neighbouring tab so the workbench auto-opens the next editor via editorGroupView.doCloseActiveEditor → doOpenEditor, or clicking the tab) fires onWillOpenEditor unsuppressed and would otherwise reveal the hidden editor area. Both inputs extend the abstract base DockedEditorInput (src/vs/sessions/common/dockedEditorInput.ts, extends EditorInput). The base Workbench.revealEditorOnOpen(e) (the onWillOpenEditor handler — a protected method, renamed from _handleWillOpenEditor) does the generic reveal; SinglePaneWorkbench overrides revealEditorOnOpen and returns early (no reveal) when e.editor instanceof DockedEditorInput && partVisibility.auxiliaryBar && !partVisibility.editor — i.e. only when the detail panel is open and the editor area is closed — otherwise it calls super.revealEditorOnOpen(e). So the docked-editor policy lives in SinglePaneWorkbench (the only workbench with a docked detail panel) via a proper type + the current part visibility, not a per-input marker, a contrib-registered predicate, or a remembered set. Note the condition means that when the detail panel is closed (whole side pane closed), opening a docked editor does reveal the editor area so its content is visible. Caveat: a deliberate open of the already-open Changes tab (session-header pill ViewAllChangesAction) or a file diff (_openMultiFileDiffEditor) while the detail panel is open is still suppressed by this rule, so those must explicitly reveal via revealEditorPartExplicitly() before opening (revealing before the open also avoids the multi-diff hanging while laid out in a hidden 0-size editor part). Keep revealEditorOnOpen a named protected method so it is unit-testable via Reflect.get(...prototype, ...).
-
Gate single-pane editor-title layout/view actions on MainEditorAreaVisibleContext; the Create Pull Request bar lives in the title bar, not the editor: single-pane (config.<DOCK_DETAIL_PANEL_SETTING>-gated) editor-title layout/view items (Maximize/Restore, Toggle Details, Hide Editor, Open in Modal, the diff-view actions collapse/expand/toggle-inline/list-tree) must include MainEditorAreaVisibleContext so they disappear when the editor content is closed. The Create Pull Request anchor (CHANGES_HEADER_ACTIONS_ID) is not an editor-title action: it is contributed to Menus.TitleBarSessionMenu (the sessions title bar's session-actions area) by ChangesHeaderActionsAction in changesViewActions.ts, gated on IsSessionsWindowContext + IsAuxiliaryWindowContext.toNegated() + config.<DOCK_DETAIL_PANEL_SETTING> + SessionHasChangesContext (independent of editor-area visibility), and its ChangesActionsBar view item is registered for (Menus.TitleBarSessionMenu, CHANGES_HEADER_ACTIONS_ID) via IActionViewItemService. The docked reveal-sync (_syncDockedEditorVisibility) must be symmetric: it reveals when the node widens past the detail width and hides (sets partVisibility.editor=false, flips MainEditorAreaVisibleContext) when a sash drag squeezes the editor content back down to the detail width — same guards (_syncingDockedEditorVisibility, _suppressDockedEditorRevealSync, _dockDetailPanel, and only while the detail is visible).
-
The managed Files placeholder tab is conditional, not always-on: SinglePaneManagedTabsStrategy opens the empty Files placeholder (with the Changes tab) only when the editor group is empty on a view-open trigger (see the "add only when the group is empty" pitfall below), and removes it while a real (non-managed) file/diff is open in a visible editor area. It is not re-added when that file closes — the defaults return only when the group empties and the side pane is reopened. Drive the removal as a one-shot reaction on onWillOpenEditor (a genuinely new real-file open — skip re-activations where group.contains(editor) is already true, non-main-part groups, and restore-driven opens), not a standing autorun/editor-change invariant (that would re-remove a Files tab the user just added via +). Close/open the placeholder under suppressEditorPartAutoVisibility().
-
A per-session aux-bar (detail) capture must be skipped during a session-switch restore: the D2 onDidChangePartVisibility listener that records a created session's detail visibility must bail while _isRestoringSessionLayout is true. During restore an external component (e.g. DetailPanelController) can transiently reveal the aux bar for the incoming active editor; capturing that overwrites the session's saved detail-hidden state, so switching back shows the detail even though the user had closed it. Keep the aux-bar sync work synchronous (fire-and-forget the view-open calls) so the restore epoch ends promptly and legitimate post-restore user toggles are still captured.
-
The detail-panel forced reveal must be gated on the editor content being visible: DetailPanelController._syncForcedTarget reveals the docked detail (aux bar) when a Changes/File editor becomes active while the detail is hidden. That reveal must additionally require isVisible(EDITOR_PART, mainWindow) — otherwise, on a window reload where the user had closed the whole side pane (editor + detail both hidden, persisted), the restored managed tab becoming active re-reveals the detail and the closed state is lost. Reveal the detail only to accompany a visible editor; when the whole pane is intentionally closed, leave it closed.
-
Auto-managed tabs stay user-closable via "add only when the group is empty" — not a dismissal set: SinglePaneManagedTabsStrategy owns the managed Changes/Files docked tabs. They re-ensure on many signals (session state, editor visibility, editor changes), so naively re-creating them makes a close feel un-closable (they are non-preview pinEditor, NOT sticky — they do have close buttons; the blocker is the re-ensure). The clean rule that needs no _dismissedManagedTabs bookkeeping: open the default tabs only when the editor group is completely empty (group.editors.length === 0), and only on a "view opened" trigger — a session switch (the add-allowed session-state autorun) or the layout service's onDidRevealSidePane event (fired by the workbench whenever the docked editor part and/or aux-bar detail transitions from fully hidden to visible). A plain editor-list / visibility change reconciles (e.g. removes the Files placeholder while a real file is open) but is add-disallowed. Why this is close-respecting for free: closing one managed tab while another (or a real file) remains leaves the group non-empty → not re-added; closing the last one closes the side pane → reopening it (empty group) restores the defaults. Opening a file fires onDidRevealSidePane too, but the sync is deferred on the docked-tab sequencer (which runs after onWillOpenEditor has added the editor), so the group is non-empty when it runs → defaults are not forced back → closing that file still closes the side pane. The add-disallowed editor-change trigger is essential: without it, closing the last tab (group empty) would immediately re-add the defaults and the pane could never close. The layout-driven add is done on the settled restore, not during it: the base controller fires onDidEndSessionLayoutRestore when the restore depth returns to 0 (after the — possibly async — working-set apply completes), exposed via ISinglePaneLayoutContext; the strategy reconciles off that ([Trigger D], openDefaultsIfEmpty: true). This is required for a new session, whose empty working set closes the previous session's docked tabs after the switch — reading the group during the async apply (an editor-change trigger) races the empty state and drops the Files tab; reconciling on the settled restore-end reads the reliably-empty group. Do not gate the add on isRestoringSessionLayout captured in the editor-change autorun — that fires mid-apply and is fragile. A user file-open/close is not a restore, so it stays add-disallowed and a close still sticks. One exception — new-session submit: when the active session transitions isCreated false → true (in place, or via a resource-replace commit), the new-session view already holds the Files placeholder, so the empty-group rule would skip opening Changes; the submit transition is treated as a one-shot "ensure the Changes tab (pinned first, opened active)" even when the group is non-empty — opening it active (not inactive) is what makes the detail panel map to the Changes container rather than the still-present Files placeholder; it is a genuine one-time transition, so it never fights a later user close. Because submit fires two triggers (the session-state autorun's ensureChangesActive and, via the submit restore, onDidEndSessionLayoutRestore's Trigger D), a single shared generation counter would let the later trigger's reconcile supersede and drop the earlier's intent — so the triggers' intents are accumulated (mergeTriggers, OR-combined into a pending trigger consumed by the surviving reconcile, re-merged in finally if superseded mid-run) rather than replaced. Scope the pending intents to the session they were queued for (IPendingReconcile.sessionKey = the active session resource): a reconcile can be superseded mid-await (e.g. it stalls opening the Changes editor) by a session switch; if the superseded reconcile's finally merged its old trigger back unconditionally, an ensureChangesActive/ensureAllInputs intent for session A would leak onto session B and reopen a user-closed tab or activate Changes for the wrong session. Merge back (and accumulate on queue) only when the successor targets the same sessionKey; a session switch drops the previous session's stale intents. Second exception — a details-only reveal: when onDidRevealSidePane fires with the aux-bar detail panel visible but the editor area hidden (isVisible(AUXILIARYBAR_PART) && !isVisible(EDITOR_PART)), the docked details panel shows the managed docked inputs, so they are ensured (Changes if created + Files) even when the group is non-empty — restoring one the user had closed earlier. This is tied to the reveal gesture (a close within an open details view still sticks until the next reveal); an editor-included reveal keeps the strict empty-group rule. Do NOT re-introduce a _dismissedManagedTabs set, an onDidCloseEditor dismissal listener, infer the reopen from aux-bar visibility, or gate on a generic "side pane became visible (editor || aux)" check. The empty Files placeholder is tidied away when a real workspace file opens — a one-shot reaction on onWillOpenEditor (a real file/vscode-remote input, skipped during a restore), not a standing "no placeholder while a real file is open" invariant enforced every reconcile. The standing invariant broke + Files: adding the placeholder while a file was open re-triggered the reconcile which immediately removed it again. Because + Files opens an EmptyFileEditorInput (not a real file), the one-shot listener ignores it, so a user-added Files tab survives while a real file is open (a tidy [Changes][file] strip still results from a real-file open).
-
Editor-area collapse (closing non-docked tabs) fires only on a detail-only hide, never when the whole side pane closes: SinglePaneEditorAreaCollapseStrategy reacts to the editor part hiding by closing every non-docked editor (capturing reopenable ones, dropping non-restorable ones). It must gate that on the aux bar still being visible (isVisible(AUXILIARYBAR_PART)): a Detail-only hide (Hide Editor keeps the detail) collapses the editors, but closing the whole side pane (both editor + aux hidden) must leave the editors intact so they return when the pane is reopened. The gate is reliable because the two hide paths order their setPartHidden calls consistently — toggleSidePane hides the aux bar before the editor, so when the editor-hidden event fires the aux is already hidden (⇒ skip collapse); Hide Editor sets the aux visible before hiding the editor (⇒ aux visible ⇒ collapse). Don't collapse purely off "editor part hidden" — that also dropped dirty/non-restorable editors when the user just closed the side pane.
-
D10 (empty aux-bar cleanup) must gate on quick-chat, not the racy container-active check, or it flickers the side pane closed on reload: the Agents-window Changes/Files aux-bar views gate on SessionHasWorkspaceContext + WorkspaceFolderCountContext, which are set asynchronously (via the setActiveSessionContextKeys autorun reading the session's async workspace) after a session activates/reloads. So right after D3b/DetailPanelController/a manual toggle reveals the aux bar, isViewContainerActive(Files/Changes) is transiently false (context keys not settled) even for a real workspace session. The D10 reconcile (_syncAuxiliaryBarPartVisibility, which runs synchronously on the onDidChangePartVisibility(visible) signal and only ever hides) then closes the just-opened side pane, and since it never re-reveals, it stays closed — the reload "side pane opens then closes" flicker, "Files not shown when opening the side pane", and "new-session side-pane state not remembered". Fix: D10 hides only when the aux is genuinely empty for the active session's lifetime — no active session, or a workspace-less quick chat (activeSession.isQuickChat?.get() === true, its Changes+Files permanently gated off) — never for a workspace-backed session whose gating context keys are merely still settling. Do NOT use the transient _hasActiveAuxViewContainers() result to hide a workspace session's aux.
-
DetailPanelController must not hide the detail on an empty editor group in the new-session view: _computeTarget returns Hidden when the main editor part is empty (a created session's all-tabs-closed → whole side pane closed). But the new-session (uncreated) view's editor group is transiently empty while its Files tab is (re)ensured, and its Files detail is open by default and owned by the layout controller's D3b. Gating the empty-group Hidden on activeSession.isCreated avoids a transient hide that the D2 visibility listener would otherwise capture as the new-session preference — making every subsequent cmd+n open with the side pane hidden. Combined with the editor-visibility reveal gate, the new-session default stays open while a user's explicit hide is still remembered (D3b _newSessionViewState).
-
Tool result text is fed to the model, which may drop or reformat markdown links (e.g. render a session URI as an inline code span), so an explicit [label](uri) in a tool result is NOT a reliable way to give the user a clickable action.
-
For a deterministic, client-rendered action (a "pill"/button) tied to a specific tool call, set toolSpecificData on the ChatToolInvocation in stateToProgressAdapter.ts (keyed on the tool name + parsed result) and add a custom subpart in chatToolInvocationPart.ts — the completed-state section already routes custom toolSpecificData kinds (see resources/simpleToolInvocation). Follow the agentFeedbackReviewConfirmation pattern.
-
Managed-tab reconciliation must run entirely under suppressEditorPartAutoVisibility(): SinglePaneManagedTabsStrategy._reconcileCore closes stale/foreign managed tabs (e.g. a restored Changes tab whose session's workspace hasn't resolved yet on reload) via _closeForeignChangesEditors before ensuring the current ones. If any close runs unsuppressed and empties the group, the workbench handleDidCloseEditor docked branch treats it as "user closed all tabs" and closes the whole side pane — the reload flicker where the side pane appears then vanishes. Wrap the full reconciliation body in one suppression window so transient empty states are never mistaken for a user action; don't rely on per-open suppressions alone. (Historical note: the managed Files placeholder was once removed/re-added reactively with a _dismissedManagedTabs set; that bookkeeping is gone — see the "add only when the group is empty" pitfall.)
-
Layout-driven editor closes (working-set apply) must not be mistaken for user closes: On any single-pane session switch (incl. Cmd+N to a new untitled session and reload), the base controller applies the target session's editor working set — an empty working set closes the managed Changes/Files tabs externally. The workbench handleDidCloseEditor docked branch would otherwise see the empty group and close the whole side pane (reload/Cmd+N flicker: pane/Files-tab appears then vanishes). Fix: _withSessionLayoutRestore (base controller) holds suppressEditorPartAutoVisibility() for the whole (async) restore only when isSinglePaneLayoutEnabled (OFF layout unchanged), so layout-driven closes never reach handleDidCloseEditor. suppressEditorPartAutoVisibility() on IAgentWorkbenchLayoutService returns the IDisposable suppression window; the boolean it toggles is observed internally through the Workbench's protected _isEditorPartAutoVisibilitySuppressed getter. (Historical note: this fix also once protected a _dismissedManagedTabs set from being poisoned by external closes; that set no longer exists — managed tabs are now re-populated purely by "add only when the group is empty on a view-open trigger".)
-
DetailPanelController must not force-reveal the detail during a layout-driven restore: _syncForcedTarget reveals the aux-bar detail to accompany the active Changes/Files editor. On a session switch the target session's editor working set is restored, making its Changes/Files editor active — an editor change that is NOT a user open. If the user had hidden the detail for that session, that restore-driven editor change would force-reveal it, losing the per-session detail-hidden state. Gate the reveal (setPartHidden(false, AUXILIARYBAR)) on !isEditorPartAutoVisibilitySuppressed() (in addition to the existing editor-visible guard): during _withSessionLayoutRestore the base controller holds suppressEditorPartAutoVisibility() (single-pane), so a restore-driven forced target skips the reveal while a genuine user editor open (unsuppressed) still reveals. Note the existing [D3c/single-pane] test passed because it simulated the reveal synchronously during apply (so D3 re-hid last); the real bug is the async DetailPanelController reveal firing on the editor-change after D3 already hid.
-
The width-based docked reveal-sync (_syncEditorVisibility) must bail while editor-part auto-visibility is suppressed: SinglePaneWorkbench._syncEditorVisibility reveals/hides the docked editor purely from the node width (for user sash drags). A session-switch / reload layout restore holds suppressEditorPartAutoVisibility while it applies the working set, which can widen the docked node before the controller has set the target editor-part visibility. Because the width-sync ran regardless of suppression, restoring a Detail-only session (aux open, editor closed) flickered the editor open on switch (the working-set apply widened the node → reveal → the controller then re-hid it) and could persist it open on reload. Gate _syncEditorVisibility on !this._isEditorPartAutoVisibilitySuppressed (alongside the existing _syncingEditorVisibility reentrancy guard) so only a real user sash drag (unsuppressed) drives width-based visibility. Relatedly, baseSessionLayoutController._applyWorkingSet's isInitialRestore branch must, for single-pane, apply _shouldHideEditorPartOnApply(editorPartHidden) after the working-set apply (a no-op for the classic layout) — otherwise a Detail-only session's persisted editor-hidden state is not re-applied on reload and the editor is left visible.
-
Single-pane detail (aux bar) ownership is split cleanly in two — visibility vs content — never three overlapping aux strategies: in single-pane the auxiliary bar is the detail panel, so exactly two strategies touch it, with non-overlapping responsibilities. SinglePaneDetailVisibilityStrategy owns only per-session shown/hidden memory: it captures the user's choice ([D1]/[D2]), restores it on switch ([D3]) by revealing/hiding the aux part (setPartHidden / hideAuxiliaryBarForRestore), and handles the submit transition ([D4]). SinglePaneDetailPanelStrategy owns everything about content: which container (Changes/Files, mapped from the active editor), the transient browser-tab hide, editor-maximize → Changes, and the "nothing to show" hide (quick chat / no workspace / empty group → Hidden). Do NOT reintroduce a separate EmptyAuxCleanup/D10 strategy or desktop's saved-container machinery (auxiliaryBarActiveViewContainerId restore, _openDefaultAuxiliaryBarContainer, _restoreSavedAuxiliaryBarContainerOnReveal, pinned-container checks) into the visibility strategy — the container always follows the active editor, so a stored container preference is redundant and races the detail-panel mapping. Because the visibility strategy reveals the part and the detail-panel strategy fills it, the detail-panel strategy registers immediately in _registerViewStateManagement (not deferred to Restored like the managed tabs), so a reveal and its container open happen in the same turn.
-
Single-pane is a sibling of the desktop controller and composes strategy objects — it does not extend LayoutController: SinglePaneLayoutController (file contrib/layout/browser/singlePaneLayoutController.ts) extends BaseLayoutController directly, NOT the classic desktop LayoutController, so the desktop controller can be deprecated/deleted without touching single-pane. Its behaviour is composed from strategy objects under contrib/layout/browser/singlePane/ (each a Disposable, created via createInstance with a leading ISinglePaneLayoutContext arg): SinglePaneDetailVisibilityStrategy (per-session detail shown/hidden: D1/D2/D3/D4) and SinglePaneDetailPanelStrategy (container + maximize + browser-hide + nothing-to-show hide) — the detail split above; SinglePaneManagedTabsStrategy + SinglePaneEditorAreaCollapseStrategy (share a SinglePaneDockedTabsCoordinator holding the tab Sequencer, collapsedEditors, and the getChangesEditorResource helper; docked (managed) tabs are identified by instanceof DockedEditorInput); SinglePaneQuickChatEditorHideStrategy; SinglePaneResponsiveSidebarStrategy (owns the Toggle Details action + sidebar auto-hide); SinglePaneNewSessionRulesStrategy (R1). Shared controller state (isRestoringSessionLayout, withSessionLayoutRestore, togglingSidePane, the obs, viewStateBySession, hidingAuxiliaryBarForRestore/hideAuxiliaryBarForRestore) is exposed to strategies through ISinglePaneLayoutContext (built lazily in the controller because base's constructor calls the _registerViewStateManagement/_registerAuxiliaryControllers hooks before subclass field initializers run). The detail-visibility/detail-panel/responsive/R1 strategies register in _registerViewStateManagement; the managed-tab/collapse/quick-chat strategies register in _registerAuxiliaryControllers deferred to LifecyclePhase.Restored. Fresh storage: single-pane persists to sessions.singlePane.layoutState + sessions.singlePane.newSessionViewState (base _layoutStateStorageKey/_legacyWorkingSetsStorageKey are overridable; single-pane skips legacy migration), so it never shares state with the classic desktop controller — the test harness seeds both keys.
-
Single-pane detail/tab behaviour lives ON the layout controller (or its strategies), not in separate contribution controllers or a shared service: SinglePaneLayoutController owns both the managed docked tabs (pinned Changes multi-diff + empty Files placeholder) and the detail-panel mapping (active editor → Changes/Files container, aux-bar reveal/hide). They were previously ChangesTabController/DetailPanelController (registered by a SinglePaneModeController contribution) coordinating via global IAgentWorkbenchLayoutService flags, then briefly via an ISessionLayoutCoordinatorService. Both were removed: "is a session-switch restore in progress?" is just the base protected getter this._isRestoringSessionLayout (set by _withSessionLayoutRestore) — surfaced to the strategies via ISinglePaneLayoutContext.isRestoringSessionLayout — so a restore-driven editor change never force-reveals the detail or dismisses a managed tab. The base controller has IChangesViewService + IContextKeyService deps and a protected _editorGroupsService (a subclass can't add DI ctor params without redeclaring all base params, so shared services live on the base). Tests: the layout harness got activeGroupEditors/closeSuppressionFlags, a real mainPart.activeGroup, an activateAux opt-in that resolves the lifecycle, and a TestSinglePaneController.runWithRestore(...) seam to hold _isRestoringSessionLayout across an async editor change; changesTabController.test.ts was deleted and its scenarios moved into desktopSessionLayoutController.test.ts.
-
Single-pane created-session default is Editor-only (Changes editor, detail closed) — the detail is not force-opened by editor activation: a Changes/file editor becoming active must NOT auto-reveal the docked detail (aux bar). SinglePaneDetailPanelStrategy._syncForcedDetailTarget reveals a hidden detail ONLY when it was transiently hidden by a browser tab (_hiddenByBrowser), never when it is hidden by the per-session default or an explicit user hide; when the detail is visible it still switches the container (Changes/Files) to match the active editor. Exception — opening the empty Files placeholder (EmptyFileEditorInput) reveals the Files detail (its content, the Files tree, lives in the aux bar). This is a dedicated onDidActiveEditorChange listener in the strategy that reveals the aux bar when the placeholder becomes the active editor — NOT reactive logic inside the detail autorun (which re-reads auxBarVisibleObs, so it would re-reveal the instant the user hides the detail — bug: "can't hide the details view in the empty file editor at all"). Keying on active editor (not onWillOpenEditor) is deliberate: the managed auto-ensured Files tab is opened inactive as a background tab (fileTabOptions), so it never becomes active and never reveals — preserving the Editor-only default — while the + Files action and selecting the Files tab both make it active and reveal. Do NOT reveal from the NewFileTabAction instead: that misses tab-selection and other activation paths (tried and rejected — "does not work"). The listener is guarded by isVisible(EDITOR_PART) (don't reveal the detail alone while the whole side pane is closed, e.g. Scenario C reload) and !ctx.isRestoringSessionLayout (a restore-driven activation must not reveal). Because hiding the aux bar fires onDidChangePartVisibility, not onDidActiveEditorChange, the user's hide sticks while the placeholder stays active. Do NOT reintroduce a DetailPanelTarget.FilesReveal in the autorun or an isEditorPartAutoVisibilitySuppressed() layout-service API — the active-editor listener needs neither. The reopen default is layout-aware via the base _defaultReopenSidePaneParts() hook. When changing this, update the [single-pane] reveals the Files detail when the empty Files placeholder becomes active and [Scenario C] tests together.
-
Editor-title actions that only make sense with a restorable editor must also gate on EditorMaximizedContext.negate(): the single-pane "Hide Editor" action is meaningless while the editor area is maximized, so its when includes EditorMaximizedContext.negate() (in addition to MainEditorAreaVisibleContext + HasDockedDetailsContext).
-
R1 (new-session editor hide) must be transition-triggered, not level-triggered on the active editor: hiding the editor in the new-session view must fire only when the editor just became visible (visibility false→true) or when the view was just entered with the editor already visible (inherited-visible editor) — never merely because the active editor changed to a managed placeholder while the editor is already visible. A level-triggered rule ("hide whenever active editor is non-real content and editor visible") wrongly hides the editor when the user switches to the Files tab with a file already open (the reveal-sync suppression re-arm clears isEditorRevealedExplicitly, so the level rule then hides). Track previousEditorVisible + previousInNewSessionView in the autorun and hide only on (editorJustRevealed || justEnteredNewSessionView) && !isEditorRevealedExplicitly(). The two workbench methods setSuppressDockedEditorRevealSync (blocks width-based reveals at the source, avoiding flicker) and isEditorRevealedExplicitly (distinguishes an explicit toggle-details-off/file-open reveal that must stick) are still required by R1 — they are independent of the ChangesTab/DetailPanel controller merge.
-
Single-pane created sessions need the docked editor part revealed on switch — the isModal gate in _applyWorkingSet skips it: baseSessionLayoutController._applyWorkingSet only reveals the editor part when !isModal (i.e. workbench.editor.useModal !== 'all'), because in the classic layout editors open in a modal part. But in single-pane the docked editor lives in the grid even when useModal is 'all' (the default), so that gate wrongly skips the reveal and a created session's side pane looks fully closed (worse once the Changes editor no longer force-reveals the detail). Fix: compute revealEditorPart = !editorPartHidden && !isInitialRestore && (isSinglePaneLayoutEnabled ? isCreatedSession : !isModal) and also reveal for the 'empty' working-set case in single-pane (a first-visit created session has no saved editors but still shows its managed Changes editor). This restores the Editor-only default while respecting the per-session editorPartHidden (Detail-only / side-pane-closed) state and excluding new-session views (R1 keeps their editor closed). Note the layout test harness leaves isSinglePaneLayoutEnabled falsy by default, so base single-pane branches are inert in tests unless a test opts in via the singlePaneLayoutEnabled create option.
-
A draft replaced by a committed session must inherit the draft's side-pane layout before _applyWorkingSet runs: some providers commit a new-session draft by firing onDidReplaceSession with a new session resource, not by flipping isCreated on the same resource. Without transferring the active draft's _editorPartHiddenBySession and aux-bar state, the committed resource has no saved layout, so the delayed B2 working-set apply treats it as a first-visit created session and reveals the editor (Editor-only default) even though the user submitted from the new-session Detail-only view. Handle the replacement event as D4 submit: copy the active draft's editor-hidden state to the committed resource, record Changes as the committed aux container, and open Changes only if the draft detail was visible; switching to an unrelated existing created session still uses the Editor-only default.
-
Single-pane D3c: a created session with NO saved detail state must be left in its current on-screen state — never force-hidden: the detail (aux-bar) restore for a created single-pane session (SinglePaneDetailVisibilityStrategy._syncDetailVisibility D3c) must only act when viewStateBySession has a saved entry — hide when it says hidden, reveal when it says visible. When there is no saved state (savedState === undefined), return without touching the aux bar. Force-hiding on the no-state path re-closes the detail the user had open in the new-session view on submit: the committed session's resource can change again after the initial draft→committed transition, so a later restore run lands in D3c with no saved state and previousIsCreated already true (the intrinsic !previousIsCreated && isCreated submit detection ([D4]) no longer matches), and would re-hide. Leaving the current state also covers a first-time-seen created session gracefully; the detail-panel strategy keeps the container in sync, and the visibility is captured on the next switch-away or user toggle. (The intrinsic [D4] submit routing to _onNewSessionSubmitted is still kept for the clean first transition — it records the state and opens Changes — but D3c-leave-current is the backstop for every follow-up run.)
-
A replace-based submit must be detected intrinsically in the aux/detail restore autorun (!previousIsCreated && isCreated), not via _onSessionReplaced: the same ordering trap as the editor reveal, but for the detail (aux-bar) visibility. sessionsService listens to onDidReplaceSession first (it's a core service) and its handler calls updateSession → sets activeSession in a transaction → the single-pane SinglePaneDetailVisibilityStrategy D3 restore autorun fires synchronously inside that handler. The layout controller's _onSessionReplaced (registered later, at BlockRestore) runs after — so any aux-state transfer it does is too late: the autorun has already run D3c. The classic same-resource isSubmit guard (!isSessionSwitch && !previousIsCreated && isCreated) misses this because the agent-host/Copilot provider commits by replacing the draft with a new resource (isSessionSwitch is true). Fix: relax isSubmit to previousSessionResource && !previousIsCreated && isCreated && !viewStateBySession.has(activeSessionResource) — detect the submit purely from the transition, independent of _onSessionReplaced ordering. The !has(state) guard keeps a genuine navigation from a draft to an existing created session on the normal D3 restore path. _onSessionReplaced then only needs to cover the background submit (a session committed while a different session is active, so the autorun never fires for it). Because the committed resource can still change again after the first transition, this intrinsic detection alone isn't enough — pair it with the D3c-leave-current rule above. General rule: for any "on submit, preserve/transfer layout" logic, detect the submit from the reactive transition the consumer already observes — never from a flag/transfer set by a separately-registered onDidReplaceSession listener.
-
onDidReplaceSession always means submit — never re-check from.status === Untitled, and never try to preserve visibility via a flag consumed by runOnChange: two related traps when suppressing the docked-editor reveal on new-session submit. (1) By the time onDidReplaceSession fires, the draft has already transitioned Untitled→Completed, so a _isNewSessionReplacement(from,to) guard checking from.status === SessionStatus.Untitled is always false and silently skips the whole editor-hidden/aux transfer. The event is documented to fire only when an untitled draft is atomically replaced by its committed session, so treat every onDidReplaceSession as a submit — no status guard. (2) The B2 working-set runOnChange (on the workspace-gated activeSessionForWorkingSet derive) fires before the synchronous onDidReplaceSession handler, so a boolean flag set in _onSessionReplaced and read synchronously in runOnChange is captured stale (false) and cannot suppress the reveal. The correct, ordering-robust mechanism is to have _onSessionReplaced write the draft's live editor-part visibility into _editorPartHiddenBySession[to] synchronously; because _applyWorkingSet reads that map inside its Sequencer.queue async microtask body (which runs after the sync replace handler), the reveal decision (_shouldRevealEditorPartOnApply/_shouldRevealEditorPartForEmptyWorkingSet) sees editorPartHidden=true and skips. Do NOT add a preserveEditorPartVisibility apply option keyed off event ordering — it's impossible to set in time.
-
R1 can drop setSuppressDockedEditorRevealSync — always hide on new-session-view entry instead: the width-based reveal-sync suppression (setSuppressDockedEditorRevealSync/_suppressDockedEditorRevealSync) was removed. It did two jobs: (1) block a momentary width-reveal of the editor in the new-session view, and (2) clear _editorRevealedExplicitly on entering the view so R1 re-hides an inherited-explicit editor across a session switch (the working-set apply runs under suppressEditorPartAutoVisibility, so handleDidCloseEditor doesn't clear the flag naturally). Job (1) is now handled by R1 re-hiding any non-explicit reveal (a sash-drag reveal flickers then re-hides — acceptable). Job (2) is handled by making R1's hide condition justEnteredNewSessionView || (editorJustRevealed && !isEditorRevealedExplicitly()) — i.e. entering the new-session view always resets to editor-closed (a stale cross-session explicit flag can't keep the editor open), while the explicit flag is only honored for in-session reveals (toggle-details-off revealing the empty editor). isEditorRevealedExplicitly is still needed for that in-session case.
-
Quick chats have no side pane — don't auto-reveal the editor part, and hide it when switching in from a session that had it open: in single-pane, SinglePaneLayoutController._shouldRevealEditorPartOnApply must exclude quick chats (!editorPartHidden && isCreatedSession && !isQuickChat); a created quick chat would otherwise reveal the docked editor part on switch (bug: "side pane opened automatically for quick chat"). Excluding the reveal is not enough — switching in from a workspace session leaves the editor part visible (the working-set apply is suppressed and never hides it), so a dedicated _registerQuickChatEditorHide() autorun hides the editor part while a quick chat's editor group is empty (gated on _isMainPartEmpty() so a real editor, e.g. the integrated browser, opened in a quick chat is never hidden). The aux bar is already handled by D10 + the detail-panel Hidden target.