From 0f9736eeeb3475245ef0e10d7d4208d0ee1feab5 Mon Sep 17 00:00:00 2001 From: Martin Fleck Date: Fri, 16 Jan 2026 20:12:05 +0100 Subject: [PATCH 1/2] Extend model submission with optional layout information Fixes https://github.com/eclipse-glsp/glsp/issues/1616 --- .../features/layout/computed-bounds-action-handler.ts | 7 +++++-- .../common/features/model/model-submission-handler.ts | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/server/src/common/features/layout/computed-bounds-action-handler.ts b/packages/server/src/common/features/layout/computed-bounds-action-handler.ts index 5bf5458..c5a5a92 100644 --- a/packages/server/src/common/features/layout/computed-bounds-action-handler.ts +++ b/packages/server/src/common/features/layout/computed-bounds-action-handler.ts @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ import { GModelRoot } from '@eclipse-glsp/graph'; -import { Action, ComputedBoundsAction, MaybePromise } from '@eclipse-glsp/protocol'; +import { Action, ComputedBoundsAction, LayoutOperation, MaybePromise } from '@eclipse-glsp/protocol'; import { inject, injectable } from 'inversify'; import { ActionHandler } from '../../actions/action-handler'; import { applyAlignment, applyElementAndBounds, applyRoute } from '../../utils/layout-util'; @@ -39,7 +39,10 @@ export class ComputedBoundsActionHandler implements ActionHandler { const model = this.modelState.root; if (action.revision === model.revision) { this.applyBounds(model, action); - return this.submissionHandler.submitModelDirectly(); + return this.submissionHandler.submitModelDirectly( + undefined, + LayoutOperation.create([], { canvasBounds: action.canvasBounds, viewport: action.viewport }) + ); } return []; diff --git a/packages/server/src/common/features/model/model-submission-handler.ts b/packages/server/src/common/features/model/model-submission-handler.ts index 78b11c1..997efaa 100644 --- a/packages/server/src/common/features/model/model-submission-handler.ts +++ b/packages/server/src/common/features/model/model-submission-handler.ts @@ -17,6 +17,7 @@ import { Action, DirtyStateChangeReason, GModelRootSchema, + LayoutOperation, MarkersReason, MaybePromise, RequestBoundsAction, @@ -112,9 +113,10 @@ export class ModelSubmissionHandler { * to the `ActionDispatcher`, or simply returned as the result of an `ActionHandler.execute()` method. * * @param reason The optional reason that caused the model update. + * @param layout The optional layout operation that carries the information for auto-layout. * @returns A list of actions to be processed in order to submit the model. */ - submitModel(reason?: DirtyStateChangeReason): MaybePromise { + submitModel(reason?: DirtyStateChangeReason, layout?: LayoutOperation): MaybePromise { this.modelFactory.createModel(); const revision = this.requestModelAction ? 0 : this.modelState.root.revision! + 1; @@ -124,7 +126,7 @@ export class ModelSubmissionHandler { const root = this.serializeGModel(); return [RequestBoundsAction.create(root), SetDirtyStateAction.create(this.commandStack.isDirty, { reason })]; } - return this.submitModelDirectly(reason); + return this.submitModelDirectly(reason, layout); } /** @@ -139,11 +141,12 @@ export class ModelSubmissionHandler { * `ActionHandler.execute()` method. * * @param reason The optional reason that caused the model update. + * @param layout The optional layout operation that carries the information for auto-layout. * @returns A list of actions to be processed in order to submit the model. */ - async submitModelDirectly(reason?: DirtyStateChangeReason): Promise { + async submitModelDirectly(reason?: DirtyStateChangeReason, layout?: LayoutOperation): Promise { if (this.diagramConfiguration.layoutKind === ServerLayoutKind.AUTOMATIC && this.layoutEngine) { - await this.layoutEngine.layout(); + await this.layoutEngine.layout(layout); } const root = this.serializeGModel(); From 72ffc285f868924057a009041df0fc794c8eea07 Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Tue, 20 Jan 2026 08:59:06 +0100 Subject: [PATCH 2/2] Upgrade next --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2b99491..0a65eb6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -301,9 +301,9 @@ prettier-plugin-packagejson "~2.4.6" "@eclipse-glsp/protocol@next": - version "2.6.0-next.6" - resolved "https://registry.yarnpkg.com/@eclipse-glsp/protocol/-/protocol-2.6.0-next.6.tgz#7437694ed1e4f5ca716ba657b98af46c90abbc9a" - integrity sha512-uswJrgPNb7wwRCiqyoNOkTCqdM2S+3avXuh4/vDKxyo7w05yLkblp1foEInfYIbRmqTod05K4fAtUWEkxJcg5Q== + version "2.6.0-next.14" + resolved "https://registry.yarnpkg.com/@eclipse-glsp/protocol/-/protocol-2.6.0-next.14.tgz#954c845feaca1484a76fc53617290bfa58ff36b9" + integrity sha512-081j0/WZrUFe7/G+T2zxKRDBj0grlJ/r5pizYPP8ig7Lzq9hRqL2n1vxOoU9DUaeZcWec6MJJRm5nscomFq7IA== dependencies: sprotty-protocol "1.4.0" uuid "~10.0.0"