Skip to content

fix: keep the playground's portable IDE rules free of the citry package - #389

Merged
JuroOravec merged 1 commit into
mainfrom
fix/portable-ide-self-contained
Oct 25, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
fix/portable-ide-self-contained

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Supersedes #388. The fast gate reports the playground's copy of the portable IDE rules as stale. Rebuilding it as it stands would break the playground's editor analysis, so this PR fixes the source first.

What was wrong

  • How the playground loads the rules: the docs playground runs its editor analysis in a browser Worker (docs_site/_internal/frontend/src/analysis_worker.js). The Worker installs only citry-core in Pyodide, writes docs_site/static/playground/portable_ide.py as the module citry_portable_ide, imports it, then runs analysis_adapter.py. The citry package is never installed there.
  • What perf: walk parsed templates in check and the LSP without one Python call per level #377 changed: it made packages/py/citry/citry/_portable_ide.py, the source of that copy, import citry._walk. A rebuilt copy then fails with ModuleNotFoundError: No module named 'citry._walk', and the editor shows no analysis.
  • Why no test caught it: analysis_adapter.py fell back to citry._portable_ide when citry_portable_ide was missing, so the docs tests ran the source instead of the generated copy.

The change

  • The source: _portable_ide.py walks nested templates with a list of iterators instead of citry._walk. It still uses a fixed number of Python frames however deep the templates nest, and records tags in the same order. Its docstring now says it may import only the standard library and citry_core, and why.
  • The copy: docs_site/static/playground/portable_ide.py is rebuilt with pnpm --dir docs_site/_internal/frontend build.
  • The adapter: analysis_adapter.py imports citry_portable_ide only, as the Worker provides it.
  • The tests:
    • The adapter fixture installs the generated copy as citry_portable_ide, so every adapter test runs the copy the browser runs.
    • A new test, test_generated_portable_rules_load_without_the_citry_package, loads the copy in a subprocess with citry blocked, runs template_tag_uses on a nested template, and runs the adapter beside it.
    • With a copy built from main's source (fix(docs): rebuild the playground's copy of the portable IDE helpers #388's file), the new test fails with the error above.

Checks

  • Tests: docs_site/tests/test_playground_analysis.py (10 tests), test_analysis.py and test_check_depth_frames.py (54 tests) pass.
  • Generated copies: pnpm --dir docs_site/_internal/frontend run check, the protocol Python copies, the VS Code bundle, the citry-ui assets and scripts/validate.py pass.

No changelog entry: the docs site is not a published package.

🤖 Generated with Claude Code

The docs playground's analysis Worker installs citry-core in Pyodide,
writes `portable_ide.py` (generated from `citry/_portable_ide.py`) as the
module `citry_portable_ide`, and imports it. The `citry` package is not
installed there. #377 made `_portable_ide.py` import `citry._walk`, so a
rebuilt copy would fail with ModuleNotFoundError and leave the editor
without analysis. The committed copy had not been rebuilt, which the
fast gate reports as stale.

- `_portable_ide.py` walks nested templates with a plain list of
  iterators instead of `citry._walk`. It still uses a fixed number of
  Python frames however deep the templates nest, and records tags in the
  same order. Its docstring states the import rule and why.
- `docs_site/static/playground/portable_ide.py` is rebuilt from it.
- `analysis_adapter.py` imports `citry_portable_ide` only. It used to
  fall back to `citry._portable_ide`, so the docs tests ran the source
  rather than the generated copy and could not see this break.
- The docs tests load the generated copy as the Worker does: the adapter
  fixture installs it as `citry_portable_ide`, and a new test loads it in
  a subprocess with `citry` blocked, then runs it and the adapter. That
  test fails with a copy built from `main`'s source.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit 745e959 into main Oct 25, 2026
26 of 28 checks passed
@JuroOravec
JuroOravec deleted the fix/portable-ide-self-contained branch October 25, 2026 10:28
JuroOravec added a commit that referenced this pull request Oct 25, 2026
The minor and patch updates change what esbuild bundles into
playground.js and live_code_runtime.js, so docs-check reported both as
stale. Rebuilt with `pnpm --dir docs_site/_internal/frontend build` on
top of main, which already carries the current portable_ide.py (#389).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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