Revert "fix(memory): bound OOM-prone accumulators (#10179)" (#10255)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-07-23 18:35:31 -07:00
committed by GitHub
co-authored by Orca
parent 6eb70d8370
commit aab112933e
1577 changed files with 15167 additions and 91655 deletions
+170 -133
View File
@@ -91,12 +91,11 @@ import { GIT_FETCH_SKIP_AUTO_MAINTENANCE_CONFIG_ARGS } from '../../shared/git-fe
import { createHash, randomUUID } from 'node:crypto'
import { homedir } from 'node:os'
import { isAbsolute, join, resolve } from 'node:path'
import { mkdir, opendir, rm, stat } from 'node:fs/promises'
import { mkdir, readFile, readdir, rm, stat } from 'node:fs/promises'
import { resolveWorktreeCreateBase } from '../worktree-create-base'
import { resolveWorktreeAddBaseRef } from '../../shared/worktree-base-ref'
import { OrchestrationDb } from './orchestration/db'
import { formatMessagesForInjection } from './orchestration/formatter'
import { OrchestrationMessageWaiterRegistry } from './orchestration-message-waiter-registry'
import type {
Automation,
AutomationCreateInput,
@@ -190,11 +189,6 @@ import {
} from '../../shared/runtime-navigation'
import type { SshConnectionState } from '../../shared/ssh-types'
import { getPublicSshState } from './public-ssh-state'
import {
RuntimeSshRelayRecoveryGenerations,
type RuntimeSshRelayRecoveryGenerationLease
} from './runtime-ssh-relay-recovery-generations'
import { RuntimeOperationGenerations } from './runtime-operation-generations'
import { closeTerminalTabInWorkspaceSession } from '../../shared/workspace-session-terminal-tab-close'
import type {
LinearCurrentIssueContextHints,
@@ -247,7 +241,6 @@ import {
import { parsePtySessionId } from '../../shared/pty-session-id-format'
import { clampLinearIssueListLimit } from '../../shared/linear-issue-read-limits'
import { isFolderRepo } from '../../shared/repo-kind'
import { mapWithConcurrency } from '../../shared/map-with-concurrency'
import { DEFAULT_WORKSPACE_STATUS_ID } from '../../shared/workspace-statuses'
import {
buildSetupRunnerCommand,
@@ -566,14 +559,6 @@ import type {
PRRefreshOutcome
} from '../../shared/types'
import { inspectSetupScriptImportCandidates } from '../../shared/setup-script-imports'
import {
readSetupScriptImportFile,
SETUP_SCRIPT_IMPORT_FILE_MAX_BYTES,
SETUP_SCRIPT_IMPORT_MAX_CODE_UNITS
} from '../setup-script-import-file'
import { MAX_ORCA_YAML_BYTES, MAX_ORCA_YAML_CODE_UNITS } from '../../shared/orca-yaml-file-limit'
import { readFilesystemProviderBoundedText } from '../filesystem-provider-bounded-text'
import { readLocalFilesystemDirectory } from '../ipc/filesystem-directory-reader'
import type {
CreateHostedReviewInput,
CreateHostedReviewResult,
@@ -776,8 +761,6 @@ import {
hasUnrecognizedOrcaYamlKeys,
hasHooksFile,
loadHooks,
MAX_HOOK_GITIGNORE_BYTES,
MAX_ISSUE_COMMAND_BYTES,
parseOrcaYaml,
readIssueCommand,
runHook,
@@ -1675,6 +1658,14 @@ type TerminalWaiter = {
abortCleanup: (() => void) | null
}
type MessageWaiter = {
handle: string
typeFilter: string[] | undefined
resolve: (result: void) => void
timeout: NodeJS.Timeout | null
abortCleanup: (() => void) | null
}
function omitUndefinedProperties<T extends Record<string, unknown>>(value: T): Partial<T> {
return Object.fromEntries(
Object.entries(value).filter(([, entry]) => entry !== undefined)
@@ -2499,7 +2490,7 @@ export class OrcaRuntimeService {
private resolvedWorktreeCache: ResolvedWorktreeCache | null = null
private resolvedWorktreeInFlight: ResolvedWorktreeInFlight | null = null
private resolvedWorktreeGeneration = 0
private readonly worktreeScanGenerations = new RuntimeOperationGenerations()
private worktreeScanGenerations = new Map<string, number>()
private worktreeScanCache = new Map<string, RuntimeWorktreeScanCache>()
private worktreeScanInFlight = new Map<string, RuntimeWorktreeScanInFlight>()
private cloneInFlightByPath = new Map<string, Promise<void>>()
@@ -2507,7 +2498,7 @@ export class OrcaRuntimeService {
private ptyForegroundAgentRefreshes = new Map<string, PtyForegroundAgentRefresh>()
private ptyDelayedForegroundSnapshotTitleObservations = new Map<string, number>()
private _orchestrationDb: OrchestrationDb | null = null
private readonly messageWaiters = new OrchestrationMessageWaiterRegistry()
private messageWaitersByHandle = new Map<string, Set<MessageWaiter>>()
// Why: mobile clients subscribe to terminal output via terminal.subscribe.
// These listeners fire on every onPtyData call, enabling real-time streaming
// without polling. Keyed by ptyId for O(1) lookup per data event.
@@ -2578,7 +2569,8 @@ export class OrcaRuntimeService {
private providerVisibleStateByPtyId = new Map<string, RuntimeVisibleTerminalState>()
private providerVisibleRetryAtByPtyId = new Map<string, number>()
private providerSnapshotsWithLiveModeTransition = new WeakSet<PtyProviderBufferSnapshot>()
private readonly ptyLifecycleGenerations = new RuntimeOperationGenerations()
private ptyLifecycleGenerationById = new Map<string, number>()
private nextPtyLifecycleGeneration = 1
private recentPtyPathCandidatesById = new Map<string, string[]>()
// Why: candidates only feed mobile file-tap provenance; desktop-only
// sessions skip the 3-regex extraction on every PTY chunk until a
@@ -2878,7 +2870,7 @@ export class OrcaRuntimeService {
| null
private readonly agentSessionClaimSigner: AgentSessionClaimSigner
private readonly agentSessionCreateOperations = new Map<string, AgentSessionCreateOperation>()
private readonly sshRelayRecoveryGenerations = new RuntimeSshRelayRecoveryGenerations()
private sshRelayRecoveryGenerationByTargetId = new Map<string, number>()
private accountServices: RuntimeAccountServices | null = null
private commitMessageAgentEnv: CommitMessageAgentEnvironmentResolvers | null = null
private automationService: AutomationService | null = null
@@ -3575,32 +3567,33 @@ export class OrcaRuntimeService {
// Why: SSH state changes originate in main's ssh handlers, not in runtime
// methods, so they need a public entry point onto the client-event stream.
notifySshStateChanged(targetId: string, state: SshConnectionState): void {
this.sshRelayRecoveryGenerations.invalidate(targetId)
this.bumpSshRelayRecoveryGeneration(targetId)
this.invalidateSshWorktreeScanCache(targetId)
this.emitClientEvent({ type: 'sshStateChanged', targetId, state: getPublicSshState(state)! })
}
notifySshRelayReady(targetId: string): void {
const generationLease = this.sshRelayRecoveryGenerations.begin(targetId)
if (!generationLease) {
return
}
void this.publishRecoveredSshMobileSessionTabs(targetId, generationLease)
.catch((error) => {
if (!generationLease.isCurrent()) {
return
}
console.warn('[runtime] failed to publish recovered SSH session tabs', {
targetId,
error
})
const generation = this.bumpSshRelayRecoveryGeneration(targetId)
void this.publishRecoveredSshMobileSessionTabs(targetId, generation).catch((error) => {
if (this.sshRelayRecoveryGenerationByTargetId.get(targetId) !== generation) {
return
}
console.warn('[runtime] failed to publish recovered SSH session tabs', {
targetId,
error
})
.finally(() => generationLease.release())
})
}
private bumpSshRelayRecoveryGeneration(targetId: string): number {
const generation = (this.sshRelayRecoveryGenerationByTargetId.get(targetId) ?? 0) + 1
this.sshRelayRecoveryGenerationByTargetId.set(targetId, generation)
return generation
}
private async publishRecoveredSshMobileSessionTabs(
targetId: string,
generationLease: RuntimeSshRelayRecoveryGenerationLease
generation: number
): Promise<void> {
const repoIds = new Set(
(this.store?.getRepos() ?? [])
@@ -3632,7 +3625,7 @@ export class OrcaRuntimeService {
})
}
await this.refreshMobileSessionPtyRecords()
if (!generationLease.isCurrent()) {
if (this.sshRelayRecoveryGenerationByTargetId.get(targetId) !== generation) {
return
}
for (const worktreeId of worktreeIds) {
@@ -8408,15 +8401,17 @@ export class OrcaRuntimeService {
}
private getPtyLifecycleGeneration(ptyId: string): number {
return this.ptyLifecycleGenerations.current(ptyId)
}
private isPtyLifecycleGenerationCurrent(ptyId: string, generation: number): boolean {
return this.ptyLifecycleGenerations.isCurrent(ptyId, generation)
const existing = this.ptyLifecycleGenerationById.get(ptyId)
if (existing !== undefined) {
return existing
}
const generation = this.nextPtyLifecycleGeneration++
this.ptyLifecycleGenerationById.set(ptyId, generation)
return generation
}
private advancePtyLifecycleGeneration(ptyId: string): void {
this.ptyLifecycleGenerations.advance(ptyId)
this.ptyLifecycleGenerationById.set(ptyId, this.nextPtyLifecycleGeneration++)
// Why: a provider response belongs to the process generation that issued
// it; a respawn must neither reuse its frame nor join its in-flight call.
this.providerBufferAcquisitionsByPtyId.delete(ptyId)
@@ -9268,7 +9263,7 @@ export class OrcaRuntimeService {
// Why: daemon PTYs survive an app relaunch before any renderer mounts.
// Mobile still needs their retained history without navigating desktop.
const snapshot = await this.ptyController?.serializeProviderBuffer?.(ptyId, opts)
if (!snapshot || !this.isPtyLifecycleGenerationCurrent(ptyId, generation)) {
if (!snapshot || this.getPtyLifecycleGeneration(ptyId) !== generation) {
return null
}
const snapshotModeTracker = new TerminalKittyKeyboardModeTracker()
@@ -9406,7 +9401,7 @@ export class OrcaRuntimeService {
{ scrollbackRows: 0 },
{ timeoutMs: VISIBLE_TERMINAL_SNAPSHOT_TIMEOUT_MS }
)
if (!snapshot || !this.isPtyLifecycleGenerationCurrent(ptyId, generation)) {
if (!snapshot || this.getPtyLifecycleGeneration(ptyId) !== generation) {
this.providerVisibleRetryAtByPtyId.set(ptyId, Date.now() + VISIBLE_TERMINAL_SNAPSHOT_RETRY_MS)
return null
}
@@ -9420,7 +9415,7 @@ export class OrcaRuntimeService {
}
}
const lines = await this.parseVisibleSnapshotLines(snapshot)
if (!this.isPtyLifecycleGenerationCurrent(ptyId, generation)) {
if (this.getPtyLifecycleGeneration(ptyId) !== generation) {
return null
}
const visibleState: RuntimeVisibleTerminalState = {
@@ -9446,7 +9441,7 @@ export class OrcaRuntimeService {
await state.writeChain
if (
this.headlessTerminals.get(ptyId) !== state ||
!this.isPtyLifecycleGenerationCurrent(ptyId, generation)
this.getPtyLifecycleGeneration(ptyId) !== generation
) {
return null
}
@@ -9681,15 +9676,16 @@ export class OrcaRuntimeService {
// before the first-ever connect no longer yields candidates.
for (const [ptyId, buffer] of this.recentPtyOutputById) {
let candidates = this.recentPtyPathCandidatesById.get(ptyId)
buffer.forEachRetainedChunk((chunk, index, headChunkIsPartial) => {
const { chunks, headChunkIsPartial } = buffer.retainedChunks()
for (let index = 0; index < chunks.length; index += 1) {
if (index === 0 && headChunkIsPartial) {
// A pre-sliced over-window chunk was already extracted eagerly at
// append time (while its original text was intact); replaying its
// truncated remainder would mint or drop candidates spuriously.
return
continue
}
candidates = appendRecentPtyPathCandidates(candidates, chunk)
})
candidates = appendRecentPtyPathCandidates(candidates, chunks[index]!)
}
if (candidates) {
this.recentPtyPathCandidatesById.set(ptyId, candidates)
}
@@ -15099,7 +15095,21 @@ export class OrcaRuntimeService {
if (!dirStat.isDirectory()) {
throw new Error(`${dirPath} is not a directory`)
}
return { resolvedPath: dirPath, entries: await readLocalFilesystemDirectory(dirPath) }
const entries = await readdir(dirPath, { withFileTypes: true })
const mapped = entries
.filter((entry) => entry.name !== '.' && entry.name !== '..')
.map((entry) => ({
name: entry.name,
isDirectory: entry.isDirectory(),
isSymlink: entry.isSymbolicLink()
}))
mapped.sort((a, b) => {
if (a.isDirectory !== b.isDirectory) {
return a.isDirectory ? -1 : 1
}
return a.name.localeCompare(b.name)
})
return { resolvedPath: dirPath, entries: mapped }
}
async isGitAvailable(): Promise<boolean> {
@@ -15372,13 +15382,9 @@ export class OrcaRuntimeService {
if (!existingStat.isDirectory()) {
return { error: `"${trimmedName}" already exists at this location and is not a folder.` }
}
const directory = await opendir(targetPath)
try {
if ((await directory.read()) !== null) {
return { error: `"${trimmedName}" already exists at this location and is not empty.` }
}
} finally {
await directory.close().catch(() => {})
const entries = await readdir(targetPath)
if (entries.length > 0) {
return { error: `"${trimmedName}" already exists at this location and is not empty.` }
}
} else {
await mkdir(targetPath, { recursive: false })
@@ -15709,22 +15715,12 @@ export class OrcaRuntimeService {
}
const repo = await this.resolveRepoSelector(repoSelector)
this.store.removeProject(repo.id)
this.notifyRepoStoreChanged(repo.id)
invalidateAuthorizedRootsCache()
return { removed: true }
}
notifyRepoStoreChanged(repoId: string): void {
const removed = !this.store?.getRepo(repoId)
if (removed) {
this.terminalTopologyRevisionByRepoId.delete(repoId)
}
this.terminalTopologyRevisionByRepoId.delete(repo.id)
this.invalidateResolvedWorktreeCache()
this.invalidateWorktreeScanCacheForRepo(repoId)
if (removed) {
this.worktreeScanGenerations.forget(repoId)
}
this.invalidateWorktreeScanCacheForRepo(repo.id)
invalidateAuthorizedRootsCache()
this.notifyReposChanged()
return { removed: true }
}
async inspectTerminalProcess(
@@ -17112,12 +17108,8 @@ export class OrcaRuntimeService {
}
}
try {
const result = await readFilesystemProviderBoundedText(
fsProvider,
joinWorktreeRelativePath(repo.path, 'orca.yaml'),
{ maxBytes: MAX_ORCA_YAML_BYTES, maxCodeUnits: MAX_ORCA_YAML_CODE_UNITS }
)
const hooks = result.kind === 'text' ? parseOrcaYaml(result.content) : null
const result = await fsProvider.readFile(joinWorktreeRelativePath(repo.path, 'orca.yaml'))
const hooks = result.isBinary ? null : parseOrcaYaml(result.content)
return {
hasHooksFile: Boolean(hooks),
hooks,
@@ -17165,19 +17157,11 @@ export class OrcaRuntimeService {
return { hasHooks: false, hooks: null, mayNeedUpdate: false }
}
try {
const result = await readFilesystemProviderBoundedText(
fsProvider,
joinWorktreeRelativePath(repo.path, 'orca.yaml'),
{ maxBytes: MAX_ORCA_YAML_BYTES, maxCodeUnits: MAX_ORCA_YAML_CODE_UNITS }
)
if (result.kind === 'binary') {
const result = await fsProvider.readFile(joinWorktreeRelativePath(repo.path, 'orca.yaml'))
if (result.isBinary) {
return { hasHooks: false, hooks: null, mayNeedUpdate: false }
}
return {
hasHooks: true,
hooks: result.kind === 'text' ? parseOrcaYaml(result.content) : null,
mayNeedUpdate: false
}
return { hasHooks: true, hooks: parseOrcaYaml(result.content), mayNeedUpdate: false }
} catch {
return { hasHooks: false, hooks: null, mayNeedUpdate: false }
}
@@ -17206,18 +17190,15 @@ export class OrcaRuntimeService {
return null
}
try {
const result = await readFilesystemProviderBoundedText(fsProvider, filePath, {
maxBytes: SETUP_SCRIPT_IMPORT_FILE_MAX_BYTES,
maxCodeUnits: SETUP_SCRIPT_IMPORT_MAX_CODE_UNITS
})
return result.kind === 'text' ? result.content : null
const result = await fsProvider.readFile(filePath)
return result.isBinary ? null : result.content
} catch {
return null
}
}
try {
return await readSetupScriptImportFile(filePath)
return await readFile(filePath, 'utf-8')
} catch (error) {
if (!isENOENT(error)) {
console.warn('[runtime] Failed to inspect setup script import candidate:', error)
@@ -17275,11 +17256,11 @@ export class OrcaRuntimeService {
issueCommandPath: string
): Promise<string | null> {
try {
const result = await readFilesystemProviderBoundedText(fsProvider, issueCommandPath, {
maxBytes: MAX_ISSUE_COMMAND_BYTES,
maxCodeUnits: MAX_ISSUE_COMMAND_BYTES
})
return result.kind === 'text' ? result.content.trim() || null : null
const result = await fsProvider.readFile(issueCommandPath)
if (result.isBinary) {
return null
}
return result.content.trim() || null
} catch {
return null
}
@@ -17290,12 +17271,8 @@ export class OrcaRuntimeService {
repoPath: string
): Promise<string | null> {
try {
const result = await readFilesystemProviderBoundedText(
fsProvider,
joinWorktreeRelativePath(repoPath, 'orca.yaml'),
{ maxBytes: MAX_ORCA_YAML_BYTES, maxCodeUnits: MAX_ORCA_YAML_CODE_UNITS }
)
if (result.kind !== 'text') {
const result = await fsProvider.readFile(joinWorktreeRelativePath(repoPath, 'orca.yaml'))
if (result.isBinary) {
return null
}
return parseOrcaYaml(result.content)?.issueCommand?.trim() || null
@@ -17341,12 +17318,9 @@ export class OrcaRuntimeService {
options: { required?: boolean } = {}
): Promise<void> {
const gitignorePath = joinWorktreeRelativePath(repoPath, '.gitignore')
let result: Awaited<ReturnType<typeof readFilesystemProviderBoundedText>>
let result: Awaited<ReturnType<IFilesystemProvider['readFile']>>
try {
result = await readFilesystemProviderBoundedText(fsProvider, gitignorePath, {
maxBytes: MAX_HOOK_GITIGNORE_BYTES,
maxCodeUnits: MAX_HOOK_GITIGNORE_BYTES
})
result = await fsProvider.readFile(gitignorePath)
} catch (error) {
if (!isENOENT(error)) {
if (options.required) {
@@ -17365,13 +17339,9 @@ export class OrcaRuntimeService {
}
return
}
if (result.kind !== 'text') {
if (result.isBinary) {
if (options.required) {
throw new Error(
result.kind === 'binary'
? 'Remote .gitignore is binary; cannot verify .orca is ignored'
: 'Remote .gitignore exceeds the supported size limit'
)
throw new Error('Remote .gitignore is binary; cannot verify .orca is ignored')
}
return
}
@@ -24626,10 +24596,8 @@ export class OrcaRuntimeService {
getAgentLaunchPlatformForRepo(repo, projectRuntimeByRepoId.get(repo.id))
])
)
const perRepoWorktrees = await mapWithConcurrency(
repos,
RESOLVED_WORKTREE_REPO_CONCURRENCY,
async (repo) => {
const perRepoWorktrees = await Promise.all(
repos.map(async (repo) => {
if (isFolderRepo(repo)) {
return listRuntimeFolderWorkspaces(this.requireStore(), repo).map((worktree) => ({
...worktree,
@@ -24686,7 +24654,7 @@ export class OrcaRuntimeService {
comment: merged.comment
}
})
}
})
)
const worktrees = projectResolvedWorktreeLineage(
perRepoWorktrees.flat(),
@@ -24750,7 +24718,7 @@ export class OrcaRuntimeService {
projectRuntimeByRepoId?: ReadonlyMap<string, ProjectExecutionRuntimeResolution>
): Promise<RuntimeWorktreeScanResult> {
const now = Date.now()
const generation = this.worktreeScanGenerations.current(repo.id)
const generation = this.worktreeScanGenerations.get(repo.id) ?? 0
const projectRuntime = projectRuntimeByRepoId
? projectRuntimeByRepoId.get(repo.id)
: !repo.connectionId
@@ -24781,7 +24749,7 @@ export class OrcaRuntimeService {
const result = await promise
if (
result.ok &&
this.worktreeScanGenerations.isCurrent(repo.id, generation) &&
generation === (this.worktreeScanGenerations.get(repo.id) ?? 0) &&
this.worktreeScanInFlight.get(repo.id)?.promise === promise
) {
this.worktreeScanCache.set(repo.id, {
@@ -24861,7 +24829,7 @@ export class OrcaRuntimeService {
}
private invalidateWorktreeScanCacheForRepo(repoId: string): void {
this.worktreeScanGenerations.advance(repoId)
this.worktreeScanGenerations.set(repoId, (this.worktreeScanGenerations.get(repoId) ?? 0) + 1)
this.worktreeScanCache.delete(repoId)
this.worktreeScanInFlight.delete(repoId)
}
@@ -24872,7 +24840,7 @@ export class OrcaRuntimeService {
repos.filter((repo) => repo.connectionId === targetId).map((repo) => repo.id)
)
for (const repoId of affectedRepoIds) {
this.worktreeScanGenerations.advance(repoId)
this.worktreeScanGenerations.set(repoId, (this.worktreeScanGenerations.get(repoId) ?? 0) + 1)
this.worktreeScanCache.delete(repoId)
this.worktreeScanInFlight.delete(repoId)
}
@@ -25350,7 +25318,6 @@ export class OrcaRuntimeService {
this.terminalFileUriHostnameByPtyId.delete(ptyId)
this.wslDistroByPtyId.delete(ptyId)
this.clearAgentRowSnapshotsForPty(ptyId)
this.ptyLifecycleGenerations.forget(ptyId)
const handle = this.handleByPtyId.get(ptyId)
if (handle) {
// Why: pruning can remove a PTY without onPtyExit firing; release this leader's agent team so it doesn't leak.
@@ -26693,14 +26660,84 @@ export class OrcaRuntimeService {
// Why: wake blocking orchestration.check --wait calls on this handle so they return the new message immediately instead of polling.
notifyMessageArrived(handle: string, messageType?: string): void {
this.messageWaiters.notify(handle, messageType)
const waiters = this.messageWaitersByHandle.get(handle)
if (!waiters || waiters.size === 0) {
return
}
for (const waiter of [...waiters]) {
// Why: don't wake a coordinator waiting for worker_done/escalation on heartbeat noise it would misread as idleness.
if (messageType && waiter.typeFilter && !waiter.typeFilter.includes(messageType)) {
continue
}
this.resolveMessageWaiter(waiter)
}
}
waitForMessage(
handle: string,
options?: { typeFilter?: string[]; timeoutMs?: number; signal?: AbortSignal }
): Promise<void> {
return this.messageWaiters.wait(handle, options)
return new Promise((resolve) => {
const timeoutMs = options?.timeoutMs ?? MESSAGE_WAIT_DEFAULT_TIMEOUT_MS
const waiter: MessageWaiter = {
handle,
typeFilter: options?.typeFilter,
resolve,
timeout: null,
abortCleanup: null
}
// Why: on caller abort (RPC socket closed — design doc §3.1), resolve now to release the long-poll slot instead of waiting out timeoutMs.
const signal = options?.signal
const onAbort = (): void => {
this.removeMessageWaiter(waiter)
resolve()
}
if (signal) {
if (signal.aborted) {
resolve()
return
}
waiter.abortCleanup = () => signal.removeEventListener('abort', onAbort)
signal.addEventListener('abort', onAbort, { once: true })
}
waiter.timeout = setTimeout(() => {
this.removeMessageWaiter(waiter)
resolve()
}, timeoutMs)
let waiters = this.messageWaitersByHandle.get(handle)
if (!waiters) {
waiters = new Set()
this.messageWaitersByHandle.set(handle, waiters)
}
waiters.add(waiter)
})
}
private resolveMessageWaiter(waiter: MessageWaiter): void {
this.removeMessageWaiter(waiter)
waiter.resolve()
}
private removeMessageWaiter(waiter: MessageWaiter): void {
if (waiter.timeout) {
clearTimeout(waiter.timeout)
waiter.timeout = null
}
if (waiter.abortCleanup) {
waiter.abortCleanup()
waiter.abortCleanup = null
}
const waiters = this.messageWaitersByHandle.get(waiter.handle)
if (waiters) {
waiters.delete(waiter)
if (waiters.size === 0) {
this.messageWaitersByHandle.delete(waiter.handle)
}
}
}
private buildPtyTerminalSummary(
@@ -30213,7 +30250,6 @@ const WORKTREE_SCAN_CACHE_TTL_MS = 30_000
// these (crash-cluster diagnostics, 2026-07).
const WORKTREE_SCAN_AGENT_SCRATCH_TTL_MS = 5 * 60_000
const RESOLVED_WORKTREE_REPO_TIMEOUT_MS = 5000
const RESOLVED_WORKTREE_REPO_CONCURRENCY = 8
export function resolveWorktreeScanCacheTtlMs(repo: Pick<Repo, 'path' | 'connectionId'>): number {
return !repo.connectionId && isAgentScratchRepoRootPath(repo.path)
@@ -31660,6 +31696,7 @@ async function assertTerminalInputWithinLimitWithYield(text: string | undefined)
const TUI_IDLE_DEFAULT_TIMEOUT_MS = 5 * 60 * 1000
const TUI_IDLE_POLL_INTERVAL_MS = 2000
const TUI_IDLE_QUIESCENCE_MS = 3000
const MESSAGE_WAIT_DEFAULT_TIMEOUT_MS = 2 * 60 * 1000
const EXPLICIT_IDLE_TITLE_RE = /(^|\s)(ready|idle|done)(\s|$|[.!?])/i
const CLAUDE_IDLE_PREFIX = '\u2733'
const GEMINI_IDLE_PREFIX = '\u25c7'