Skip to content

[v5.5] Diagnostics UI: model/log viewer + ModelFile page + MathJax#408

Open
lil-aditya wants to merge 6 commits intoEAPD-DRB:mainfrom
lil-aditya:feat/v55-diagnostics-ui
Open

[v5.5] Diagnostics UI: model/log viewer + ModelFile page + MathJax#408
lil-aditya wants to merge 6 commits intoEAPD-DRB:mainfrom
lil-aditya:feat/v55-diagnostics-ui

Conversation

@lil-aditya
Copy link
Copy Markdown
Contributor

Closes: #391
Part of: #388
Requires: PR1 (guardrails) and PR2 (backend/runtime routes) to be merged

Summary

This PR ports the upstream MUIO v5.5 diagnostics UI into MUIOGO, including:

  • DataFile page model/log viewer flow
  • Standalone ModelFile page (#/ModelFile)
  • MathJax-based equation rendering
  • Scenario toggle-all control

Changes included

  • Added "View Model", "View Log", and "Equations" controls to DataFile page
  • Integrated safe frontend calls to:
    • /readModelFile
    • /readLogFile
  • Added standalone ModelFile page with equation parsing + rendering
  • Integrated MathJax (scoped to equations page only)
  • Added scenario toggle-all control (preserves locked SC_0)

Compatibility + Safety

  • Frontend requests only fixed backend endpoints (no arbitrary path input)
  • Raw model/log text rendered using DOM text nodes (no innerHTML usage)
  • MathJax applied only to equation view (not logs or raw text)
  • Toggle-all excludes disabled scenarios and preserves SC_0

Narrow upstream adaptations

The upstream UI was followed by default, with minimal, targeted changes:

  • Switched from eager preload → on-demand fetch for model/log text
  • Replaced HTML-string rendering with safe DOM-based rendering
  • Fixed routing to use SPA hash format (#/ModelFile)
  • Adjusted toggle-all behavior to respect MUIOGO constraints

Files touched (frontend scope)

  • WebAPP/App/Controller/DataFile.js
  • WebAPP/App/Controller/ModelFile.js
  • WebAPP/App/View/DataFile.html
  • WebAPP/App/View/ModelFile.html
  • WebAPP/Classes/Html.Class.js
  • WebAPP/Classes/Osemosys.Class.js
  • WebAPP/Routes/Routes.Class.js
  • WebAPP/index.html

Validation

  • git diff --check passed (no whitespace/syntax issues)
  • ES modules import cleanly (Node-based check)
  • Equation parser validated (67 equations extracted from model file)
  • Route wiring verified at code level

Known limitations

  • PR3 depends on PR2 backend routes (readModelFile, readLogFile)

End-to-end UI validation is expected in CI / reviewer environment.

Out of scope

Notes

This PR intentionally keeps changes minimal and aligned with upstream v5.5 UI behavior, while enforcing MUIOGO’s safety constraints for path handling and rendering.

Copilot AI review requested due to automatic review settings April 2, 2026 14:28
@github-actions github-actions bot added the needs-intake-fix PR intake structure needs maintainer follow-up label Apr 2, 2026
@lil-aditya
Copy link
Copy Markdown
Contributor Author

This PR is based on the PR2 branch since upstream main did not yet include PR2 in this checkout.
Happy to rebase if needed once PR2 is merged.

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

Ports the upstream v5.5 diagnostics UI into MUIOGO by adding model/log viewers, a standalone ModelFile equations page, and supporting backend routes/guardrails for safe diagnostics reads.

Changes:

  • Added DataFile-page controls and modals for viewing the fixed-path model/log text, plus a scenario toggle-all control.
  • Introduced a standalone #/ModelFile page that parses GMPL constraints and typesets them with MathJax.
  • Added backend fixed-path routes (/readModelFile, /readLogFile), runtime logging location changes, and a smoke/clean-base verification harness + CI workflow.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
WebAPP/SOLVERs/model.v.5.4.txt Minor formatting tweaks in solver model text; used by equations extraction/rendering.
WebAPP/Routes/Routes.Class.js Adds SPA route for #/ModelFile.
WebAPP/index.html Adds MathJax configuration + CDN script include.
WebAPP/Classes/Osemosys.Class.js Adds frontend helpers for readModelFile / readLogFile via fetch.
WebAPP/Classes/Html.Class.js Adds safe plain-text rendering helpers for model/log/data text.
WebAPP/App/View/ModelFile.html New equations page layout + styles.
WebAPP/App/View/DataFile.html Adds EQUATIONS / VIEW MODEL / VIEW LOG controls, toggle-all button, and model/log modals.
WebAPP/App/Controller/ModelFile.js New controller: extracts objective/constraints and typesets with MathJax.
WebAPP/App/Controller/DataFile.js Adds modal text viewer helper and scenario toggle-all behavior.
API/Routes/DataFile/DataFileRoute.py Adds fixed-path read endpoints and improves logging around runs.
API/Classes/Base/Config.py Introduces runtime/log directory configuration and solver model path constant.
API/app.py Adds rotating file logging setup and warning capture.
API/Classes/Case/OsemosysClass.py Refactors path bookkeeping (results/view/resData paths) and solver model file reference.
API/Classes/Case/DataFileClass.py Refactors case run creation/update/cleanup to use instance paths and preserve viewDefinitions.
tests_smoke/test_smoke_app.py Adds stdlib unittest smoke coverage for app import and fixed routes.
scripts/verify_clean_base.py Adds “clean-base” verification script (git state, conflict markers, py_compile, smoke tests).
docs/dev/upstream_sync_playbook.md Documents upstream sync order, overlap surface, rejected patterns, and verification command.
CONTRIBUTING.md Adds clean-base verification guidance and pointers to the playbook.
.github/workflows/smoke.yml Runs clean-base verification in CI on pull requests.

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



# Energy balance – include only pairs that exist (others implicitly 0)
# Energy balance � include only pairs that exist (others implicitly 0)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The comment line contains a replacement character ("�"), which suggests an encoding/typography corruption (likely meant to be an en dash). Since this file is solver input, please replace it with plain ASCII (e.g., "-"), or ensure the intended character is preserved reliably.

Suggested change
# Energy balance include only pairs that exist (others implicitly 0)
# Energy balance - include only pairs that exist (others implicitly 0)

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +44
<script>
window.MathJax = window.MathJax || {
tex: {
packages: { '[+]': ['ams'] },
inlineMath: [['\\(', '\\)']],
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

MathJax is being configured and loaded in the global entrypoint, which means every page load pulls MathJax even when the equations view isn't used. This also conflicts with the PR description claim that MathJax is scoped to the equation page only; consider loading/injecting MathJax only when the ModelFile route/view is entered.

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +53
<!-- Swap this CDN src later if MathJax is vendored locally. -->
<script id="muiogo-mathjax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" defer></script>
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The MathJax CDN URL is not version-pinned ("mathjax@3"), so it can change underneath you. Pin to a specific version and consider adding an integrity/crossorigin policy (or vendoring locally) to reduce supply-chain risk.

Suggested change
<!-- Swap this CDN src later if MathJax is vendored locally. -->
<script id="muiogo-mathjax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" defer></script>
<!-- MathJax CDN is version-pinned; swap this src later if MathJax is vendored locally. -->
<script id="muiogo-mathjax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-chtml.js" defer></script>

Copilot uses AI. Check for mistakes.
Comment on lines +138 to +140
equation.latex,
'\\end{align}',
`\\tag{${counter}}`,
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The generated MathJax block puts \tag{} after \end{align}. In LaTeX/MathJax, \tag must be inside an ams math environment (e.g., within align/equation) or it may be ignored / throw a typeset error. Move the tag into the align environment (or use an environment that supports tagging as written).

Suggested change
equation.latex,
'\\end{align}',
`\\tag{${counter}}`,
`${equation.latex} \\tag{${counter}}`,
'\\end{align}',

Copilot uses AI. Check for mistakes.
}else{
Html.renderScOrder(model.scenarios);
}
DataFile.syncScenarioToggleButton();
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The toggle-all button label/icon is only synced when the modal opens and when toggle-all is clicked. If a user manually checks/unchecks individual scenario checkboxes, the toggle-all label can become stale. Add a change handler on '#osy-scOrder' checkbox inputs to call syncScenarioToggleButton() after any manual toggle.

Suggested change
DataFile.syncScenarioToggleButton();
DataFile.syncScenarioToggleButton();
// Keep toggle-all button state in sync when individual scenario checkboxes change
$("#osy-scOrder")
.off("change", "input[type='checkbox']")
.on("change", "input[type='checkbox']", function () {
DataFile.syncScenarioToggleButton();
});

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-intake-fix PR intake structure needs maintainer follow-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] Port the DataFile model/log diagnostics from MUIO v5.5

2 participants