Skip to content

Incorporate HTML help in the Web UI for offline access #1366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 4, 2025

This PR adds comprehensive offline help functionality to the EduMIPS64 Web UI, enabling documentation access without internet connection - crucial for university exams and other offline contexts.

Changes Made

Core Implementation

  • HelpBrowserDialog: New component providing iframe-based documentation browsing with language selection
  • Enhanced HelpDialog: Updated to include offline help browser alongside existing about information
  • Webpack configuration: Modified to bundle HTML help files as static assets

Documentation Integration

  • Generated HTML documentation from existing Sphinx sources for all supported languages:
    • English (help/en/)
    • Italian (help/it/)
    • Chinese (help/zh/)
  • Total bundle size: ~1.1MB for complete trilingual documentation
  • Includes all sections: instructions, FPU, examples, user interface, and file formats

Key Features

  • Offline-first: All help content bundled with the web application
  • Multi-language support: Language selector with proper navigation between docs
  • Complete documentation: Same comprehensive help available in the Swing UI
  • Cross-platform compatibility: Works in both regular web browsers and Electron distribution

Before/After

Before: Web UI only linked to external ReadTheDocs, requiring internet connection

<Link href="https://edumips64.readthedocs.io/en/latest/">
  Read the docs
</Link>

After: Integrated help browser with offline documentation

<Button onClick={handleOpenHelpBrowser}>
  Open EduMIPS64 Documentation
</Button>

Technical Details

The implementation leverages the existing Sphinx documentation build system used for the Swing UI's JavaHelp files. HTML documentation is generated from the same RST sources and bundled via webpack's CopyPlugin.

File structure:

build/gwt/war/edumips64/help/
├── en/
│   ├── index.html
│   ├── instructions.html
│   ├── _static/
│   └── ...
├── it/
└── zh/

Testing

  • ✅ Documentation loads correctly in all three languages
  • ✅ Internal navigation and CSS styling work properly
  • ✅ Compatible with existing Electron packaging
  • ✅ Minimal bundle size impact (~1.1MB total)

Fixes #1365.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://168.63.129.16:80/machine/
    • Triggering command: /usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Incorporate HTML help in the Web UI Incorporate HTML help in the Web UI for offline access Jun 4, 2025
@Copilot Copilot AI requested a review from lupino3 June 4, 2025 15:45
Copilot finished work on behalf of lupino3 June 4, 2025 15:45
<DialogContent sx={{ height: '70vh', padding: 0 }}>
<iframe
ref={iframeRef}
src={helpUrl}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 17 days ago

To fix the issue, we need to ensure that the selectedLanguage value is sanitized before constructing the helpUrl. This can be achieved by validating the selectedLanguage against the predefined HELP_LANGUAGES array to ensure it matches one of the allowed language codes. If the value is invalid, we can default to a safe fallback (e.g., 'en').

Steps to implement the fix:

  1. Add a validation function to check if the selectedLanguage is one of the allowed language codes.
  2. Use this validation function in the handleLanguageChange function and when constructing the helpUrl.
  3. Ensure that the helpUrl is always constructed using a sanitized value.

Suggested changeset 1
src/webapp/components/HelpBrowserDialog.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/webapp/components/HelpBrowserDialog.js b/src/webapp/components/HelpBrowserDialog.js
--- a/src/webapp/components/HelpBrowserDialog.js
+++ b/src/webapp/components/HelpBrowserDialog.js
@@ -23,7 +23,10 @@
 
+  const isValidLanguage = (lang) => HELP_LANGUAGES.some((language) => language.code === lang);
+
   const handleLanguageChange = (event) => {
-    setSelectedLanguage(event.target.value);
+    const newLanguage = isValidLanguage(event.target.value) ? event.target.value : 'en';
+    setSelectedLanguage(newLanguage);
     // Navigate to index page when language changes
     if (iframeRef.current) {
-      iframeRef.current.src = `help/${event.target.value}/index.html`;
+      iframeRef.current.src = `help/${newLanguage}/index.html`;
     }
@@ -203,3 +206,3 @@
 
-  const helpUrl = `help/${selectedLanguage}/index.html`;
+  const helpUrl = `help/${isValidLanguage(selectedLanguage) ? selectedLanguage : 'en'}/index.html`;
 
EOF
@@ -23,7 +23,10 @@

const isValidLanguage = (lang) => HELP_LANGUAGES.some((language) => language.code === lang);

const handleLanguageChange = (event) => {
setSelectedLanguage(event.target.value);
const newLanguage = isValidLanguage(event.target.value) ? event.target.value : 'en';
setSelectedLanguage(newLanguage);
// Navigate to index page when language changes
if (iframeRef.current) {
iframeRef.current.src = `help/${event.target.value}/index.html`;
iframeRef.current.src = `help/${newLanguage}/index.html`;
}
@@ -203,3 +206,3 @@

const helpUrl = `help/${selectedLanguage}/index.html`;
const helpUrl = `help/${isValidLanguage(selectedLanguage) ? selectedLanguage : 'en'}/index.html`;

Copilot is powered by AI and may make mistakes. Always verify output.
@lupino3 lupino3 committed this autofix suggestion 17 days ago.
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.49%. Comparing base (a6eba7d) to head (0dfc6b9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1366   +/-   ##
=========================================
  Coverage     52.49%   52.49%           
  Complexity     1465     1465           
=========================================
  Files           258      258           
  Lines         10464    10464           
  Branches       1132     1132           
=========================================
  Hits           5493     5493           
  Misses         4638     4638           
  Partials        333      333           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a6eba7d...0dfc6b9. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lupino3
Copy link
Member

lupino3 commented Jun 4, 2025

@copilot I see that you added src/webapp/help. This is not correct, as it is duplicating both the .rst source of the help and even the HTML output of the compilation.

You need to dynamically include in the webapp the output of the help compilation process, not commit to git a copy of the RST sources and of the HTML output.

Copy link
Contributor Author

Copilot AI commented Jun 4, 2025

@copilot I see that you added src/webapp/help. This is not correct, as it is duplicating both the .rst source of the help and even the HTML output of the compilation.

You need to dynamically in...

Fixed in commit bdc70f4. Removed the duplicated src/webapp/help directory and updated webpack configuration to dynamically include documentation from the build output (build/docs/*/html) generated by the existing gradle htmlDocs tasks. No longer committing RST sources or HTML output to git.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://168.63.129.16:80/machine/
    • Triggering command: /usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of lupino3 June 4, 2025 18:28
@lupino3
Copy link
Member

lupino3 commented Jun 4, 2025

@copilot Please make the help readable with both dark and bright themes.

Copy link
Contributor Author

Copilot AI commented Jun 4, 2025

@copilot Please make the help readable with both dark and bright themes.

Fixed in commit f041136. Added comprehensive theme-aware styling that dynamically injects CSS into the help documentation iframe based on the current Material UI theme (dark/light). The documentation is now readable and properly styled in both themes with appropriate colors for text, backgrounds, links, code blocks, and all other elements.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)
  • http://168.63.129.16:80/machine/
    • Triggering command: /usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of lupino3 June 4, 2025 20:08
lupino3 and others added 2 commits July 16, 2025 10:22
…as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@lupino3 lupino3 marked this pull request as ready for review July 16, 2025 08:22
@lupino3
Copy link
Member

lupino3 commented Jul 16, 2025

@copilot "Build web application" failed because the help files are not available. Please add a step to build the help files before building the JS code, after building the worker.

Copy link
Contributor Author

Copilot AI commented Jul 16, 2025

@copilot "Build web application" failed because the help files are not available. Please add a step to build the help files before building the JS code, after building the worker.

Fixed in commit 9cb3e77. Added HTML documentation build step (./gradlew htmlDocsEn htmlDocsIt htmlDocsZh) to both build-web and build-electron jobs in the CI workflow, positioned after building the JS worker but before building the web application. This ensures the help files are available when webpack tries to copy them.

Copilot finished work on behalf of lupino3 July 16, 2025 08:57
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.

Incorporate HTML help in the Web UI
2 participants