Repository navigation
ariadne: py_console, a Python console for the x hosts (P2, first part) - #1195
Merged
Merged
Conversation
A shipped component, cvc://components/py_console.ari: a text_view
scrollback, a message_input with a Run button, and Clear. It is plain
.ari over widgets every backend already draws, so it works the same in
ariglx (ImGui), arix (the terminal) and ariglx-web (the browser), with
no core widget, loader or backend change.
A document turns it on with `console: true` in its python: block. The
Python engine then exports two natives on that document's ScriptLane:
(python-console ID SOURCE) and (python-console-clear ID). Each
submission runs as one notebook-style cell in the namespace the block
ran in (_ariadne_console, src/ariadne_python/ariadne_console.py):
- stdout and stderr are captured (64 KB a cell), and the last
expression's repr is shown and kept as `_` in that namespace (never
builtins._, which is process-wide);
- input() reads an empty stdin and raises EOFError, so a cell under
arix never reads the terminal;
- an exception shows its traceback from the cell's own frames, its
lines registered in linecache; SystemExit ends the cell, not the
document;
- the scrollback echoes the cell after >>> and ..., and keeps 2000
lines.
The natives return a typed dict {ok output log}; DSL values stay typed.
Without console: true they raise PermissionError. unload() puts the
refusing natives back, so the old namespace goes with its load and a
reload that drops console: true has no console.
The console module is embedded on its own (kAriadneConsoleSource):
ariadne_python.py is one configure_file literal, already half of MSVC's
16 KB cap. document_module_name() is now the one place that names a
block's module. No registry and no new statics: the consoles hang off
the lane's natives. Server hosts never reach load_block, so arisrvx is
unchanged.
Docs: ARIADNE.md 9.6 (console: and "A console"), the roadmap's 4.5 as
built, and its P2 row (left: py_editor, jedi completion, history keys,
display()).
Tests: arix_py_console (expression, print and stderr, a multi-line cell,
the shared namespace, _, a traceback without engine frames, SyntaxError,
SystemExit, input(), the output cap, clear, two consoles, bad
arguments), arix_py_console_off, arix_py_console_terminal,
ari_python_console_needs_arix; AriadneComponents.ShippedComponentsLoadClean
picks up py_console.ari; the ariglx-web smoke case "the py_console
component runs a cell in the page".
…xes) A cell no longer swaps sys.stdin, sys.stdout and sys.stderr for the process. A cell gives up the GIL, so other threads run while it does: an async export on the pool, or a thread of the document's. Before, their print() landed in the cell's output and scrollback, their input() got EOFError, and a redirect_stdout of their own that overlapped a cell could leave sys.stdout on a dead StringIO for the rest of the process. - The first document with a console puts a _Stream in each of the three, and every later load with a console checks again. The cell's thread gets the running cell's streams (a ContextVar the cell sets and resets); every other thread, and any thread between cells, gets the stream the proxy stands in for. A cell's streams are closed when it ends, so a context it leaves behind falls back too. A stream that was None reads nothing and writes nowhere. - linecache: a cell's file name carries its load's tag (<console ID:N #xxxxxx>), so a reload or the next document no longer overwrites an earlier load's entries. Clear takes a console's cells out. When the natives let go of a load's consoles they close them, which takes all of that load's cells out. - arisrvx: a server document's console: was accepted silently and did nothing. Its load now warns that the key is ignored. - arix_py_console_terminal matches the output on the scrollback's row, and fails on a line of the process's own stdout. Tests: arix_py_console gets a threads case (an async export prints while a cell runs, and the cell's output is its own), a trim case (2500 lines keep the last 2000, from "500" to "2499") and a linecache check in clear. The new arix_engine_test hosts the engine under one AppRuntime and reloads it from a console document into one with no python: block: both natives raise PermissionError, and the first load's cells have left linecache when a third load's block looks. With the old console module and no unload override, the threads case and arix_engine_test fail. Docs: ARIADNE.md 9.6 and the roadmap's 4.5 now say that a document whose python: block lacks console: true gets a PermissionError, and one with no python: block has neither function. The Run button is ImGui's (ariglx, ariglx-web), and arix runs a cell with Enter.
pycvc-linux builds the scripting hosts by name (ari, arix, ariglx), and its scripting-host step runs every test matching ^arix_. This branch adds arix_engine_test, which matched but was never built, so ctest reported it "Not Run" and the job failed. The build step now names it too.
…ata scan passes
transfix
enabled auto-merge (squash)
November 13, 2026 03:54
…lotlib's and display()
…app (master builds again) #1197's ariadne_wasm_browser_test.cpp (built natively as ariadne_wasm_transform_test wherever wasmtime is found, and in the wasm-guests node job) still called register_script_engine(engine) and unregister_script_engine("wasm"), which #1203 replaced with the (app, ...) forms. #1197's CI ran before #1203 landed, so master at accadc3 doesn't compile it. As #1203 did for ariadne_wasm_test.cpp: SetUp no longer registers the engine, and the TearDown that unregistered it goes. Each of the file's 18 AppRuntimes already calls use_script_engine(engine), which registers it on that runtime's app.
… app #1203 gives every cvc command its app as an argument, removes cvc_app() and makes cvc::ariadne::load_string take the app. It merged after #1168 and #1180, whose new code still used the old forms, so master does not build: - src/cvc-cli/main.cpp: cmd_trace (#1168) takes cvc::app & like the other commands and replays on it, not cvc_app(). - src/cvc/tests/ariadne_runtime_test.cpp: #1180's three AriadneRichText tests pass their app to load_string; each already makes one.
…s), so py_console's CI builds
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
CI at 9d002d1 built it on master as of 09:28, after #1197 added ariadne_wasm_browser_test.cpp with register_script_engine calls that predate #1203 (all three package-linux lanes and wasm-guests failed to compile it). Master fixed that in #1229, and the load_string calls #1169 left in the loader and chart tests in #1190. This merge takes master as it is now, so CI builds on those fixes. No conflicts. Master's new natives (#1190's file-pick and http-upload, #1195's py_console, #1169's chart) build against this branch's call_args context as they are. Checked on Windows (MSVC Release): full build; the Ariadne, net, HTTP, state_exec, groups, slices, async-call, cycle-registry and multi-app ctests, 1336/1336. ariadne_wasm_browser_test is not built here (it needs wasmtime or Emscripten); master's CI builds it.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…#1222-#1225, #1229) Master's #1190 (file-pick and http-upload) was written for a single async host; this branch runs an isolated document's programs on its own group's host, on a pool worker in an `any` group. - net_intrinsics.cpp: StartedRequest takes master's deliver()/on_outcome, settling through the host's finisher. http-upload is its own provider, `any` as the requests are: it parks on the calling program's host (ictx.host), takes its progress path from ictx.root_path (no tree walk on a worker), and a started upload (a browser page) keeps the host's finisher, not the host. - ariadne.cpp: file-pick, file-info and file-forget bind into the program's env as they are, in every group (install_backend_verbs), not through the backend verbs' host_proxied wrapper, which cannot park an async verb. file-pick parks on the program's own host, claims the Runtime's picker hub under its lock where it is called, and opens the picker on the host thread (exec_pool::run_on_host; inline when called there). Its answer goes through the host's finisher, as the host may be gone by then. - ci.yml: the sanitizer list keeps this branch's tests and master's point_classes_test. - STATE_EXEC_THREADED.md: rows for http-upload, the file verbs, and the contours and point-classes providers. The last two are registered without a kind, so they are host_only, and an isolated document in an app that installs them goes to a host-affinity group. - New test: AriadneIsolatedDocs.FilePickOpensItsPickerOnTheFramesThread.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
One conflict, master's #1195 (py_console) in the class this branch reworked, python_engine.cpp's PythonScriptEngine: - load_block keeps master's order (the block's object lives on for consoles_for) with this branch's take_error(helper); unload comes in beside the engine's private EngineState pointer. - export_console's natives described their own errors through the process-wide g_helper this branch removed. export_console now takes the helper and its natives hold a reference of their own, let go as their consoles are; unload passes none. - The engine's constructor describes a console that fails to load with st.helper, which is up by then. Checked on Windows (MSVC Release): full build; format clean on changed lines; the host, Python and multi-app ctests with master's console tests, 47/47 (skips as before: no FTXUI or matplotlib here), among them arix_engine_test, which reloads documents with and without a console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first part of P2 in docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md:
py_console(§4.5, "The console widget"; ARIADNE.md §9.6).What it adds
cvc://components/py_console.ari. It has atext_viewscrollback, amessage_inputand Clear. It is plain .ari over widgets every backend already draws, so it works the same inariglx(ImGui),arix(the terminal) andariglx-web(the browser). No core widget, loader or backend change. ImGui's input line has a Run button (ariglx,ariglx-web);arixruns a cell with Enter.console: truein a document'spython:block. The Python engine then exports(python-console ID SOURCE)and(python-console-clear ID)on that document's ScriptLane.python:block lacksconsole: true, both raisePermissionError.python:block has neither function:unload()puts the refusing natives back, so a reload that drops the console takes it away.arisrvxwarns that a server document'sconsole:is ignored. Before, it was accepted silently._ariadne_console, src/ariadne_python/ariadne_console.py):_in that namespace, neverbuiltins._.input()gets EOFError, so a cell underarixnever reads the terminal.SystemExitends the cell, not the document.<console ID:N #xxxxxx>). Clear removes a console's cells, and closing a load's consoles removes all of that load's cells.>>>and..., and keeps 2000 lines.sys.stdin,sys.stdoutandsys.stderrhold proxies, and a ContextVar hands the running cell's streams to its own thread alone. Pool exports and the document's own threads keep the real streams, and a cell never reassigns them. A stream that wasNonereads nothing and writes nowhere.{ok output log}. DSL values stay typed.kAriadneConsoleSource).ariadne_python.pyis one configure_file literal, already half of MSVC's 16 KB cap.document_module_name()is now the one place that names a block's module. No registry and no new statics: the consoles hang off the lane's natives.console:and "A console"), the roadmap's §4.5 "as built", and its P2 row.Two commits: the feature, then review fixes (thread-only capture, per-load linecache names, the
arisrvxwarning, a stricter terminal test).Tests (Windows, sandipaws)
ctest-ox-py-console.bat, CTEST_RE^(arix_|ari_python_|ari_chat_component|ari_docset|AriadneComponents\.): 21 passed, 1 failed.arix_python_program:ModuleNotFoundError: pycvc_gl. This tree builds withCVC_BUILD_PYCVC_GL=OFF, and that test's app.py importspycvc_gl. This change doesn't touch it.arix_py_console: passed, 16 cases. They include the new threads case (an async export prints while a cell runs, and the cell's output is its own), the trim case (2500 lines keep the last 2000, from "500" to "2499") and the linecache check in clear.arix_engine_test(new gtestArixEngine.AReloadIntoADocumentWithNoPythonBlockTakesTheConsoleAway): passed, 1/1.arix_py_console_terminal, with the new PASS/FAIL regexes: passed.^pycvc_ariadne: 2 passed, 0 failed (pycvc_ariadne,pycvc_ariadne_server).unloadoverride.arix_engine_testfailed, andarix_py_consolefailed on threads and clear, as expected. Then I restored the real sources and rebuilt.python -Imade 7 checks, and all 7 behaved as intended:redirect_stdout;input();Nonestream;git-clang-format --diffagainst the merge base): no changes.Left out
arisrvxserver warning. This tree doesn't build arisrv (no gRPC or WS). I checked the warning with the Python probe instead. It drivesariadne_server._Program.load_blockthrough a fake link, and throughpycvc_ariadne_server.MAX_TEXT(1 MB) trim case. The finding asked only for the 2000-line trim.ariglx-webbrowser smoke run. The web tree here only compiles the touched sources and doesn't link. The new smoke case, "the py_console component runs a cell in the page", is in arigl_web_smoke.mjs.py_editor(ImGuiColorTextEdit needs a cvcpkg recipe), jedi completion, the console's history keys, anddisplay().Merging waits on Joe's review.