Repository navigation
Deploy from the browser IDE through the IDE server, which builds, stops, installs and starts (G395) - #977
Open
johannesPettersson80 wants to merge 4 commits into
Open
Deploy from the browser IDE through the IDE server, which builds, stops, installs and starts (G395)#977johannesPettersson80 wants to merge 4 commits into
johannesPettersson80 wants to merge 4 commits into
Conversation
The badge said Not deployed while the project's program ran: its rule, in JavaScript, compared the open tabs with the sources of the last deployment made from the same browser session. The browser now asks the runtime program.sources and forwards it, with the open tabs' unsaved texts, to POST /api/ide/sync-status. The IDE server compares the project's sources, as the build collects and labels them, with the program: in sync when their hash is the program's source_sha256, else modified with each file that differs, not deployed without a program, unknown when the runtime does not answer. The browser renders the answer. The deploy flow's build-first rule still hashes the open tabs; it moves to Rust with the deploy workflow (G395).
…nstalls and starts (G395) The browser IDE's Deploy did not deploy in its main cases. It built the project only when its own hash of the open tabs had changed, then sent the project's .st files without a program image to POST /api/deploy, or to /api/deploy/proxy for another runtime, and stopped nothing: a running runtime refused every deployment, and a stopped remote one restarted its old program while the badge read In sync. Its rules were logic in JavaScript. Specification 11, "Unified Web IDE deploy contract": POST /api/ide/deploy starts a task of the IDE server that reads the runtime's status, builds the project for its target (a computer's CPU or a board), stops a running program and waits up to 10 seconds, deploys the image alone with a cold restart and waits up to 10 seconds for it to run. A refused deployment starts the program that ran before again, warm. A failed build stops nothing. The standalone IDE server answers 409 for a deployment to itself. - web/ide_deploy.rs: the five steps over a DeployTarget, and the task that builds with this executable and streams the build's output into the task panel. - web/ide_deploy/targets.rs: this runtime, through the same code as POST /api/deploy (web/deploy_here.rs, shared with ops_routes.rs), and another runtime through its web interface with the request's token and the connection's credentials. - web/ide_routes/deploy.rs: the route (Admin access, Editor session, 1 MiB body). - ide_tasks.rs: begin_ide_task_job and run_ide_task_process, shared by the tasks. - aux_routes.rs: POST /api/deploy/proxy removed; its helpers are shared with the task. - ide-online.js, ide-commands.js: Deploy confirms and starts the task; the old flow is gone. - The browser IDE guide and a changelog fragment. Tests: web::ide_deploy::tests (10, against a scripted runtime), web_ide_integration part 10 (access and the standalone server), and computer_stopped_keeps_runtime_up's ide_deploy module (deploys to the runtime that serves the IDE and to another one, on real runtimes).
…397) into this branch
…G397) into this branch
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This branch has not been deployed
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.
What
The browser IDE's Deploy deploys. The IDE server builds the project for the runtime's computer or board, stops the runtime's program, installs the new one and starts it cold. The task panel shows each step (G395).
The old Deploy did not deploy in its main cases:
.stfiles toPOST /api/deploy, or toPOST /api/deploy/proxyfor a remote runtime. It sent no program image and stopped nothing.POST /api/deployaccepts a deployment only while the program is stopped (specification 34 §11.2). So while the program ran, every deployment was refused, although the confirmation said the program would restart.src/, and its restart loaded its oldprogram.tpi. The badge still turned In sync, from the hashes of the sources the browser had sent.Built on #976 (G383c), which merges first; #974 and #975 have merged.
The behaviour
Specification 11 has a new section, "Unified Web IDE deploy contract". The browser asks the user to confirm and saves the open tabs. It then starts a task with
POST /api/ide/deploy {target, auth_basic}:targetisnullfor the runtime that serves the IDE, or the address the Online panel connected to. The task:status. Its platform names the build target: a device's board name (esp32c6,stm32u5a9), or the<arch>of a computer's<os>-<arch>. A platform whose target the build does not know ends the task before anything is built or stopped.host, the IDE server's own CPU, is never taken for the runtime's;trust-runtime build --target <target>(specification 44 §4.1, §4.4). A failed build ends the task, and the program keeps running;shutdown, and waits up to 10 seconds forstopped. Otherwise it ends with the state, and nothing is deployed;restart: "cold";running. Otherwise it ends with the state and the fault.A refused deployment writes nothing. If the program ran before, the task starts it again with
restart warmand ends with the refusal. The route needs the web interface's Admin access, asPOST /api/deploydoes, and an Editor session. The standalone IDE server (trust-runtime ide serve) runs no program, so it answers a deployment to itself with 409. The confirmation says that the program stops and that the new one starts cold, with its RETAIN variables at their initial values. The badge asks again after the task.Decisions
I made these under the owner's delegation of 22 and 25 November. They are recorded in the specification:
trust-runtime ctl installsends it. The runtime keeps the files of its project folder, and the image holds the texts of the program's files (specification 44 §5.3), which the badge compares.POST /api/deploychecks a deployment with sources against the running HMI (specification 39 §16.4 item 6) by compiling the sent sources alone, with default settings. A project whosesrc/uses a library outsidesrc/, asmemory_marker_counterusesHmi.Displayfromlibraries/hmi, is refused with 422. Sending the library files too would write them under the target'ssrc/.ctl install, the deployment is not checked against the runtime's HMI. A binding to a variable the new program lacks shows "not in running program". Checklist item G396 covers checking the image itself, for every deployment path alike.POST /api/deploy/proxyis removed. Its only caller was the old flow. The task reaches a remote runtime through the sameproxy_remote_postthat/api/control/proxyuses, with the request's token and the connection's credentials.The fix
web/ide_deploy.rs(new):run_deploy, the five steps over aDeployTargetwith injected build, log and pause, and the task (start_ide_deploy_job,build_for). The task runs the build as a process of this executable, with its output streamed into the task panel.web/ide_deploy/targets.rs(new): the two targets.ThisRuntimeTargetdispatches control requests in this process. Its deployment goes through the same code asPOST /api/deploy.RemoteRuntimeposts to the other runtime's/api/controland/api/deploy.web/deploy_here.rs(new):POST /api/deploy's body after its authorization, shared by the route and the task. It covers the HMI check, the Stopped rule, the write, the HMI activation and the restart.ops_routes.rscalls it, with its behaviour unchanged.web/ide_routes/deploy.rs(new):POST /api/ide/deploy. It checks Admin access, the POST policy, an Editor session, the body (1 MiB) and the active project, then picks the target and starts the task.ide_tasks.rs:begin_ide_task_jobandrun_ide_task_process, split out ofstart_ide_task_jobso that the deploy task shares them. The build, test and validate tasks behave as before.aux_routes.rs: the proxy route is removed.proxy_remote_post,normalize_proxy_responseandProxyBasicAuthare shared with the task.ide-online.jsandide-commands.js:/api/deploy/proxycall.docs/public/start/program-in-browser.md): a section "Deploy Your Project".### Fixedand### Removed.Tests
web::ide_deploy::tests(10), against a runtime that answers from a script and records each request:a_running_program_is_stopped_then_the_new_one_is_deployed_and_started_cold: the exact requests (status, shutdown, the polls, the image withrestart: "cold", the polls) and the log lines. It catches a deployment sent to a running program, sent before the stop is reported, carrying sources or another restart, and a task that ends before the program runs.a_stopped_program_is_deployed_without_a_stop.a_failed_build_leaves_the_program_running: onlystatuswas sent.a_refused_deployment_starts_the_program_that_ran_again_warm.a_refused_deployment_to_a_stopped_program_starts_nothing.a_program_that_does_not_stop_within_ten_seconds_gets_no_deployment: 100 polls 100 ms apart, then no deployment.a_new_program_that_does_not_run_ends_the_task_with_its_state_and_fault.a_device_gets_the_project_built_for_its_board:esp32c6, built foresp32c6.a_runtime_whose_programs_the_ide_does_not_build_gets_nothing:rp2040,linux-armv7,hostandlinux-host. Nothing is built or sent after thestatus.the_target_is_a_computers_arch_or_a_devices_board: Linux, Windows and macOS computers, both boards, andhost.web_ide_integration(part_10, 2):a_deployment_needs_the_admin_access_and_an_editor_session: 401 without the token, 401 without a session, and 403 for a Viewer session.the_standalone_ide_server_refuses_a_deployment_to_itself: 409, and no task started.computer_stopped_keeps_runtime_up(ide_deploy, 2), on real runtimes ofmemory_marker_counterbuilt with this tree's toolchain:the_ide_deploys_the_edited_project_to_the_running_runtime_that_serves_it: while the program runs,src/Main.stis edited to the second step and deployed through the IDE. The task names each step and succeeds. The counter that climbed by one in each scan then climbs by two, and the badge reads in sync.the_ide_deploys_to_another_runtime_through_its_web_interface: runtime A's IDE deploys to runtime B. B's counter climbs by two, and B'ssrc/Main.ststays as it was, since no sources are sent. A keeps running its own program, never stopped, and itsprogram.tpiis unchanged.Mutants, each failing at its own assertion:
restart {"mode":"cold"};Ok(());linux-x86_64;hosttaken for the runtime's target: the target test and the not-built test fail.In the browser (Playwright on the builder, against
trust-runtime runofexamples/web_ui_complete_projectbuilt from this tree). I looked at each screenshot:src/main.stit read Modified (1).state=running.Not run: a device in the loop. The task builds for a board by its board name, and the unit tests prove only that. No deployment to the bench ESP32-C6 was tried, since flashing it is the owner's call.
Checks
On the builder, over the worktree, which holds G383c's head
bd982849cand this change:-D warningson trust-runtime, all targets and features;web::, 348, withweb::ide_deploy's 10);web_ide_integration(34, with part 10's 2);computer_stopped_keeps_runtime_up(17, withide_deploy's 2), with the toolchain of this tree;api_smoke,debug_control,complete_programandruntime_reliability;x86_64-pc-windows-gnu) on trust-runtime;architecture-doctor --full-map: every check passes but FULLMAP-RUNTIMEBOUND and FULLMAP-RUNTIMESAFE, which need.gitand always fail on the builder's copy;After
main. G383a tookmainatd794363f6and #966'spin-project-lite0.2.19 (G397,e90222778), without which Supply Chain fails on every pull request, and G383b, G383c and G395 took it in turn. The top of the stack, which holds all four, was checked again on the builder: fmt, the changelog fragments, Clippy on trust-runtime-services and trust-runtime (all targets and features), rustdoc on trust-runtime, trust-runtime-services' library tests, trust-runtime's web library tests,native_image_header,native_small_program,web_ide_integration,computer_stopped_keeps_runtime_up, the runtime vertical and Windows Clippy. Each branch passed the pre-push contracts.Found while building this, and kept for their own lanes:
ctl install, an image-onlyPOST /api/deployor this task.