From 44a933b9dde0b1843d1e07483a3bb60e9ca097e6 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sun, 7 Jun 2026 23:13:37 -0400 Subject: [PATCH] fix: use remote workspace backend without streaming git --- inc/Workspace/RemoteWorkspaceBackend.php | 15 ++++++++++++++- tests/smoke-remote-workspace-backend.php | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/inc/Workspace/RemoteWorkspaceBackend.php b/inc/Workspace/RemoteWorkspaceBackend.php index 780eb6fe..dc254054 100644 --- a/inc/Workspace/RemoteWorkspaceBackend.php +++ b/inc/Workspace/RemoteWorkspaceBackend.php @@ -22,12 +22,25 @@ class RemoteWorkspaceBackend { * Whether the remote backend should handle workspace operations. */ public static function should_handle(): bool { + $diagnostic = \DataMachineCode\Support\GitRunner::diagnose(); + $default = self::should_handle_for_local_capabilities( + ! empty($diagnostic['git_available']), + ! empty($diagnostic['git_available']) && ! empty($diagnostic['proc_open_available']) + ); + return (bool) apply_filters( 'datamachine_code_remote_workspace_backend_should_handle', - ! \DataMachineCode\Support\GitRunner::is_available() + $default ); } + /** + * Decide whether constrained runtimes need the GitHub-backed backend. + */ + public static function should_handle_for_local_capabilities( bool $git_available, bool $streaming_available ): bool { + return ! ( $git_available && $streaming_available ); + } + /** * Clone/register a GitHub repository as a remote workspace primary. * diff --git a/tests/smoke-remote-workspace-backend.php b/tests/smoke-remote-workspace-backend.php index 222481db..cb741f7c 100644 --- a/tests/smoke-remote-workspace-backend.php +++ b/tests/smoke-remote-workspace-backend.php @@ -163,6 +163,10 @@ function update_option( string $key, mixed $value, bool $autoload = true ): bool echo "Remote workspace backend - smoke\n"; $backend = new RemoteWorkspaceBackend(); + $assert('remote backend handles missing git runtime', RemoteWorkspaceBackend::should_handle_for_local_capabilities(false, false)); + $assert('remote backend handles non-streaming git runtime', RemoteWorkspaceBackend::should_handle_for_local_capabilities(true, false)); + $assert('remote backend leaves full local git runtime alone', ! RemoteWorkspaceBackend::should_handle_for_local_capabilities(true, true)); + $clone = $backend->clone_repo('https://github.com/chubes4/example.git'); $assert('clone registers remote repo', ! is_wp_error($clone) && 'example' === $clone['name'] && 'github_api' === $clone['backend']); $assert('clone backend result omits model-facing guidance', ! is_wp_error($clone) && ! array_key_exists('next_required_tool', $clone) && ! array_key_exists('next_required_args', $clone));