Skip to content

Fix ApplicationConfig format: preserve application: structure on round-trip, warn when sub-files unresolvable#9

Merged
intel352 merged 6 commits intomasterfrom
copilot/fix-applicationconfig-format-issues
Apr 8, 2026
Merged

Fix ApplicationConfig format: preserve application: structure on round-trip, warn when sub-files unresolvable#9
intel352 merged 6 commits intomasterfrom
copilot/fix-applicationconfig-format-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Opening an ApplicationConfig-format YAML (application: top-level key with workflows[].file references) silently converted it to flat WorkflowConfig on the first onChange event and rendered no sub-file nodes.

Root causes

  • parseYaml/parseYamlSafe didn't recognize the application: format — returned an empty config, triggering a silent rewrite on export
  • configToYaml, exportMainFileYaml, and buildMainFileContent had no path to emit application: format — always produced flat WorkflowConfig with imports:
  • WorkflowStore.exportToConfig() called nodesToConfig() which strips all metadata, losing ApplicationConfig identity across the round-trip

Changes

src/types/workflow.ts

  • Add ApplicationConfigMeta interface (name?, version?, workflows: [{file}])
  • Add _applicationConfig?: ApplicationConfigMeta to WorkflowConfig (alongside master's _extraTopLevelKeys)

src/utils/serialization.ts

  • parseYaml / parseYamlSafe: detect application: format; populate _applicationConfig, imports, name, version
  • resolveImports: set _applicationConfig on the returned merged config so format identity survives sub-file resolution
  • buildApplicationConfigYaml (new export): round-trips ApplicationConfigMetaapplication: YAML
  • isMetadataOnlyApplicationConfig (new): returns true when config has no real main-file modules/workflows/triggers/pipelines
  • configToYaml: delegates to buildApplicationConfigYaml only when _applicationConfig is present and the config is metadata-only; falls back to full WorkflowConfig serialization otherwise so top-level content is never dropped
  • buildMainFileContent: delegates to configToYaml (preserving _extraTopLevelKeys and _originalKeys ordering); clears sub-file-owned workflows/triggers from the main-file view for ApplicationConfig configs so isMetadataOnlyApplicationConfig correctly identifies the main file; importedFiles naturally excludes unresolvable sub-files (files not present in fileModules/filePipelines) preventing empty YAML overwrites

src/stores/workflowStore.ts

  • Uses importedPassthrough (from master) to carry all non-visual fields — including _applicationConfig — through the import/export cycle; exportToConfig explicitly reattaches _applicationConfig from importedPassthrough after nodesToConfig

src/components/WorkflowEditor.tsx

  • Warning for ApplicationConfig format without a file resolver is keyed off !onResolveFile (not !sourceMapProp) so it fires correctly when a host passes a static sourceMap but no resolver

Example

# Before: opening this file rewrote it on first onChange
application:
  name: my-service
  workflows:
    - file: base.yaml
    - file: users.yaml

# After: exportMainFileYaml / configToYaml preserve the original structure
application:
  name: my-service
  workflows:
    - file: base.yaml
    - file: users.yaml

Two existing tests updated to assert application: format (previously asserted imports:); 22 new tests added in serialization-applicationconfig.test.ts covering ApplicationConfig detection, round-trip, metadata-only guard, and empty-file filtering.

Copilot AI review requested due to automatic review settings April 8, 2026 13:21
Copilot AI linked an issue Apr 8, 2026 that may be closed by this pull request
Copilot AI review requested due to automatic review settings April 8, 2026 13:21
…ow warning when sub-files can't be resolved

Agent-Logs-Url: https://github.com/GoCodeAlone/workflow-editor/sessions/cde0510e-a5f2-413a-8ccb-0d0493cb622c

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 8, 2026 13:40
…olidate file collection logic

Agent-Logs-Url: https://github.com/GoCodeAlone/workflow-editor/sessions/cde0510e-a5f2-413a-8ccb-0d0493cb622c

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 8, 2026 13:44
Copilot AI changed the title [WIP] Fix ApplicationConfig format not recognized and missing sub-file nodes Fix ApplicationConfig format: preserve application: structure on round-trip, warn when sub-files unresolvable Apr 8, 2026
Copilot AI requested a review from intel352 April 8, 2026 13:44
@intel352 intel352 marked this pull request as ready for review April 8, 2026 14:09
Copilot AI review requested due to automatic review settings April 8, 2026 14:09
Copy link
Copy Markdown

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 adds first-class support for the ApplicationConfig YAML format (application: with workflows[].file references) so the editor can preserve that structure across import → edit → export, and provides user-facing warnings when referenced sub-files can’t be resolved/rendered.

Changes:

  • Add ApplicationConfigMeta and persist _applicationConfig metadata through parsing, import resolution, store round-trip, and export.
  • Teach serialization/export paths (configToYaml, exportMainFileYaml/exportToFiles) to emit application: YAML when appropriate, plus add a dedicated buildApplicationConfigYaml helper.
  • Add/adjust tests to validate ApplicationConfig detection and round-trip behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/serialization.ts Detect application: format, preserve metadata through resolveImports, and add ApplicationConfig YAML emit paths.
src/utils/serialization-multifile.test.ts Update multifile expectations to match application: main-file output.
src/utils/serialization-applicationconfig.test.ts New comprehensive test suite for ApplicationConfig recognition and round-tripping.
src/utils/index.ts Re-export buildApplicationConfigYaml.
src/types/workflow.ts Define ApplicationConfigMeta and add _applicationConfig to WorkflowConfig.
src/stores/workflowStore.ts Preserve ApplicationConfig metadata in store import/export and clear it on reset.
src/components/WorkflowEditor.tsx Warn when ApplicationConfig is detected but full resolution/rendering isn’t possible.

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

Comment on lines +70 to +77
// ApplicationConfig format detected but no file resolver provided — warn the user
// rather than silently converting the format.
if (config._applicationConfig && !sourceMapProp) {
addToast(
'ApplicationConfig format detected. Configure a workspace file resolver to render the full application graph from referenced sub-files.',
'warning',
);
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The warning is meant to trigger when ApplicationConfig is detected but onResolveFile is not provided. This check uses !sourceMapProp, which can suppress the warning when a host passes a sourceMap but no resolver (still cannot resolve referenced sub-files). Consider keying this warning off !onResolveFile (and optionally also when resolver returns missing files).

Copilot uses AI. Check for mistakes.
@intel352
Copy link
Copy Markdown
Contributor

intel352 commented Apr 8, 2026

@copilot apply changes based on the comments in this thread

… warning condition, strengthen test assertion

Agent-Logs-Url: https://github.com/GoCodeAlone/workflow-editor/sessions/365aa754-1dd3-4dce-8884-3575138941a1

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot apply changes based on the comments in this thread

Applied all four review comments in commit 7ef4683:

  1. configToYaml guard — added isMetadataOnlyApplicationConfig() helper that checks for real modules/workflows/triggers/pipelines; configToYaml now only emits application: format when the config has no main-file content, falling back to full WorkflowConfig serialization otherwise.

  2. Empty export filesbuildMainFileContent now filters importedFiles to only include files that actually have exported content (modules or pipelines). Files referenced in application.workflows[].file that had no resolvable content are excluded from the export file map, preventing empty YAML overwrites.

  3. Warning condition — changed !sourceMapProp!onResolveFile in WorkflowEditor.tsx. The warning now triggers when there is no file resolver (the actual requirement), regardless of whether a sourceMap prop was passed.

  4. Test assertion — replaced the hasAtLeastOneRef check with importedFiles.forEach(f => expect(mainYaml).toContain(f)) so every expected file reference is individually verified.

@intel352
Copy link
Copy Markdown
Contributor

intel352 commented Apr 8, 2026

@copilot Address the merge conflicts intelligently, ensure all tests still pass.

…hrough, and preserve ApplicationConfig format

- Keep both _applicationConfig and _extraTopLevelKeys on WorkflowConfig
- Replace applicationConfig store field with importedPassthrough (master's approach)
- Explicitly reattach _applicationConfig in exportToConfig from importedPassthrough
- Integrate KNOWN_TOP_LEVEL_KEYS and extractExtraTopLevelKeys from master alongside buildApplicationConfigYaml and isMetadataOnlyApplicationConfig from our branch
- Use master's buildMainFileContent (delegate to configToYaml); clear workflows/triggers in mainOnlyConfig for ApplicationConfig format so isMetadataOnlyApplicationConfig works correctly on the merged config
- All 4055 tests pass

Agent-Logs-Url: https://github.com/GoCodeAlone/workflow-editor/sessions/a1a28ad8-429d-4928-80f4-956801c8d6b4

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 8, 2026 15:34
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot Address the merge conflicts intelligently, ensure all tests still pass.

Resolved in commit 90f9ae3. Here's what the merge integrated:

  • WorkflowConfig type: both _applicationConfig and _extraTopLevelKeys are now present
  • Store: replaced our applicationConfig field with master's importedPassthrough — since importedPassthrough is a spread of the full config (minus visual fields), _applicationConfig is carried automatically; exportToConfig explicitly reattaches it from originalConfig._applicationConfig after nodesToConfig
  • serialization.ts: kept all additions from both sides — KNOWN_TOP_LEVEL_KEYS, extractExtraTopLevelKeys, buildApplicationConfigYaml, isMetadataOnlyApplicationConfig; used master's buildMainFileContent (delegate to configToYaml) with one addition: for ApplicationConfig format, workflows and triggers are cleared from mainOnlyConfig before calling configToYaml, since those fields come from sub-files and would otherwise cause isMetadataOnlyApplicationConfig to return false on the merged config

All 4055 tests pass.

@intel352 intel352 merged commit 3b669e0 into master Apr 8, 2026
4 checks passed
@intel352 intel352 deleted the copilot/fix-applicationconfig-format-issues branch April 8, 2026 21:02
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.

ApplicationConfig format not recognized; sub-file nodes not rendered

3 participants