sessions: make SessionChangesService resolvable without the workbench layout service

SessionChangesService is a DI singleton also instantiated in component fixtures / unit tests, which do not register IAgentWorkbenchLayoutService. Read the single-pane setting via IConfigurationService (available everywhere) instead, so resolving ISessionChangesService no longer fails with 'depends on layoutService which is NOT registered'. The layout service remains the single source of truth for contributions that run only in the real Agents window.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Sandeep Somavarapu
2026-07-04 02:04:50 +02:00
parent 12ee6fc384
commit 360944154d
2 changed files with 9 additions and 7 deletions

View File

@@ -6,10 +6,11 @@
import { URI } from '../../../../base/common/uri.js';
import { localize } from '../../../../nls.js';
import { createDecorator, IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { IMultiDiffEditorOptions } from '../../../../editor/browser/widget/multiDiffEditor/multiDiffEditorWidgetImpl.js';
import { IEditorService, PreferredGroup } from '../../../../workbench/services/editor/common/editorService.js';
import { IEditorGroup } from '../../../../workbench/services/editor/common/editorGroupsService.js';
import { IAgentWorkbenchLayoutService } from '../../../browser/workbench.js';
import { DOCK_DETAIL_PANEL_SETTING } from '../../../common/sessionConfig.js';
import { SessionChangesEditorInput } from './sessionChangesEditorInput.js';
export const ISessionChangesService = createDecorator<ISessionChangesService>('sessionChangesService');
@@ -61,7 +62,7 @@ export class SessionChangesService implements ISessionChangesService {
constructor(
@IEditorService private readonly editorService: IEditorService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IAgentWorkbenchLayoutService private readonly layoutService: IAgentWorkbenchLayoutService,
@IConfigurationService private readonly configurationService: IConfigurationService,
) { }
getChangesEditorResource(sessionResource: URI): URI {
@@ -93,7 +94,11 @@ export class SessionChangesService implements ISessionChangesService {
async openChangesEditor(sessionResource: URI, options?: IMultiDiffEditorOptions, group?: PreferredGroup): Promise<IEditorGroup | undefined> {
const multiDiffSource = this.getChangesEditorResource(sessionResource);
if (this.layoutService.isSinglePaneLayoutEnabled) {
// Read the setting directly (rather than via IAgentWorkbenchLayoutService) so this
// singleton also resolves in minimal environments — component fixtures / tests — that
// don't register the Agents-window layout service. The layout service remains the
// single source of truth for contributions that run only in the real window.
if (this.configurationService.getValue<boolean>(DOCK_DETAIL_PANEL_SETTING) === true) {
const input = this.instantiationService.createInstance(SessionChangesEditorInput, multiDiffSource);
const pane = await this.editorService.openEditor(input, { ...options, pinned: true }, group);
return pane?.group;

View File

@@ -25,7 +25,6 @@ import { IActiveSession, ISessionsChangeEvent, ISessionsManagementService } from
import { ISessionsService } from '../../../../services/sessions/browser/sessionsService.js';
import { ChatInteractivity, IChat, ISessionFileChange, ISessionWorkspace, SessionStatus } from '../../../../services/sessions/common/session.js';
import { ISessionChangesService, SessionChangesService } from '../../../changes/browser/sessionChangesService.js';
import { IAgentWorkbenchLayoutService } from '../../../../browser/workbench.js';
import { CHANGES_VIEW_CONTAINER_ID } from '../../../changes/common/changes.js';
import { SESSIONS_FILES_CONTAINER_ID } from '../../../files/browser/files.contribution.js';
import { TestInstantiationService } from '../../../../../platform/instantiation/test/common/instantiationServiceMock.js';
@@ -212,9 +211,7 @@ export function createTestHarness(store: DisposableStore, options: ICreateOption
activeEditorResource: undefined,
editorGroupsHaveContent: true,
applyWorkingSetCalls: [],
sessionChangesService: new SessionChangesService(new class extends mock<IEditorService>() { }, instaService, new class extends mock<IAgentWorkbenchLayoutService>() {
override get isSinglePaneLayoutEnabled() { return false; }
}),
sessionChangesService: new SessionChangesService(new class extends mock<IEditorService>() { }, instaService, configService),
};
instaService.stub(ISessionsManagementService, new class extends mock<ISessionsManagementService>() {