Skip to content

fix(compiler): align generated apps and typed IR#787

Merged
cssbruno merged 2 commits into
mainfrom
codex/fix-ir-app-hmr-issues
Jun 27, 2026
Merged

fix(compiler): align generated apps and typed IR#787
cssbruno merged 2 commits into
mainfrom
codex/fix-ir-app-hmr-issues

Conversation

@cssbruno

Copy link
Copy Markdown
Owner

Summary

  • generate default .gowdk app packages inside the application module, remove stale nested go.mod files, and keep legacy/role app module isolation where required
  • lower server load fields into typed IR and make render, SSR load, taint, and validation paths consume typed fields instead of reparsing ServerBody
  • add state-shape compatibility metadata so dev component HMR carries island state only across compatible replacements

Issues

Fixes #663.
Refs #664.
Refs #639.

Verification

  • go test ./internal/gwdkir ./internal/gwdkanalysis ./internal/compiler ./internal/viewrender ./internal/buildgen ./internal/appgen ./internal/gowdkcmd (parent go process hung after child exit; packages through appgen passed, gowdkcmd rerun below passed)
  • go test ./internal/gowdkcmd -count=1
  • go test ./internal/gwdkanalysis ./internal/compiler ./internal/buildgen ./internal/appgen
  • go test ./internal/gowdkcmd -run 'TestBuildValidationReturnsOperationErrorDiagnostics|TestDevComponentHMRPayload|TestLiveReloadScriptIncludesComponentHMR|TestBuildCommandGeneratesContractRoleBinaries' -count=1
  • go build ./cmd/gowdk
  • scripts/test-go-modules.sh
  • scripts/check-docs-links.sh
  • scripts/check-docs-style.sh
  • scripts/check-removed-syntax.sh
  • scripts/check-doc-versions.sh
  • git diff --check

@github-actions github-actions Bot added compiler Compiler internals, pipeline, and generated metadata IR Internal compiler IR and phase handoffs docs Documentation work labels Jun 27, 2026
@cssbruno cssbruno marked this pull request as ready for review June 27, 2026 14:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 31e9feaa49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/appgen/module.go Outdated
ImportBase: legacyGeneratedAppModulePath,
BuildDir: absApp,
}
appModule, err := currentAppModule()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve app modules from the generated app directory

When gowdk build --project-root /path/to/app --app /path/to/app/.gowdk/site --bin ... is invoked from any directory other than the project root, this still asks go list -m in the process cwd. The build path does not chdir to ProjectRoot, so .gowdk apps inside the application module fall back to a nested go.mod or use the wrong module; generated backend imports such as example.com/site/internal/... then fail to resolve or trip Go internal visibility, which is the case this change is trying to fix. Resolve the module relative to absApp/project root instead of the current working directory.

Useful? React with 👍 / 👎.

})
return
}
blocks.ServerFields = fields

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report empty server loads as diagnostics

When a non-empty server {} body has setup/Go lines but no => { ... } load declaration, parseServerFields returns an empty slice and this assignment leaves ServerFields empty without adding a diagnostic. The following invariant check now reports internal compiler error: ... has server body but no typed load fields for a user-authored validation mistake in gowdk check/build --ssr; emit a normal validation diagnostic when no fields are parsed from a non-empty server block instead of letting it become an ICE.

Useful? React with 👍 / 👎.

Comment on lines +178 to +180
if colon := indexTopLevelByte(element, ':'); colon >= 0 {
name = element[:colon]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject malformed keyed server load fields

For keyed server declarations, everything after the top-level colon is discarded without any validation, so inputs like server { => { title: } } or => { title: missing( } are accepted as a load field named title instead of producing a parse diagnostic. This lets malformed authoring syntax reach SSR generation/checks as if it were valid; either reject colon syntax here or validate that the keyed expression is present and syntactically valid before appending the field name.

Useful? React with 👍 / 👎.

@cssbruno cssbruno merged commit c2cf66c into main Jun 27, 2026
24 checks passed
@cssbruno cssbruno deleted the codex/fix-ir-app-hmr-issues branch June 27, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler Compiler internals, pipeline, and generated metadata docs Documentation work IR Internal compiler IR and phase handoffs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate apps inside the project module instead of a nested gowdk-generated-app module

1 participant