fmt(js): npm run fix on merge (#92399)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c0055b3a6d
commit
4b860d8193
@@ -91,7 +91,13 @@ describe('useRuntimeMessageRepository', () => {
|
||||
parts: [
|
||||
{ type: 'text', text: 'running…' },
|
||||
{ type: 'tool-call', toolCallId: 'call_00_DUP', toolName: 'terminal', args: {}, argsText: '' },
|
||||
{ type: 'tool-call', toolCallId: 'call_00_DUP', toolName: 'terminal', args: { done: true }, argsText: '{"done":true}' }
|
||||
{
|
||||
type: 'tool-call',
|
||||
toolCallId: 'call_00_DUP',
|
||||
toolName: 'terminal',
|
||||
args: { done: true },
|
||||
argsText: '{"done":true}'
|
||||
}
|
||||
] as ChatMessage['parts']
|
||||
}
|
||||
|
||||
@@ -103,6 +109,7 @@ describe('useRuntimeMessageRepository', () => {
|
||||
const toolParts = (assistant!.message.content as readonly { type: string; toolCallId?: string }[]).filter(
|
||||
part => part.type === 'tool-call'
|
||||
)
|
||||
|
||||
expect(toolParts).toHaveLength(2)
|
||||
expect(new Set(toolParts.map(part => part.toolCallId)).size).toBe(2)
|
||||
|
||||
@@ -126,13 +133,16 @@ describe('useRuntimeMessageRepository', () => {
|
||||
role: 'assistant',
|
||||
parts: [{ type: 'text', text: 'working' }, tool('call-a'), tool('call-b')] as ChatMessage['parts']
|
||||
}
|
||||
|
||||
const streamed: ChatMessage = {
|
||||
id: 'assistant-stream-49',
|
||||
role: 'assistant',
|
||||
parts: [tool('call-b'), tool('call-c')] as ChatMessage['parts']
|
||||
}
|
||||
|
||||
const { result } = renderHook(() => useRuntimeMessageRepository([text('user-1', 'user', 'go'), committed, streamed]))
|
||||
const { result } = renderHook(() =>
|
||||
useRuntimeMessageRepository([text('user-1', 'user', 'go'), committed, streamed])
|
||||
)
|
||||
|
||||
const assistant = result.current.messages.find(item => item.message.id === 'committed-49-assistant')
|
||||
expect(assistant).toBeDefined()
|
||||
@@ -169,6 +179,7 @@ describe('useRuntimeMessageRepository', () => {
|
||||
|
||||
for (const id of ['assistant-1', 'assistant-2']) {
|
||||
const item = result.current.messages.find(entry => entry.message.id === id)
|
||||
|
||||
const ids = (item!.message.content as readonly { type: string; toolCallId?: string }[])
|
||||
.filter(part => part.type === 'tool-call')
|
||||
.map(part => part.toolCallId)
|
||||
|
||||
@@ -20,7 +20,13 @@ import {
|
||||
} from './chat-messages'
|
||||
|
||||
const toolCallPart = (toolCallId: string): ChatMessagePart =>
|
||||
({ type: 'tool-call' as const, toolCallId, toolName: 'read_file', args: {} as never, argsText: '{}' }) as ChatMessagePart
|
||||
({
|
||||
type: 'tool-call' as const,
|
||||
toolCallId,
|
||||
toolName: 'read_file',
|
||||
args: {} as never,
|
||||
argsText: '{}'
|
||||
}) as ChatMessagePart
|
||||
|
||||
const assistantWith = (parts: ChatMessagePart[]): ChatMessage =>
|
||||
({ id: 'm1', role: 'assistant', parts, timestamp: 0 }) as unknown as ChatMessage
|
||||
|
||||
@@ -270,7 +270,11 @@ describe('coalesceToolOnlyAssistants toolCallId uniqueness', () => {
|
||||
it('drops the copy the predecessor already carries, keeps the new call', () => {
|
||||
const merged = coalesceToolOnlyAssistants(
|
||||
[
|
||||
assistant('committed-49-assistant', [{ type: 'text', text: 'working' } as ChatMessagePart, tool('call-a'), tool('call-b')]),
|
||||
assistant('committed-49-assistant', [
|
||||
{ type: 'text', text: 'working' } as ChatMessagePart,
|
||||
tool('call-a'),
|
||||
tool('call-b')
|
||||
]),
|
||||
assistant('assistant-stream-49', [tool('call-b'), tool('call-c')])
|
||||
],
|
||||
createToolMergeCache()
|
||||
@@ -278,7 +282,9 @@ describe('coalesceToolOnlyAssistants toolCallId uniqueness', () => {
|
||||
|
||||
expect(merged).toHaveLength(1)
|
||||
|
||||
const ids = merged[0].parts.filter(part => part.type === 'tool-call').map(part => (part as { toolCallId: string }).toolCallId)
|
||||
const ids = merged[0].parts
|
||||
.filter(part => part.type === 'tool-call')
|
||||
.map(part => (part as { toolCallId: string }).toolCallId)
|
||||
|
||||
expect(ids).toEqual(['call-a', 'call-b', 'call-c'])
|
||||
})
|
||||
@@ -294,7 +300,9 @@ describe('coalesceToolOnlyAssistants toolCallId uniqueness', () => {
|
||||
|
||||
expect(merged).toHaveLength(1)
|
||||
|
||||
const ids = merged[0].parts.filter(part => part.type === 'tool-call').map(part => (part as { toolCallId: string }).toolCallId)
|
||||
const ids = merged[0].parts
|
||||
.filter(part => part.type === 'tool-call')
|
||||
.map(part => (part as { toolCallId: string }).toolCallId)
|
||||
|
||||
expect(ids).toEqual(['call-a', 'call-b'])
|
||||
})
|
||||
|
||||
@@ -97,11 +97,19 @@ describe('transcript tail cache', () => {
|
||||
// parts sharing an id. This path paints DIRECTLY into the view and the same
|
||||
// bytes are re-read every launch — without repair-on-read, an affected
|
||||
// install crash-loops forever even after upgrading.
|
||||
const tool = (toolCallId: string) => ({ type: 'tool-call', toolCallId, toolName: 'terminal', args: {}, argsText: '' })
|
||||
const tool = (toolCallId: string) => ({
|
||||
type: 'tool-call',
|
||||
toolCallId,
|
||||
toolName: 'terminal',
|
||||
args: {},
|
||||
argsText: ''
|
||||
})
|
||||
|
||||
const poisoned = {
|
||||
messages: [{ id: 'assistant-p', role: 'assistant', parts: [tool('call-b'), tool('call-b')] }],
|
||||
savedAt: Date.now()
|
||||
}
|
||||
|
||||
window.localStorage.setItem('hermes.transcript-tail.v1:sess-poisoned', JSON.stringify(poisoned))
|
||||
|
||||
const loaded = loadTranscriptTail('sess-poisoned')
|
||||
|
||||
Reference in New Issue
Block a user