-
Notifications
You must be signed in to change notification settings - Fork 126
Description
System details:
Positron and OS details:
Windows 11
Session details:
Positron Version: 2025.12.0 (system setup) build 35
Code - OSS Version: 1.105.0
Commit: 5418e79
Date: 2025-11-06T07:36:41.761Z
Electron: 37.6.0
Chromium: 138.0.7204.251
Node.js: 22.19.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26100
Describe the issue:
Summary
Currently, positron.runtime.executeCode supports an observer that receives error messages when code execution fails, but it doesn’t return standard output when the code completes successfully. This makes it difficult for extensions or clients to capture the printed output of executed code directly.
Motivation / Problem
At present, the only way to access printed output is by writing to a temporary file and reading it back. This workaround is cumbersome and introduces unnecessary I/O overhead and potential race conditions. For example, an extension that runs snippets to produce lightweight feedback or inline results must handle file writes, file cleanup, and synchronization — all of which could be avoided if executeCode exposed stdout.
Proposed Solution
Extend the observer interface to include a callback or event for standard output. For example:
positron.runtime.executeCode(code, ..., {
onOutput: (text) => { /* handle printed output */ },
onError: (err) => { /* handle errors */ },
onComplete: () => { /* handle completion */ },
...
});This would parallel the existing error reporting mechanism and make it much easier to build extensions that need to capture or display output dynamically.
Benefits
- Enables extensions to display code output inline without temp files.
- Reduces file system operations and improves performance.
- Aligns with common patterns in REPL- or notebook-style APIs (e.g., Jupyter, Node.js child_process).
- Simplifies extension development and debugging.
Alternatives Considered
Using temporary files works, but it is an ugly and brittle solution compared to an API-level event.