Skip to content

fix: installer web UI 404 and PowerShell banner garbling - #114

Merged
elkaix merged 1 commit into
mainfrom
fix/installer-web-404-banner-unicode
Jun 10, 2026
Merged

fix: installer web UI 404 and PowerShell banner garbling#114
elkaix merged 1 commit into
mainfrom
fix/installer-web-404-banner-unicode

Conversation

@elkaix

@elkaix elkaix commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Windows/Linux installers: web UI no longer 404s on /. Both installer CI workflows (windows-installer.yml, linux-installer.yml) now build the gitignored web/vis frontend bundles before running PyInstaller, matching the PyPI release flow. Every PyInstaller spec (root + both installer packages) aborts loudly when bundles are missing. As a last-resort fallback, the web and vis apps serve an explanatory 503 page on / instead of a bare 404 when assets are absent at runtime.
  • Startup banner renders on legacy Windows consoles. print_banner() now honors the existing ascii_glyphs_enabled() detection with width-preserving ASCII fallbacks, and degrades per line (instead of crashing) when the output stream rejects Unicode (e.g. cp1252 in PowerShell with redirected output).
  • Also fixes a latent TypeError in print_banner when all lines are <hr> (max(60, *[]) on empty sequence).

Test plan

  • tests/utils/test_server.py — 6 new TestPrintBanner tests cover: alignment, ASCII opt-in, cp1252 stdout, per-line UnicodeEncodeError fallback, hr-only banner
  • tests/utils/test_pyinstaller_utils.py — 2 new tests cover require_ui_assets accepting a built tree and rejecting an unbuilt one
  • tests/web/test_web_ui_assets.py — new file covers web and vis apps serving 503 + explanatory HTML when index.html is absent
  • CI: Linux and Windows installer workflows should now successfully build and embed the frontend bundles before freezing

Summary by CodeRabbit

Release Notes

  • New Features

    • Startup banners now use ASCII characters on legacy Windows consoles for improved compatibility.
  • Bug Fixes

    • Windows and Linux installers now build the web and visualization UI bundles before packaging, preventing 404 errors.
    • Applications gracefully handle missing UI assets by displaying a helpful error page with build instructions.
  • Tests

    • Added tests for missing UI asset handling and banner rendering with ASCII fallback support.

Windows and Linux native installers froze the app without building the
gitignored web/vis frontend bundles, so `pythinker web` opened a browser
onto `GET /?token=… → 404 Not Found`. Both installer workflows now build
the bundles before PyInstaller (matching the PyPI release flow). Every
PyInstaller spec aborts loudly when bundles are missing, and the apps
serve an explanatory 503 page on `/` as a last-resort fallback instead of
a bare 404.

The startup banner raw-printed Unicode block art, which garbled on legacy
Windows code pages (e.g. cp1252) and raised UnicodeEncodeError on
redirected stdout. The banner now honors the existing ASCII-glyph detection
with width-preserving fallbacks and degrades per line instead of crashing.
Also fixes a latent TypeError in `print_banner` when all lines are `<hr>`.
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 426b898b-c256-409e-9364-4146bc74dcac

📥 Commits

Reviewing files that changed from the base of the PR and between e24753b and 7502926.

📒 Files selected for processing (14)
  • .github/workflows/linux-installer.yml
  • .github/workflows/windows-installer.yml
  • CHANGELOG.md
  • packages/linux-installer/pythinker.spec
  • packages/windows-installer/pythinker.spec
  • pythinker.spec
  • src/pythinker_code/utils/pyinstaller.py
  • src/pythinker_code/utils/server.py
  • src/pythinker_code/vis/app.py
  • src/pythinker_code/web/app.py
  • tasks/todo.md
  • tests/utils/test_pyinstaller_utils.py
  • tests/utils/test_server.py
  • tests/web/test_web_ui_assets.py

📝 Walkthrough

Walkthrough

PyInstaller frozen builds now enforce UI bundle presence at build time and handle missing assets gracefully at runtime. Installer workflows build web/vis bundles before freezing; PyInstaller specs validate they exist and abort if missing. If assets are missing at runtime, apps serve informative 503 fallback pages. Startup banners are hardened against Windows console Unicode failures with ASCII degradation.

Changes

UI Bundle Validation and Fallback

Layer / File(s) Summary
PyInstaller build-time validation
src/pythinker_code/utils/pyinstaller.py, pythinker.spec, packages/linux-installer/pythinker.spec, packages/windows-installer/pythinker.spec, tests/utils/test_pyinstaller_utils.py
require_ui_assets() validates that web/static/index.html and vis/static/index.html exist under the resolved package root and aborts via SystemExit if missing. All three PyInstaller specs (main, Linux, Windows) call this check to fail fast before Analysis when bundles are absent. Tests verify both success and failure paths.
Installer workflow build steps
.github/workflows/linux-installer.yml, .github/workflows/windows-installer.yml
Linux and Windows workflows now set up Node.js 24 with npm caching and run build_web.py and build_vis.py before PyInstaller freezing, ensuring bundles exist before the build-time validation runs.
App-level UI fallback and testing
src/pythinker_code/utils/server.py, src/pythinker_code/web/app.py, src/pythinker_code/vis/app.py, tests/web/test_web_ui_assets.py
Web and vis apps conditionally mount static files only when index.html exists; if missing, they serve a 503 with missing_ui_page() explaining the missing assets and build command. Integration tests monkeypatch STATIC_DIR to simulate missing bundles and verify both apps return 503 with appropriate guidance.
Banner rendering robustness
src/pythinker_code/utils/server.py, tests/utils/test_server.py
Startup banners now gracefully fall back to ASCII glyphs when stdout cannot encode Unicode, handling per-write UnicodeEncodeError without crashing. Width calculation is fixed for edge cases (all <hr> lines). Tests cover ASCII opt-in, legacy cp1252 stdout, strict ASCII enforcement, and all-<hr> edge case.
Changelog and task documentation
CHANGELOG.md, tasks/todo.md
Changelog documents the installer fix and banner improvements for users; task notes detail root cause, implementation, and verification checklist for maintainers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.15% which is insufficient. The required threshold is 70.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title follows conventional commits format (fix: ) and clearly summarizes the main changes: installer web UI 404 resolution and PowerShell banner Unicode handling.
Description check ✅ Passed Description comprehensively covers changes, test plan, and objectives. Related issue section is missing but all critical content is present and well-organized.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/installer-web-404-banner-unicode

Comment @coderabbitai help to get the list of available commands and usage tips.

@elkaix
elkaix merged commit 2d7b17e into main Jun 10, 2026
28 checks passed
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.74359% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pythinker_code/utils/pyinstaller.py 75.00% 1 Missing and 1 partial ⚠️
src/pythinker_code/vis/app.py 80.00% 0 Missing and 1 partial ⚠️
src/pythinker_code/web/app.py 80.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@elkaix
elkaix deleted the fix/installer-web-404-banner-unicode branch June 10, 2026 23:47
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.

1 participant