feat: add WSL support #2402
ClosedUtkarshUsername(GitHub profile, opens in a new tab)wants to merge 61 commits into
main fromrefs/pull/2402/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/server/src/wsl/WslPath.ts lines 41 to 54Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +27,21 @@27+ const posixRelative = relative.split(path.win32.sep).filter(Boolean).join("/");28+ return posixRelative ? `/mnt/${drive}/${posixRelative}` : `/mnt/${drive}`;29+}30+31+export function isUnsupportedNetworkPath(input: string): boolean {32+ return input.startsWith("\\\\") && parseWslUncPath(input) === null;33+}34+35+export function normalizePosixPath(input: string): string {36+ const normalized = path.posix.normalize(input.replaceAll("\\", "/"));37+ return normalized.startsWith("/") ? normalized : `/${normalized}`;38+}39+40+export function resolvePosixChild(root: string, relativePath: string): string | null {41+ const normalizedRoot = normalizePosixPath(root);42+ const resolved = path.posix.resolve(normalizedRoot, relativePath);43+ if (resolved === normalizedRoot || resolved.startsWith(`${normalizedRoot}/`)) {44+ return resolved;45+ }46+ return null;47+}apps/server/src/persistence/Migrations/027_ExecutionTargets.ts lines 9 to 12OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,12 @@1+import * as SqlClient from "effect/unstable/sql/SqlClient";2+import * as Effect from "effect/Effect";3+4+const LOCAL_EXECUTION_TARGET_JSON = '{"kind":"local"}';5+6+export default Effect.gen(function* () {7+ const sql = yield* SqlClient.SqlClient;8+9+ yield* sql`10+ ALTER TABLE projection_projects11+ ADD COLUMN execution_target_json TEXT12+ `.pipe(Effect.catch(() => Effect.void));apps/server/src/wsl/WslBrowse.ts lines 53 to 53OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +33,21 @@33+34+export function parseWslBrowseOutput(stdout: string): FilesystemBrowseResult {35+ const lines = stdout36+ .split(/\r?\n/u)37+ .map((line) => line.trim())38+ .filter((line) => line.length > 0);39+ const parentPath = lines[0];40+ const prefixLine = lines.find((line) => line.startsWith("__PREFIX__:"));41+ const prefix = prefixLine ? prefixLine.slice("__PREFIX__:".length) : "";42+ if (!parentPath) {43+ throw new Error("WSL browse response did not include a parent path.");44+ }45+46+ const lowerPrefix = prefix.toLowerCase();47+ const showHidden = prefix.length === 0 || prefix.startsWith(".");48+ const entries: Array<FilesystemBrowseResult["entries"][number]> = [];49+50+ for (const line of lines) {51+ if (!line.startsWith("__ENTRY__:")) continue;52+ const entry = line.slice("__ENTRY__:".length);53+ const separator = entry.indexOf(":");apps/server/src/persistence/Layers/ProviderSessionRuntime.ts lines 72 to 75Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -36,3 +65,8 @@3665 : toPersistenceSqlError(sqlOperation)(cause);3766 }386768+function parseJsonField(value: string | null): unknown | null {69+ if (value === null) return null;70+ const parsed = JSON.parse(value);71+ return typeof parsed === "string" ? JSON.parse(parsed) : parsed;72+}apps/server/src/git/Layers/GitCore.ts lines 669 to 675OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -660,3 +666,10 @@660666 const path = yield* Path.Path;661667 const { worktreesDir } = yield* ServerConfig;662668669+ const withExecutionTarget = <A, E, R>(670+ executionTarget: ExecutionTarget | undefined,671+ effect: Effect.Effect<A, E, R>,672+ ): Effect.Effect<A, E, R> =>673+ executionTarget === undefined674+ ? effect675+ : Effect.suspend(() => executionTargetStorage.run(executionTarget, () => effect));
- apps/server/src/persistence/Migrations/023_ProjectionThreadShellSummary.ts lines 20 to 21OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2,9 +2,20 @@22 import * as Effect from "effect/Effect";3+import { SqlError } from "effect/unstable_sql/SqlError";4+5+const isDuplicateColumnError = (error: unknown): boolean => {6+ if (error instanceof SqlError) {7+ const message = error.message.toLowerCase();8+ return message.includes("duplicate column");9+ }10+ return false;11+};312413 export default Effect.gen(function* () {514 const sql = yield* SqlClient.SqlClient;615716 yield* sql`817 ALTER TABLE projection_threads918 ADD COLUMN latest_user_message_at TEXT10- `.pipe(Effect.catch(() => Effect.void));19+ `.pipe(20+ Effect.catch((error) => (isDuplicateColumnError(error) ? Effect.void() : Effect.fail(error))),21+ );
- apps/web/src/lib/gitReactQuery.ts line 108OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -97,8 +100,9 @@97100 export function gitResolvePullRequestQueryOptions(input: {98101 environmentId: EnvironmentId | null;99102 cwd: string | null;103+ executionTarget?: ExecutionTarget | undefined;100104 reference: string | null;101105 }) {102106 return queryOptions({103107 queryKey: [104108 "git",
UtkarshUsername(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
- @@ -552,3 +566,8 @@552566 (persistedBinding?.providerInstanceId === resolvedInstanceId553567 ? readPersistedCwd(persistedBinding.runtimePayload)554568 : undefined);569+ const effectiveExecutionTarget =570+ input.executionTarget ??571+ (persistedBinding?.provider === input.provider572+ ? readPersistedExecutionTarget(persistedBinding.runtimePayload)573+ : undefined);@@ -1835,4 +1836,5 @@18351836 worktreePath: activeThread?.worktreePath ?? null,18361837 })18371838 : null;1839+ const activeProjectExecutionTarget = activeProject?.executionTarget;18381840 const gitStatusQuery = useVcsStatus({ environmentId, cwd: gitCwd });
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
1785d4e7-0054-4a17-aedd-8c018263cd2dYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share