Skip to content

Code formatting while saving#382

Open
stijnpotters1 wants to merge 11 commits intomasterfrom
fix/auto-save-formatting
Open

Code formatting while saving#382
stijnpotters1 wants to merge 11 commits intomasterfrom
fix/auto-save-formatting

Conversation

@stijnpotters1
Copy link
Copy Markdown
Contributor

@stijnpotters1 stijnpotters1 commented Mar 24, 2026

Now the code is not formatted or normalized when the file is getting saved.

Instead of moving elements, attributes and cursor:
Now the cursor stays where it was left and attributes dont shift

Note:

  • When adding a configuration or adapter the reformatting is applied.
  • Also the full crud for the adapter since this is only used in the studio. When you return to the editor, the code is not formatted without bothering the user while editing the configuration

Copilot AI review requested due to automatic review settings March 24, 2026 16:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR changes the “save configuration” flow so saving XML no longer reformats/normalizes content (preventing cursor/attribute shifting), and updates backend + frontend contracts accordingly.

Changes:

  • Backend: updateConfiguration now writes raw content to disk and returns no XML payload (controller returns an empty 200 response).
  • Frontend: saveConfiguration now expects no response body; editor no longer replaces content with server-returned XML after save.
  • Config creation paths now add the flow namespace when creating new XML configuration files; tests updated for the new behaviors.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/main/java/org/frankframework/flow/configuration/ConfigurationService.java Stops XML normalization on update; adds namespace insertion when creating new configs (now introduces XML transform exceptions).
src/main/java/org/frankframework/flow/configuration/ConfigurationController.java Update endpoint now returns ResponseEntity<Void>; add-config endpoint now declares XML-related checked exceptions.
src/main/java/org/frankframework/flow/filetree/FileTreeService.java Creating .xml files delegates to configuration creation; throws clause updated (currently contains a compile-breaking duplicate).
src/main/java/org/frankframework/flow/filetree/FileTreeController.java Propagates XML-related checked exceptions from file creation endpoint.
src/main/frontend/app/services/configuration-service.ts saveConfiguration now returns Promise<void> and drops the previous XML response type.
src/main/frontend/app/routes/editor/editor.tsx Save no longer sets editor content from a server-returned XML response.
src/main/frontend/app/routes/studio/canvas/flow.tsx Awaits git diff refresh after saving.
src/test/java/org/frankframework/flow/configuration/ConfigurationServiceTest.java Updates assertions to match raw-write behavior (no newline/normalization).
src/test/java/org/frankframework/flow/configuration/ConfigurationControllerTest.java Updates mocks to reflect boolean/void-style update response.
src/test/java/org/frankframework/flow/filetree/FileTreeServiceTest.java Updates test method signatures to match new checked exceptions.
src/main/java/org/frankframework/flow/adapter/AdapterService.java Removes a stray blank line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stijnpotters1 stijnpotters1 requested a review from Matthbo March 24, 2026 17:37
@stijnpotters1 stijnpotters1 self-assigned this Mar 24, 2026
@stijnpotters1 stijnpotters1 marked this pull request as ready for review March 24, 2026 17:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Stijn Potters <stijn.potters1@gmail.com>
@stijnpotters1 stijnpotters1 requested review from Copilot and removed request for Copilot March 24, 2026 17:39
Copilot AI review requested due to automatic review settings March 24, 2026 17:43
@stijnpotters1 stijnpotters1 linked an issue Mar 24, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/main/java/org/frankframework/flow/filetree/FileTreeService.java:145

  • FileTreeService.createFile now exposes XML-processing checked exceptions (ParserConfigurationException, SAXException, TransformerException) in its public signature even though callers may be creating non-XML files. This leaks implementation details and forces controllers/tests to deal with XML-specific exceptions. Consider catching these exceptions inside createFile (or inside ConfigurationService.addConfigurationToFolder) and rethrowing an ApiException/IOException with context so the signature can remain throws IOException, ApiException.
	public FileTreeNode createFile(String projectName, String parentPath, String fileName)
			throws IOException, ApiException, ParserConfigurationException, TransformerException, SAXException {
		if (parentPath == null || parentPath.isBlank()) {
			throw new IllegalArgumentException("Parent path must not be empty");
		}

		validateFileName(fileName);
		String fullPath = parentPath.endsWith("/") ? parentPath + fileName : parentPath + "/" + fileName;
		validateWithinProject(projectName, fullPath);

		if (fileName.toLowerCase().endsWith(".xml")) {
			configurationService.addConfigurationToFolder(projectName, fileName, parentPath);
		} else {
			fileSystemStorage.createFile(fullPath);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Matthbo
Copy link
Copy Markdown
Member

Matthbo commented Mar 25, 2026

I'm currently also working on the editor, from API endpoints to monaco editor and thus touch a lot of these files too
I can review and merge it when its approved and deal with the merge conflict or take these changes with me in my PR instead of having it first go to master.

My changes split up some of the endpoints and services in both front and backend, maybe its better to take these changes with me but that's just my opinion

@Matthbo
Copy link
Copy Markdown
Member

Matthbo commented Apr 2, 2026

@Daan0709 Could you take a look at this?
I'm not sure if this is a smart idea as the frontend wont represent how the final file will look after saving.
I made this after talking with Niels a bit ago #403, maybe we should merge that issue into #380 and update this PR?

@Daan0709
Copy link
Copy Markdown
Contributor

Daan0709 commented Apr 8, 2026

@Matthbo Yeah ill take a look at this. I'll merge #403 into #380 and implement the same file formatting.

@Daan0709 Daan0709 linked an issue Apr 8, 2026 that may be closed by this pull request
@sonarqubecloud
Copy link
Copy Markdown

@Daan0709
Copy link
Copy Markdown
Contributor

@Matthbo I have merged this branch with master and also added prettier formatting to be in line with what the backend returns. This PR should be ready for review now

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.

Editor file formatting differs in monaco-editor Editor saving results is moving selector Backend automatically alphabetises attributes

4 participants