Skip to content

Conversation

brunogrbavac
Copy link
Collaborator

File Watching Support to Daytona SDKs

Description

Adds real-time file watching capabilities to both TypeScript and Python SDKs via WebSocket connections.

Features

  • Real-time file monitoring (create, modify, delete, rename)
  • Cross-platform support (Node.js, Deno, browser, serverless)
  • WebSocket-based communication
  • Both sync and async Python support

Key Changes

  • TypeScript SDK: Extended FileSystem class with watchFiles() method
  • Python SDK: Added watch_files() method with async context manager
  • Infrastructure: WebSocket proxy support, daemon filewatching with fsnotify
  • Examples: Added file watching examples for both SDKs

@brunogrbavac brunogrbavac marked this pull request as draft August 21, 2025 18:34
@brunogrbavac brunogrbavac requested a review from MDzaja August 21, 2025 18:34
Copy link
Collaborator

@MDzaja MDzaja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, run yarn docs && yarn nx build docs.

Comment on lines +54 to +83
class WatchHandle:
"""Handle for a file watching session."""

def __init__(self, close_func: Callable[[], None]):
"""Initialize a new WatchHandle.

Args:
close_func: Function to call to stop watching
"""
self._close_func = close_func

async def close(self) -> None:
"""Stop watching the directory."""
self._close_func()


class SyncWatchHandle:
"""Synchronous handle for a file watching session."""

def __init__(self, close_func: Callable[[], None]):
"""Initialize a new SyncWatchHandle.

Args:
close_func: Function to call to stop watching
"""
self._close_func = close_func

def close(self) -> None:
"""Stop watching the directory."""
self._close_func()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d move these into _sync/_async file_watcher.py, since they differ per module. I’d also rename the async version to AsyncWatchHandle and the sync version to WatchHandle (auto-generated from the async one) to stay consistent with the naming convention of other existing classes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add this to docs:file-watcher and docs:async-file-watcher in package.json so the documentation gets autogenerated under the File Watcher page.

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