Edit a running project
Write editor changes to the virtual filesystem and observe updates from running processes.
Development servers and tools observe the same filesystem that your editor uses. Write a file and the running tool can rebuild or reload it.
let pendingWrite: ReturnType<typeof setTimeout> | undefined
editor.onDidChange((value) => {
clearTimeout(pendingWrite)
pendingWrite = setTimeout(() => {
void startpod.fs.writeFile("src/App.jsx", value)
}, 80)
})Debounce high-frequency editor updates to avoid triggering a build for every keystroke.
Observe filesystem changes
Processes can also create or modify files. Subscribe to keep a file tree or editor model current:
const watcher = startpod.fs.watch(
".",
{ recursive: true },
(event, path) => {
console.log(event, path)
}
)
// Later
watcher.close()Use stat().revision when you must order rapid writes. It is a monotonic pod-local revision, so it is more reliable for ordering than millisecond timestamps.
Handle conflicts
Treat the filesystem as the source of truth. If both the editor and a running process write the same file, compare revisions and ask the user before replacing unsaved editor content.