Skip to content

Refactor runtime callbacks: pass UpdatedFile via onOutput instead of calling writeFile internally#174

Merged
na-trium-144 merged 2 commits intomainfrom
copilot/update-runtime-command-types
Feb 28, 2026
Merged

Refactor runtime callbacks: pass UpdatedFile via onOutput instead of calling writeFile internally#174
na-trium-144 merged 2 commits intomainfrom
copilot/update-runtime-command-types

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Runtime implementations were directly calling EmbedContext.writeFile() to persist file changes, tightly coupling runtimes to the embed context and making it impossible to observe file updates from call sites.

Changes

New UpdatedFile type (runtime.tsx)

export interface UpdatedFile {
  type: "file";
  filename: string;
  content: string;
}

RuntimeContext signature updates

  • runCommand: onOutput: (output: ReplOutput | UpdatedFile) => void
  • runFiles: onOutput: (output: ReplOutput | UpdatedFile) => void

Worker API (worker/runtime.tsx, *.worker.ts)

  • WorkerAPI.runCode / runFile return Promise<void> instead of Promise<{ updatedFiles: Record<string, string> }>
  • Workers (pyodide, ruby, jsEval) now call onOutput({ type: "file", filename, content }) per updated file rather than returning a batch record
  • WorkerProvider removes writeFile dependency entirely

TypeScript runtime (typescript/runtime.tsx)

  • Removed useEmbedContext / writeFile dependency
  • Emitted JS files are passed via onOutput and merged locally before forwarding to jsEval.runFiles

Call sites (exec.tsx, repl.tsx)

  • Both now intercept output.type === "file" in the callback and call writeFile() themselves, keeping file persistence in the UI layer where it belongs

Tests (tests.ts)

  • defineTests drops the filesRef parameter
  • "files modified by command/script" tests now assert directly on UpdatedFile items collected from the callback, removing the setTimeout polling hack

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • workers.cloudflare.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node node_modules/.bin/next lint (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 28, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
my-code ee5ab63 Commit Preview URL

Branch Preview URL
Feb 28 2026, 09:26 AM

Copilot AI changed the title [WIP] Update runCommand and runFiles types in RuntimeContext Refactor runtime callbacks: pass UpdatedFile via onOutput instead of calling writeFile internally Feb 28, 2026
@na-trium-144 na-trium-144 marked this pull request as ready for review February 28, 2026 09:36
@na-trium-144 na-trium-144 merged commit 4e7dd62 into main Feb 28, 2026
4 checks passed
@na-trium-144 na-trium-144 deleted the copilot/update-runtime-command-types branch February 28, 2026 09:36
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.

2 participants