Skip to content

Clean up / refactor codeworld-server#73

Merged
jvoigtlaender merged 14 commits intofmidue:fmiduefrom
nimec01:cw-server-cleanup
Apr 29, 2026
Merged

Clean up / refactor codeworld-server#73
jvoigtlaender merged 14 commits intofmidue:fmiduefrom
nimec01:cw-server-cleanup

Conversation

@nimec01
Copy link
Copy Markdown
Collaborator

@nimec01 nimec01 commented Apr 22, 2026

This removes old leftovers from the original codeworld-server implementation.

Mentionable changes:

  • The server responses do not return any program or deploy ID anymore. The client now saves the code locally based on its hash.
  • Removed (now) obsolete dependencies
  • We now use explicit import lists
  • Re-enabled incomplete-patterns, name-shadowing, unused-imports and unused-matches warnings

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

Refactors codeworld-server and the web client to remove legacy “program/deploy ID” plumbing and instead key locally-saved code by a content hash, while also trimming obsolete Haskell modules/dependencies and tightening imports/warnings.

Changes:

  • Server compile response no longer includes program/deploy IDs; client-side code now hashes source and persists it locally.
  • Removed legacy Util/Model modules and pruned unused codeworld-server dependencies.
  • Updated JS compile/run flows to consume the new server response format.

Reviewed changes

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

Show a summary per file
File Description
web/js/run.js Adjust response parsing to load compiled program from new response layout.
web/js/codeworld_shared.js Adds sha256digest helper for hashing source code.
web/js/codeworld.js Switches editor initialization + compile flow to localStorage-by-hash and new compile response parsing.
codeworld-server/src/Util.hs Deleted legacy utility layer (IDs, hashing, filesystem helpers).
codeworld-server/src/Model.hs Deleted legacy JSON models tied to removed functionality.
codeworld-server/src/Main.hs Removes program/deploy ID handling from compile endpoint and simplifies temp build layout.
codeworld-server/codeworld-server.cabal Removes now-obsolete dependencies and modules.

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

Comment thread web/js/codeworld.js
Comment thread web/js/run.js
Comment on lines 208 to 211
mode <- getBuildMode
let previewConf = previewConfig $ config ctx
Just source <- (T.decodeUtf8 <$>) <$> getParam "source"
mPreview <- getParam "enablePreview"
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

These Just ... <- getParam ... bindings are failable patterns; with -Wall they trigger -Wincomplete-uni-patterns and at runtime will fail with a 500 if the parameter is missing. Prefer explicitly handling Nothing (e.g., return a 400 with a clear message) to both avoid warnings and make the handler robust.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This pattern is pretty much used for every route handler. The error message is indeed a bit misleading if we don't provide the required params ('No handler accepted "/compile" '). Should we change this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm willing to go with your judgement on this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

One could argue that the routes in question are not meant to be hit by the users themselves (i.e. manually sending a request to the server) and thus we shouldn't need to care if the user understands what is wrong or not. But I would argue that it's still better to add at least add some more contextual information such that it's easier to debug for us. I'll update the handlers in just a moment.

Comment thread codeworld-server/src/Main.hs
Comment thread codeworld-server/src/Main.hs Outdated
Comment thread web/js/codeworld.js Outdated
@jvoigtlaender
Copy link
Copy Markdown
Member

Can be merged now, right?

@nimec01
Copy link
Copy Markdown
Collaborator Author

nimec01 commented Apr 29, 2026

Yes

@jvoigtlaender jvoigtlaender merged commit c3585e1 into fmidue:fmidue Apr 29, 2026
1 check passed
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.

3 participants