mirror of
https://github.com/stablyai/orca.git
synced 2026-10-18 00:03:20 +00:00
refactor: remove dead renderer retry hooks
This commit is contained in:
@@ -56,7 +56,6 @@ import { unwrapRuntimeRpcResult } from '@/runtime/runtime-rpc-client'
|
||||
import { useAppStore } from '@/store'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { releaseRetainedRuntimeTerminalClosesForEnvironment } from '@/lib/runtime-terminal-close-retry-ownership'
|
||||
|
||||
const LOCAL_RUNTIME_VALUE = '__local__'
|
||||
const NO_RUNTIME_VALUE = '__none__'
|
||||
@@ -498,7 +497,6 @@ export function RuntimeEnvironmentsPane({
|
||||
}
|
||||
if (!allowLocalRuntime) {
|
||||
await loadEnvironments()
|
||||
releaseRetainedRuntimeTerminalClosesForEnvironment(environment.id)
|
||||
if (mountedRef.current) {
|
||||
toast.success(
|
||||
translate(
|
||||
@@ -512,7 +510,6 @@ export function RuntimeEnvironmentsPane({
|
||||
}
|
||||
}
|
||||
await window.api.runtimeEnvironments.remove({ selector: environment.id })
|
||||
releaseRetainedRuntimeTerminalClosesForEnvironment(environment.id)
|
||||
await loadEnvironments()
|
||||
if (mountedRef.current) {
|
||||
toast.success(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { SSH_TERMINATE_RECONNECT_REQUIRED } from '../../../../shared/constants'
|
||||
import { releaseRetainedPtyKillsForSshTarget } from '@/lib/pty-kill-retry-ownership'
|
||||
|
||||
export type SshTargetRemoveApi = {
|
||||
terminateSessions: (args: { targetId: string }) => Promise<unknown>
|
||||
@@ -35,5 +34,4 @@ export async function removeSshTargetWithBestEffortCleanup(
|
||||
}
|
||||
}
|
||||
await api.removeTarget({ id })
|
||||
releaseRetainedPtyKillsForSshTarget(id)
|
||||
}
|
||||
|
||||
@@ -29,10 +29,6 @@ import {
|
||||
} from './terminal-delivery-watchdog'
|
||||
import { recordTerminalFreezeBreadcrumb } from './terminal-freeze-breadcrumbs'
|
||||
import { installTerminalFreezeReport } from './terminal-freeze-report'
|
||||
import {
|
||||
releaseRetainedPtyKillOwnership,
|
||||
retryRetainedPtyKills
|
||||
} from '@/lib/pty-kill-retry-ownership'
|
||||
|
||||
// ── Singleton PTY event dispatcher ───────────────────────────────────
|
||||
// One global IPC listener per channel, routes events to transports by
|
||||
@@ -139,9 +135,6 @@ export function reattachPtyDispatcherPushListeners(): void {
|
||||
}
|
||||
|
||||
export function ensurePtyDispatcher(): void {
|
||||
// Why: a prior provider disconnect can reject shutdown while retaining the
|
||||
// exact PTY id. A later terminal lifecycle event is the safe retry trigger.
|
||||
retryRetainedPtyKills()
|
||||
if (ptyDispatcherAttached) {
|
||||
return
|
||||
}
|
||||
@@ -239,7 +232,6 @@ function attachPtySecondaryPushListeners(unsubscribes: (() => void)[]): void {
|
||||
// cumulative totals too so a reused id restarts at zero on both sides.
|
||||
clearProcessedPtyCharTotal(payload.id)
|
||||
clearReceivedPtyCharTotal(payload.id)
|
||||
releaseRetainedPtyKillOwnership(payload.id)
|
||||
const handler = ptyExitHandlers.get(payload.id)
|
||||
if (handler) {
|
||||
clearPreHandlerPtyState(payload.id)
|
||||
|
||||
@@ -484,7 +484,6 @@ describe('launchAgentBackgroundSession', () => {
|
||||
.mockRejectedValueOnce(new Error('provider unavailable'))
|
||||
.mockResolvedValueOnce(undefined)
|
||||
const { launchAgentBackgroundSession } = await import('./launch-agent-background-session')
|
||||
const { retryRetainedPtyKills } = await import('./pty-kill-retry-ownership')
|
||||
|
||||
await expect(
|
||||
launchAgentBackgroundSession({
|
||||
@@ -495,7 +494,6 @@ describe('launchAgentBackgroundSession', () => {
|
||||
).rejects.toThrow('subscription setup failed')
|
||||
|
||||
expect(mockKill).toHaveBeenCalledWith('pty-1', { expectedTabId: 'tab-1' })
|
||||
retryRetainedPtyKills()
|
||||
expect(mockKill).toHaveBeenCalledTimes(1)
|
||||
expect(mockCloseTab).toHaveBeenCalledWith('tab-1', { recordInteraction: false })
|
||||
})
|
||||
@@ -809,8 +807,6 @@ describe('launchAgentBackgroundSession', () => {
|
||||
})
|
||||
mockRuntimeEnvironmentSubscribe.mockRejectedValueOnce(new Error('subscription failed'))
|
||||
const { launchAgentBackgroundSession } = await import('./launch-agent-background-session')
|
||||
const { retryRetainedRuntimeTerminalCloses } =
|
||||
await import('./runtime-terminal-close-retry-ownership')
|
||||
|
||||
await expect(
|
||||
launchAgentBackgroundSession({
|
||||
@@ -826,7 +822,6 @@ describe('launchAgentBackgroundSession', () => {
|
||||
params: { terminal: 'terminal-1' },
|
||||
timeoutMs: undefined
|
||||
})
|
||||
retryRetainedRuntimeTerminalCloses()
|
||||
expect(closeAttempts).toBe(1)
|
||||
expect(state.clearTabPtyId).toHaveBeenCalledWith('tab-1', 'remote:env-1@@terminal-1')
|
||||
expect(state.clearAgentLaunchConfig).toHaveBeenCalledWith(expect.stringMatching(/^tab-1:/))
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
killPtyRetainingRetryOwnership,
|
||||
releaseRetainedPtyKillOwnership,
|
||||
releaseRetainedPtyKillsForSshTarget
|
||||
} from './pty-kill-retry-ownership'
|
||||
import { killPtyRetainingRetryOwnership } from './pty-kill-retry-ownership'
|
||||
import { toAppSshPtyId } from '../../../shared/ssh-pty-id'
|
||||
|
||||
const IDS = Array.from({ length: 2 }, (_, index) => `pty-retained-${index}`)
|
||||
|
||||
describe('PTY kill retry ownership', () => {
|
||||
afterEach(() => {
|
||||
for (const id of IDS) {
|
||||
releaseRetainedPtyKillOwnership(id)
|
||||
}
|
||||
vi.unstubAllGlobals()
|
||||
vi.restoreAllMocks()
|
||||
vi.useRealTimers()
|
||||
@@ -33,7 +26,7 @@ describe('PTY kill retry ownership', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('releases only a removed SSH target and cancels the final retry timer', async () => {
|
||||
it('does not create renderer retry timers after main retains failures', async () => {
|
||||
vi.useFakeTimers()
|
||||
const kill = vi.fn().mockRejectedValue(new Error('provider disconnected'))
|
||||
vi.stubGlobal('window', { api: { pty: { kill } } })
|
||||
@@ -43,12 +36,10 @@ describe('PTY kill retry ownership', () => {
|
||||
|
||||
await killPtyRetainingRetryOwnership(removedId, '[pty] failed').catch(() => {})
|
||||
await killPtyRetainingRetryOwnership(retainedId, '[pty] failed').catch(() => {})
|
||||
releaseRetainedPtyKillsForSshTarget('removed-target')
|
||||
await vi.advanceTimersByTimeAsync(250)
|
||||
|
||||
expect(kill.mock.calls.filter(([id]) => id === removedId)).toHaveLength(1)
|
||||
expect(kill.mock.calls.filter(([id]) => id === retainedId)).toHaveLength(1)
|
||||
releaseRetainedPtyKillsForSshTarget('retained-target')
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -17,15 +17,3 @@ export function killPtyRetainingRetryOwnership(
|
||||
throw error
|
||||
})
|
||||
}
|
||||
|
||||
export function retryRetainedPtyKills(): void {
|
||||
// Main retries on provider availability and bounded backoff.
|
||||
}
|
||||
|
||||
export function releaseRetainedPtyKillOwnership(id: string): void {
|
||||
void id
|
||||
}
|
||||
|
||||
export function releaseRetainedPtyKillsForSshTarget(targetId: string): void {
|
||||
void targetId
|
||||
}
|
||||
|
||||
@@ -4,17 +4,12 @@ const callRuntimeRpc = vi.hoisted(() => vi.fn())
|
||||
|
||||
vi.mock('@/runtime/runtime-rpc-client', () => ({ callRuntimeRpc }))
|
||||
|
||||
import {
|
||||
closeRuntimeTerminalRetainingRetryOwnership,
|
||||
releaseRetainedRuntimeTerminalClose,
|
||||
releaseRetainedRuntimeTerminalClosesForEnvironment
|
||||
} from './runtime-terminal-close-retry-ownership'
|
||||
import { closeRuntimeTerminalRetainingRetryOwnership } from './runtime-terminal-close-retry-ownership'
|
||||
|
||||
const TARGET = { kind: 'environment' as const, environmentId: 'env-1' }
|
||||
|
||||
describe('runtime terminal close retry ownership', () => {
|
||||
afterEach(() => {
|
||||
releaseRetainedRuntimeTerminalClose(TARGET, 'terminal-1')
|
||||
callRuntimeRpc.mockReset()
|
||||
vi.restoreAllMocks()
|
||||
vi.useRealTimers()
|
||||
@@ -38,7 +33,6 @@ describe('runtime terminal close retry ownership', () => {
|
||||
await closeRuntimeTerminalRetainingRetryOwnership(TARGET, 'terminal-2').catch(() => {})
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
|
||||
releaseRetainedRuntimeTerminalClosesForEnvironment(TARGET.environmentId)
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
await vi.advanceTimersByTimeAsync(30_000)
|
||||
expect(callRuntimeRpc).toHaveBeenCalledTimes(2)
|
||||
|
||||
@@ -9,19 +9,3 @@ export function closeRuntimeTerminalRetainingRetryOwnership(
|
||||
// Why: main owns durable retry intent, so renderer loss cannot orphan the handle.
|
||||
return callRuntimeRpc(target, 'terminal.close', { terminal: handle })
|
||||
}
|
||||
|
||||
export function retryRetainedRuntimeTerminalCloses(): void {
|
||||
// Main retries on provider availability and bounded backoff.
|
||||
}
|
||||
|
||||
export function releaseRetainedRuntimeTerminalClose(
|
||||
target: EnvironmentTarget,
|
||||
handle: string
|
||||
): void {
|
||||
void target
|
||||
void handle
|
||||
}
|
||||
|
||||
export function releaseRetainedRuntimeTerminalClosesForEnvironment(environmentId: string): void {
|
||||
void environmentId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user