mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-24 04:47:03 +00:00
* fix: show Claude sessions waiting on background tasks (#2100) backgroundTaskCount was always 0 for Claude: the hub parsed the "Command running in background" tool result only from tool_result / assistant records (Claude sends it as a user record), and waited for a <task-notification> user record that current Claude Code never emits. Set the count from Claude's system/background_tasks_changed snapshot, which the CLI already forwards and which lists every running background task (empty once the last one finishes). In the session list, waiting on background work now shows a blue spinner instead of a static blue dot (too close to the "needs input" dot) or the green "running" pulse used for selected and pinned rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): forward background_tasks_changed snapshots to the hub OutgoingMessageQueue only sends chat-visible records, so Claude's background task snapshots never left the CLI. Forward that one hidden subtype, and have the hub apply it as session state without storing a hidden message row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): draw the background spinner with the thinking spinner code Both row spinners now render through one SessionSpinner; background work only switches the color to blue and no longer adds a separate Running label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
import { OutgoingMessageQueue } from './OutgoingMessageQueue'
|
|
|
|
describe('OutgoingMessageQueue message filtering', () => {
|
|
let sent: Array<Record<string, unknown>>
|
|
let queue: OutgoingMessageQueue
|
|
|
|
beforeEach(() => {
|
|
sent = []
|
|
queue = new OutgoingMessageQueue((msg) => { sent.push(msg) })
|
|
})
|
|
|
|
afterEach(() => {
|
|
queue.destroy()
|
|
})
|
|
|
|
it('sends normal messages', async () => {
|
|
queue.enqueue({ type: 'assistant', uuid: '1' })
|
|
queue.enqueue({ type: 'user', uuid: '2' })
|
|
await queue.flush()
|
|
|
|
expect(sent).toHaveLength(2)
|
|
})
|
|
|
|
it('filters hidden system messages but sends visible system messages', async () => {
|
|
queue.enqueue({ type: 'system', subtype: 'init', uuid: '1' })
|
|
queue.enqueue({ type: 'system', subtype: 'turn_duration', uuid: '2' })
|
|
queue.enqueue({ type: 'assistant', uuid: '3' })
|
|
await queue.flush()
|
|
|
|
expect(sent).toHaveLength(2)
|
|
expect(sent[0]).toMatchObject({ type: 'system', subtype: 'turn_duration' })
|
|
expect(sent[1]).toMatchObject({ type: 'assistant' })
|
|
})
|
|
|
|
it('forwards hidden background task snapshots, including empty ones', async () => {
|
|
queue.enqueue({ type: 'system', subtype: 'background_tasks_changed', tasks: [{ task_id: 'b1' }], uuid: '1' })
|
|
queue.enqueue({ type: 'system', subtype: 'background_tasks_changed', tasks: [], uuid: '2' })
|
|
queue.enqueue({ type: 'system', subtype: 'task_started', uuid: '3' })
|
|
await queue.flush()
|
|
|
|
expect(sent).toEqual([
|
|
expect.objectContaining({ subtype: 'background_tasks_changed', tasks: [{ task_id: 'b1' }] }),
|
|
expect.objectContaining({ subtype: 'background_tasks_changed', tasks: [] })
|
|
])
|
|
})
|
|
|
|
it('filters out isMeta messages', async () => {
|
|
queue.enqueue({ type: 'user', isMeta: true, uuid: '1' })
|
|
queue.enqueue({ type: 'assistant', uuid: '2' })
|
|
await queue.flush()
|
|
|
|
expect(sent).toHaveLength(1)
|
|
expect(sent[0]).toMatchObject({ type: 'assistant' })
|
|
})
|
|
|
|
it('filters out isCompactSummary messages', async () => {
|
|
queue.enqueue({ type: 'assistant', isCompactSummary: true, uuid: '1' })
|
|
queue.enqueue({ type: 'user', uuid: '2' })
|
|
await queue.flush()
|
|
|
|
expect(sent).toHaveLength(1)
|
|
expect(sent[0]).toMatchObject({ type: 'user' })
|
|
})
|
|
})
|