From c2a9689e2b8c6db8c5cffd05f33521cd7b68400d Mon Sep 17 00:00:00 2001 From: Myles Duncan-King Date: Tue, 9 Jun 2026 14:03:19 +0100 Subject: [PATCH] Fix Jump hot reload ignoring nativephp.hot_reload.watch_paths Co-authored-by: Cursor --- resources/jump/websocket-server.php | 17 ++++++++++++++++- src/Commands/JumpCommand.php | 13 +++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/resources/jump/websocket-server.php b/resources/jump/websocket-server.php index fed31f1..2c9b870 100644 --- a/resources/jump/websocket-server.php +++ b/resources/jump/websocket-server.php @@ -189,7 +189,8 @@ // page props, scroll position). Only watch them when Vite isn't running. $lastModTimes = []; $lastReloadTime = 0; - $watchPaths = ['app', 'resources', 'routes', 'config']; + $watchPaths = jumpResolveWatchPaths(); + jumpLog('File watcher paths: '.implode(', ', $watchPaths)); $serverExtensions = ['php', 'blade.php']; $clientExtensions = ['js', 'jsx', 'ts', 'tsx', 'vue', 'css', 'scss', 'sass', 'less']; @@ -252,6 +253,20 @@ function jumpLog($message) fwrite(STDERR, '['.date('H:i:s').'] [Jump] '.$message."\n"); } +function jumpResolveWatchPaths(): array +{ + $defaults = ['app', 'resources', 'routes', 'config']; + $fromEnv = getenv('JUMP_WATCH_PATHS'); + if ($fromEnv !== false) { + $decoded = json_decode($fromEnv, true); + if (is_array($decoded) && $decoded !== []) { + return $decoded; + } + } + + return $defaults; +} + /** * Resolve the live Vite dev-server origin (host + port) from the Laravel * Vite hot file. Returns [host, port] — host is what we should actually diff --git a/src/Commands/JumpCommand.php b/src/Commands/JumpCommand.php index f3a12ce..24a5ecf 100644 --- a/src/Commands/JumpCommand.php +++ b/src/Commands/JumpCommand.php @@ -359,6 +359,10 @@ private function startBridgeServer(int $wsPort, int $bridgePort, int $viteProxyP $logFile = $logDir.'/jump-bridge.log'; @file_put_contents($logFile, '=== '.date('Y-m-d H:i:s')." bridge server starting (ws={$wsPort} tcp={$bridgePort} vite_proxy={$viteProxyPort}) ===\n", FILE_APPEND); + $watchPaths = config('nativephp.hot_reload.watch_paths', [ + 'app', 'resources', 'routes', 'config', + ]); + // Run in background (not Workerman daemon mode — it breaks the event loop). if (PHP_OS_FAMILY === 'Windows') { // `&` is a command separator on Windows (not "background"), and the @@ -390,10 +394,15 @@ private function startBridgeServer(int $wsPort, int $bridgePort, int $viteProxyP // mid-command (proc_close blocks waiting for the long-lived child). // On Ctrl+C the PHP process is hard-terminated by Windows and the // bridge stays running, matching Mac/Linux behaviour. - $this->bridgeProcess = @proc_open($cmd, $desc, $pipes, base_path(), null, ['bypass_shell' => true]); + $env = array_merge(getenv() ?: [], [ + 'JUMP_WATCH_PATHS' => json_encode($watchPaths), + ]); + $this->bridgeProcess = @proc_open($cmd, $desc, $pipes, base_path(), $env, ['bypass_shell' => true]); } else { + $envPrefix = 'JUMP_WATCH_PATHS='.escapeshellarg(json_encode($watchPaths)); $cmd = sprintf( - '%s %s %s %d %d %d start >> %s 2>&1 &', + '%s %s %s %s %d %d %d start >> %s 2>&1 &', + $envPrefix, escapeshellarg($phpBinary), escapeshellarg($serverPath), escapeshellarg(base_path()),