mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 05:45:51 +00:00
Compare commits
6 Commits
codex/code
...
codex/code
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3b16ae040 | ||
|
|
a90c16431b | ||
|
|
a5ede237f0 | ||
|
|
85dc1b9462 | ||
|
|
b47731a3f3 | ||
|
|
a65df4a102 |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.7 MiB |
@@ -161,7 +161,9 @@ describe('startAgentSummarization', () => {
|
|||||||
|
|
||||||
expect(forkCalls).toEqual([])
|
expect(forkCalls).toEqual([])
|
||||||
expect(updateCalls).toEqual([])
|
expect(updateCalls).toEqual([])
|
||||||
expectDebugLogContaining('no bounded context available')
|
expectDebugLogContaining(
|
||||||
|
'[AgentSummary] Skipping summary for task-1: no bounded context available',
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('skips summarization before building context when transcript is too short', async () => {
|
test('skips summarization before building context when transcript is too short', async () => {
|
||||||
@@ -173,7 +175,9 @@ describe('startAgentSummarization', () => {
|
|||||||
|
|
||||||
expect(forkCalls).toEqual([])
|
expect(forkCalls).toEqual([])
|
||||||
expect(updateCalls).toEqual([])
|
expect(updateCalls).toEqual([])
|
||||||
expectDebugLogContaining('not enough messages (2)')
|
expectDebugLogContaining(
|
||||||
|
'[AgentSummary] Skipping summary for task-1: not enough messages (2)',
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('skips and reschedules while poor mode is active', async () => {
|
test('skips and reschedules while poor mode is active', async () => {
|
||||||
@@ -188,7 +192,7 @@ describe('startAgentSummarization', () => {
|
|||||||
|
|
||||||
expect(forkCalls).toEqual([])
|
expect(forkCalls).toEqual([])
|
||||||
expect(updateCalls).toEqual([])
|
expect(updateCalls).toEqual([])
|
||||||
expectDebugLogContaining('poor mode active')
|
expectDebugLogContaining('[AgentSummary] Skipping summary — poor mode active')
|
||||||
expect(scheduledCount).toBe(initialScheduledCount + 1)
|
expect(scheduledCount).toBe(initialScheduledCount + 1)
|
||||||
expect(lastTimerHandle).not.toBe(initialTimerHandle)
|
expect(lastTimerHandle).not.toBe(initialTimerHandle)
|
||||||
})
|
})
|
||||||
@@ -218,7 +222,7 @@ describe('startAgentSummarization', () => {
|
|||||||
|
|
||||||
handle.stop()
|
handle.stop()
|
||||||
|
|
||||||
expectDebugLogContaining('Stopping summarization for task-1')
|
expectDebugLogContaining('[AgentSummary] Stopping summarization for task-1')
|
||||||
expect(clearedHandles).toEqual([pendingHandle])
|
expect(clearedHandles).toEqual([pendingHandle])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -307,7 +307,9 @@ describe('UDS inbox retention', () => {
|
|||||||
'../udsClient.js'
|
'../udsClient.js'
|
||||||
)
|
)
|
||||||
|
|
||||||
const error = await connectToPeer(path).then(
|
const error = await connectToPeer(path, () => {
|
||||||
|
throw new Error('Unexpected post-connect socket error')
|
||||||
|
}).then(
|
||||||
() => undefined,
|
() => undefined,
|
||||||
err => err,
|
err => err,
|
||||||
)
|
)
|
||||||
@@ -338,13 +340,24 @@ describe('UDS inbox retention', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
let client: Socket | undefined
|
let client: Socket | undefined
|
||||||
|
const socketErrors: Error[] = []
|
||||||
try {
|
try {
|
||||||
const { connectToPeer } = await import('../udsClient.js')
|
const { connectToPeer } = await import('../udsClient.js')
|
||||||
client = await connectToPeer(path, 50)
|
client = await connectToPeer(
|
||||||
|
path,
|
||||||
|
error => {
|
||||||
|
socketErrors.push(error)
|
||||||
|
},
|
||||||
|
1000,
|
||||||
|
)
|
||||||
await new Promise(resolve => setTimeout(resolve, 100))
|
await new Promise(resolve => setTimeout(resolve, 100))
|
||||||
|
|
||||||
expect(client.destroyed).toBe(false)
|
expect(client.destroyed).toBe(false)
|
||||||
expect(client.listenerCount('error')).toBe(0)
|
expect(client.listenerCount('error')).toBe(1)
|
||||||
|
|
||||||
|
const socketError = new Error('post-connect failure')
|
||||||
|
client.emit('error', socketError)
|
||||||
|
expect(socketErrors).toEqual([socketError])
|
||||||
} finally {
|
} finally {
|
||||||
client?.destroy()
|
client?.destroy()
|
||||||
for (const socket of sockets) {
|
for (const socket of sockets) {
|
||||||
|
|||||||
@@ -266,33 +266,48 @@ export async function sendToUdsSocket(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to a peer and return the raw socket for bidirectional communication.
|
* Connect to a peer and return the raw socket for bidirectional communication.
|
||||||
* The caller is responsible for managing the connection lifecycle.
|
* The caller owns the post-connect lifecycle through onSocketError, which is
|
||||||
|
* attached before the Promise resolves so peer socket errors cannot be
|
||||||
|
* swallowed or surface through a listener handoff window.
|
||||||
|
* Pre-connect failures reject with UdsPeerConnectionError.
|
||||||
|
* This only opens the transport; callers still own any capability handshake.
|
||||||
*/
|
*/
|
||||||
export function connectToPeer(
|
export function connectToPeer(
|
||||||
socketPath: string,
|
socketPath: string,
|
||||||
|
onSocketError: (error: Error) => void,
|
||||||
timeoutMs = 5000,
|
timeoutMs = 5000,
|
||||||
): Promise<Socket> {
|
): Promise<Socket> {
|
||||||
return new Promise<Socket>((resolve, reject) => {
|
return new Promise<Socket>((resolve, reject) => {
|
||||||
const conn = createConnection(socketPath)
|
const conn = createConnection(socketPath)
|
||||||
let settled = false
|
let settled = false
|
||||||
const fail = (cause: unknown) => {
|
const timeout = setTimeout(
|
||||||
|
fail,
|
||||||
|
timeoutMs,
|
||||||
|
new Error('Connection timed out'),
|
||||||
|
)
|
||||||
|
function cleanupListeners(): void {
|
||||||
|
clearTimeout(timeout)
|
||||||
|
conn.off('error', fail)
|
||||||
|
}
|
||||||
|
function fail(cause: unknown): void {
|
||||||
if (settled) {
|
if (settled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
settled = true
|
settled = true
|
||||||
|
cleanupListeners()
|
||||||
conn.destroy()
|
conn.destroy()
|
||||||
reject(new UdsPeerConnectionError(socketPath, cause))
|
reject(new UdsPeerConnectionError(socketPath, cause))
|
||||||
}
|
}
|
||||||
conn.once('connect', () => {
|
conn.once('connect', () => {
|
||||||
|
if (settled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
settled = true
|
settled = true
|
||||||
conn.setTimeout(0)
|
cleanupListeners()
|
||||||
conn.off('error', fail)
|
conn.on('error', onSocketError)
|
||||||
resolve(conn)
|
resolve(conn)
|
||||||
})
|
})
|
||||||
conn.on('error', fail)
|
conn.on('error', fail)
|
||||||
conn.setTimeout(timeoutMs, () => {
|
|
||||||
fail(new Error('Connection timed out'))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user