mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 13:55:50 +00:00
Compare commits
5 Commits
codex/code
...
codex/code
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3f8c9339b | ||
|
|
3305da0d49 | ||
|
|
2c7131cea6 | ||
|
|
5ad3b316d5 | ||
|
|
bc72dc2b09 |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.6 MiB |
@@ -161,9 +161,7 @@ describe('startAgentSummarization', () => {
|
|||||||
|
|
||||||
expect(forkCalls).toEqual([])
|
expect(forkCalls).toEqual([])
|
||||||
expect(updateCalls).toEqual([])
|
expect(updateCalls).toEqual([])
|
||||||
expectDebugLogContaining(
|
expectDebugLogContaining('no bounded context available')
|
||||||
'[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 () => {
|
||||||
@@ -175,9 +173,7 @@ describe('startAgentSummarization', () => {
|
|||||||
|
|
||||||
expect(forkCalls).toEqual([])
|
expect(forkCalls).toEqual([])
|
||||||
expect(updateCalls).toEqual([])
|
expect(updateCalls).toEqual([])
|
||||||
expectDebugLogContaining(
|
expectDebugLogContaining('not enough messages (2)')
|
||||||
'[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 () => {
|
||||||
@@ -192,7 +188,7 @@ describe('startAgentSummarization', () => {
|
|||||||
|
|
||||||
expect(forkCalls).toEqual([])
|
expect(forkCalls).toEqual([])
|
||||||
expect(updateCalls).toEqual([])
|
expect(updateCalls).toEqual([])
|
||||||
expectDebugLogContaining('[AgentSummary] Skipping summary — poor mode active')
|
expectDebugLogContaining('poor mode active')
|
||||||
expect(scheduledCount).toBe(initialScheduledCount + 1)
|
expect(scheduledCount).toBe(initialScheduledCount + 1)
|
||||||
expect(lastTimerHandle).not.toBe(initialTimerHandle)
|
expect(lastTimerHandle).not.toBe(initialTimerHandle)
|
||||||
})
|
})
|
||||||
@@ -222,7 +218,7 @@ describe('startAgentSummarization', () => {
|
|||||||
|
|
||||||
handle.stop()
|
handle.stop()
|
||||||
|
|
||||||
expectDebugLogContaining('[AgentSummary] Stopping summarization for task-1')
|
expectDebugLogContaining('Stopping summarization for task-1')
|
||||||
expect(clearedHandles).toEqual([pendingHandle])
|
expect(clearedHandles).toEqual([pendingHandle])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -307,9 +307,7 @@ describe('UDS inbox retention', () => {
|
|||||||
'../udsClient.js'
|
'../udsClient.js'
|
||||||
)
|
)
|
||||||
|
|
||||||
const error = await connectToPeer(path, () => {
|
const error = await connectToPeer(path).then(
|
||||||
throw new Error('Unexpected post-connect socket error')
|
|
||||||
}).then(
|
|
||||||
() => undefined,
|
() => undefined,
|
||||||
err => err,
|
err => err,
|
||||||
)
|
)
|
||||||
@@ -340,24 +338,13 @@ 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(
|
client = await connectToPeer(path, 50)
|
||||||
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(1)
|
expect(client.listenerCount('error')).toBe(0)
|
||||||
|
|
||||||
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,48 +266,33 @@ 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 owns the post-connect lifecycle through onSocketError, which is
|
* The caller is responsible for managing the connection lifecycle.
|
||||||
* 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 timeout = setTimeout(
|
const fail = (cause: unknown) => {
|
||||||
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
|
||||||
cleanupListeners()
|
conn.setTimeout(0)
|
||||||
conn.on('error', onSocketError)
|
conn.off('error', fail)
|
||||||
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