Skip to content

Single page viewer - #10

Merged
Weilkiti merged 9 commits into
mainfrom
single-page-viewer
Nov 26, 2026
Merged

Weilkiti merged 9 commits into
mainfrom
single-page-viewer

Conversation

@Weilkiti

Copy link
Copy Markdown
Collaborator

No description provided.

The viewer as one web page that reads the model with the SysML v2 API directly
from the browser, adapted to SYSMOD v5:
- web/index.html + sysmod-viewer.css: the page
- web/sysmod-viewer-core.js: reads the SYSMOD project from the elements of a
  commit (atlas, problem statement, system idea and objectives, stakeholders,
  needs, requirements, use cases, six context diagrams, completeness checks)
- web/sysmod-viewer-api.js: SysML v2 API client (paging via Link or
  page[after], token, relay)
- web/sysmod-viewer.js: the interface, SVG context diagrams without a CDN
- web/serve.py: standard library only; serves the page and relays read-only
  requests to any SysML v2 server (CORS, http), localhost only
- tests/test_web_serve.py: rules of the relay and real HTTP with a fake server
- README: the single page is the recommended viewer; Flask stays for editing,
  AI, wizard and MCP

The same JavaScript runs on mbse4u.com/tools/sysmod-viewer/ (with an engine
for .sysml files and an allowlist relay); its tests (81 checks, Delivery Drone
model) pass with these files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H3jemrqbQnRXB9jiZkhv1r
…er; README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H3jemrqbQnRXB9jiZkhv1r
Comment thread web/serve.py Fixed
Comment thread tests/test_web_serve.py Fixed
Comment thread web/serve.py
def do_POST(self):
self.fail(405, "only GET")

def relay(self):
Comment thread tests/test_web_serve.py
self.end_headers()
self.wfile.write(b)

def do_GET(self):
Comment thread web/serve.py
print(f"SYSMOD viewer: http://localhost:{a.port}/ (Ctrl+C to stop)")
try:
server.serve_forever()
except KeyboardInterrupt:
Code scanning: serve.py relayed to any server when ALLOWED_SYSML_SERVER_ORIGINS
was not set (server-side request forgery). Now it always uses the allowlist,
with the default of the Flask server (http://localhost:9000 …), and the server
part of the outgoing request is taken from the allowlist entry, never from the
address the page sent. viewer-config.json lists the allowed servers.

The JavaScript no longer uses regular expressions anchored at the end of
remote text (/\/+$/, /\*+\/\s*$/, /\s*\n\s*/), which can run in quadratic
time on long input; replaced by linear helpers with the same results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H3jemrqbQnRXB9jiZkhv1r
…ility)

Reliability: no single-line if followed by another statement; sort() no longer
inside expressions (toSorted, or a separate statement); the promise of start()
is handled (errors are shown on the page).
Security: no regular expressions with backtracking on remote text; the path
check of serve.py works segment by segment instead of a nested-quantifier
regex; no http literal in the start message.
Maintainability: every function below cognitive complexity 15 (exprText as a
table of expression kinds, readContext split into contextLinks, partOfEnd,
stepOf, matchRole; the API client's get() into request, answerError, readJson;
the interface's render() into one function per section, the diagram into
layout, systemBox, actorBox, drawLink, placeActors; serve.py's check_url and
relay into small functions); no nested ternaries or nested template literals;
fetchBytes and the engine loader at module level; duplicate CSS selectors merged.

Behaviour unchanged: 92 checks of mbse4u.com (Delivery Drone model and
tests/test_sysmod.sysml), tests/test_web_serve.py, and the pages in a browser
(server with and without CORS, relay, token, JSON and .sysml files).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H3jemrqbQnRXB9jiZkhv1r
- promises of event handlers are voided; nextUrl at module scope
- no await in loops: pages are read recursively, JSON files with Promise.all
- reduce() with an initial value; <output> instead of role=status
- serve.py: except OSError (URLError and TimeoutError are OSErrors); no clear-text URL in the start message
- test server: Link header from its own address, not from the Host header

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H3jemrqbQnRXB9jiZkhv1r
…loud (S5332)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H3jemrqbQnRXB9jiZkhv1r
…OSONAR(python:S5332))

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H3jemrqbQnRXB9jiZkhv1r
Comment thread web/serve.py Fixed
@sonarqubecloud

Copy link
Copy Markdown

@Weilkiti
Weilkiti merged commit d715924 into main Nov 26, 2026
9 checks passed
@Weilkiti
Weilkiti deleted the single-page-viewer branch November 26, 2026 06:13
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