From 340247731416405ebb19952fd528b35e7c2ed28f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 30 May 2026 22:45:14 +0100 Subject: [PATCH] chore: remove unused infra helpers --- scripts/check-kysely-guardrails.mjs | 3 +-- src/agents/sessions/tools/bash.ts | 17 +---------------- src/agents/utils/paths.ts | 21 --------------------- src/agents/utils/shell.ts | 21 --------------------- src/infra/kysely-sync.ts | 11 ----------- src/infra/restart-sentinel.ts | 9 --------- 6 files changed, 2 insertions(+), 80 deletions(-) diff --git a/scripts/check-kysely-guardrails.mjs b/scripts/check-kysely-guardrails.mjs index 84e49e9a99a..24df29b7cd9 100644 --- a/scripts/check-kysely-guardrails.mjs +++ b/scripts/check-kysely-guardrails.mjs @@ -127,8 +127,7 @@ function collectImports(sourceFile) { const importedName = element.propertyName?.text ?? element.name.text; if ( importedName === "executeSqliteQuerySync" || - importedName === "executeSqliteQueryTakeFirstSync" || - importedName === "executeSqliteQueryTakeFirstOrThrowSync" + importedName === "executeSqliteQueryTakeFirstSync" ) { syncHelperNames.add(element.name.text); } diff --git a/src/agents/sessions/tools/bash.ts b/src/agents/sessions/tools/bash.ts index 3f03ca0f8b4..15775277c28 100644 --- a/src/agents/sessions/tools/bash.ts +++ b/src/agents/sessions/tools/bash.ts @@ -8,13 +8,7 @@ import { truncateToVisualLines } from "../../modes/interactive/components/visual import { theme } from "../../modes/interactive/theme/theme.js"; import type { AgentTool } from "../../runtime/index.js"; import { waitForChildProcess } from "../../utils/child-process.js"; -import { - getShellConfig, - getShellEnv, - killProcessTree, - trackDetachedChildPid, - untrackDetachedChildPid, -} from "../../utils/shell.js"; +import { getShellConfig, getShellEnv, killProcessTree } from "../../utils/shell.js"; import type { ToolDefinition, ToolRenderResultOptions } from "../extensions/types.js"; import type { BashOperations } from "./bash-operations.js"; import { OutputAccumulator } from "./output-accumulator.js"; @@ -68,9 +62,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas stdio: ["ignore", "pipe", "pipe"], windowsHide: true, }); - if (child.pid) { - trackDetachedChildPid(child.pid); - } let timedOut = false; let timeoutHandle: NodeJS.Timeout | undefined; const timeoutMs = resolveBashTimeoutMs(timeout); @@ -102,9 +93,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas // on inherited stdio handles held by detached descendants. waitForChildProcess(child) .then((code) => { - if (child.pid) { - untrackDetachedChildPid(child.pid); - } if (timeoutHandle) { clearTimeout(timeoutHandle); } @@ -122,9 +110,6 @@ export function createLocalBashOperations(options?: { shellPath?: string }): Bas resolve({ exitCode: code }); }) .catch((err) => { - if (child.pid) { - untrackDetachedChildPid(child.pid); - } if (timeoutHandle) { clearTimeout(timeoutHandle); } diff --git a/src/agents/utils/paths.ts b/src/agents/utils/paths.ts index c059f8943eb..f89f215b4b9 100644 --- a/src/agents/utils/paths.ts +++ b/src/agents/utils/paths.ts @@ -1,6 +1,5 @@ import { realpathSync } from "node:fs"; import { isAbsolute, relative, resolve as resolvePath, sep } from "node:path"; -import { spawnProcessSync } from "./child-process.js"; /** * Resolve a path to its canonical (real) form, following symlinks. @@ -56,23 +55,3 @@ export function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string) const absolutePath = resolveAgainstCwd(filePath, cwd); return (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join("/"); } - -export function markPathIgnoredByCloudSync(path: string): void { - const attrs = - process.platform === "darwin" - ? ["com.dropbox.ignored", "com.apple.fileprovider.ignore#P"] - : process.platform === "linux" - ? ["user.com.dropbox.ignored"] - : []; - - for (const attr of attrs) { - if (process.platform === "darwin") { - spawnProcessSync("xattr", ["-w", attr, "1", path], { encoding: "utf-8", stdio: "ignore" }); - } else { - spawnProcessSync("setfattr", ["-n", attr, "-v", "1", path], { - encoding: "utf-8", - stdio: "ignore", - }); - } - } -} diff --git a/src/agents/utils/shell.ts b/src/agents/utils/shell.ts index 1af40a757b0..29b78f7c47d 100644 --- a/src/agents/utils/shell.ts +++ b/src/agents/utils/shell.ts @@ -177,27 +177,6 @@ export function sanitizeBinaryOutput(str: string): string { .join(""); } -/** - * Detached child processes must be tracked so they can be killed on parent - * shutdown signals (SIGHUP/SIGTERM). - */ -const trackedDetachedChildPids = new Set(); - -export function trackDetachedChildPid(pid: number): void { - trackedDetachedChildPids.add(pid); -} - -export function untrackDetachedChildPid(pid: number): void { - trackedDetachedChildPids.delete(pid); -} - -export function killTrackedDetachedChildren(): void { - for (const pid of trackedDetachedChildPids) { - killProcessTree(pid); - } - trackedDetachedChildPids.clear(); -} - export function killProcessTree(pid: number, opts?: KillProcessTreeOptions): void { killProcessTreeGracefully(pid, { force: true, ...opts }); } diff --git a/src/infra/kysely-sync.ts b/src/infra/kysely-sync.ts index f1d3184530b..53c6c85f14f 100644 --- a/src/infra/kysely-sync.ts +++ b/src/infra/kysely-sync.ts @@ -60,17 +60,6 @@ export function executeSqliteQueryTakeFirstSync( return executeSqliteQuerySync(db, query).rows[0]; } -export function executeSqliteQueryTakeFirstOrThrowSync( - db: DatabaseSync, - query: CompilableQuery, -): Row { - const row = executeSqliteQueryTakeFirstSync(db, query); - if (!row) { - throw new Error("Kysely query returned no rows"); - } - return row; -} - export function clearNodeSqliteKyselyCacheForDatabase(db: DatabaseSync): void { kyselyByDatabase.delete(db); } diff --git a/src/infra/restart-sentinel.ts b/src/infra/restart-sentinel.ts index ed215558c4c..05df064fe6d 100644 --- a/src/infra/restart-sentinel.ts +++ b/src/infra/restart-sentinel.ts @@ -193,15 +193,6 @@ export async function readRestartSentinel( } } -export async function hasRestartSentinel(env: NodeJS.ProcessEnv = process.env): Promise { - try { - await fs.access(resolveRestartSentinelPath(env)); - return true; - } catch { - return false; - } -} - export async function consumeRestartSentinel( env: NodeJS.ProcessEnv = process.env, ): Promise {