Repository navigation
Write code with file tools in the sandbox, and check it in the sandbox's browser - #70
Merged
Merged
Conversation
…open its own server in its browser write_file and edit_file write in the sandbox through its kernel, where shell heredocs broke on quoting, and each change is an event the app can show. file_view reads a picture the assistant made in /workspace. On the sandbox's desktop, browser_open may open a server the assistant runs there, and pages of that server only; the sandbox's own services and every other local address stay closed. The room test sizes its small room from the instructions, so a new instruction line no longer breaks it.
…e the task works A Code tab appears once a task writes a file: a tab per file, read-only, with the lines an edit changed marked and brought into view; a file a command made is read from the sandbox when opened. While a task of the open thread works, the panel turns to its terminal for a command, its screen for the browser and its code for an edit. A tab the owner picks holds for the rest of that task.
There was a problem hiding this comment.
🟡 Changes recommended
A critical same-origin navigation bypass remains unresolved, alongside unbounded file reads and regressions in file editing and attachment viewing.
6 open issues
Restrict page navigation to the initiating origin · New Handle uncertain edit outcomes before retrying · New Generate edit excerpts from the complete updated file · New Preserve attachment aliases for video frame extraction · New Preserve line endings during exact-text edits · New Bound file reads and reject non-regular files · New
What changed in this PR
Adds sandbox file tools and local web previews so coding tasks can create, edit, and inspect their work.
Changes:
- Adds file writing, exact-text editing, change events, and a text-reading endpoint.
- Enables sandbox image viewing and loopback browsing in computer mode.
- Adds coverage and makes the context-capacity test adapt to instruction size.
| File | Description |
|---|---|
tests/test_parallel.py |
Sizes test capacity from instructions. |
tests/test_code_tools.py |
Tests file tools, images, browsing, and file reads. |
coderunner/server/gateway.py |
Adds the sandbox text-file endpoint. |
coderunner/sandbox/files.py |
Implements kernel-backed file operations. |
coderunner/browser/broker.py |
Allows selected sandbox loopback servers. |
coderunner/agent/tools.py |
Registers file tools and emits change events. |
coderunner/agent/loop.py |
Updates coding and preview instructions. |
Review effort: Balanced
Comment on lines
+1299
to
+1302
| origin = f"{host}:{port}" | ||
| if chosen: | ||
| self._built.add(origin) | ||
| return origin in self._built |
Comment on lines
+241
to
+243
| except (httpx.TransportError, OSError): | ||
| if last or not await brought_back(): | ||
| return SANDBOX_DOWN |
| show_file(ctx, path, found, op="edited", line=line, until=line + new.count("\n")) | ||
| times = f" ({found['count']} places)" if found.get("count", 1) > 1 else "" | ||
| return (f"Edited {path} at line {line}{times}; it has {found.get('lines', 0)} lines now:\n" | ||
| + sandbox_files.excerpt(found.get("body", ""), line, new)) |
Comment on lines
+1109
to
+1112
| wanted = str(args.get("path") or "").strip() | ||
| if wanted.startswith(SANDBOX_ROOTS) and getattr(svc, "sandbox", None) is not None and \ | ||
| not files.folders.inside(wanted): | ||
| return await view_own(wanted, ctx) |
| p.parent.mkdir(parents=True, exist_ok=True) | ||
| p.write_text(a["content"], encoding="utf-8") | ||
| elif a["op"] == "edit": | ||
| text = p.read_text(encoding="utf-8") |
Comment on lines
+65
to
+70
| raw = p.read_bytes() | ||
| if a["op"] == "read" and b"\0" in raw[:8192]: | ||
| return {"error": "binary", "size": len(raw)} | ||
| body = raw.decode("utf-8", errors="replace") | ||
| out.update(lines=body.count("\n") + (1 if body and not body.endswith("\n") else 0), size=len(body), | ||
| body=body[:a["shown"]], cut=len(body) > a["shown"]) |
…r write overtook The write's tool event comes before its file, so with nothing to show the panel went to Screen and stayed there. A live file now applies the follow, unless the owner picked a tab. A read of a file a command changed is dropped if a newer write of that file came while it was read.
…le it stays on that origin
…e sandbox's memory
Show the code a task writes in a Code tab, and follow the task across the panel
mkagenius
approved these changes
Dec 3, 2026
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.


Coding tasks wrote files through shell heredocs, could not look at their own screenshots, and could not open the page they built: the sandbox browser refused 127.0.0.1.
write_fileandedit_filewrite in the sandbox through its kernel (onefilessession, run as a function so nothing is left in it). An edit replaces exact text found once, or every place withall=true, and returns the changed lines numbered. A relative path starts in the shell's directory.fileevent with the file as it now is (first 64K characters), and a command run in/workspaceis followed by afiles_changedevent naming what it made. These feed the Code tab (next PR).GET /api/sandbox/file?path=reads a text file from the sandbox for that tab. Read-only, text only.file_viewlooks at a picture under/workspace,/app,/tmpor/rootin the sandbox, resized there.browser.mode"computer", Chrome runs on the sandbox's desktop, so its loopback is the sandbox. The assistant may now open a server it runs there (browser_open http://127.0.0.1:8765/), and pages may move within that same origin. Ports of the sandbox's own services (8222, 8888, 3000, 5900) and the admin port stay closed, as do private networks, page-led navigation to any other loopback port, and loopback in every other browser mode.Tests:
tests/test_code_tools.py(a fake kernel that runs the real script), full suite 1288 passing.