Files
hapi/web/scripts/fixtures/pipeline.ts
T
AnanovoandGitHub 7a320d793a fix(web): consolidate tool card display settings (#1599)
* feat(web): add configurable tool grouping mode

* fix(web): default tool grouping to grouped

* fix(web): sync tool grouping mode in the same window

* fix(web): reset tool group ids when mode changes

* fix(web): consolidate tool card display settings

* fix(web): preserve tool chronology in grouped mode

* fix(web): preserve permission details across tool grouping

* fix(web): honor command aliases in detailed tool cards

* fix(web): preserve tool mode details and unseen state

* fix(web): refresh fixtures after tool group merge

* fix(web): keep protocol fixtures in grouped mode

* fix(web): preserve grouped tool defaults

* fix(web): prioritize ACP tool kinds

* chore: retrigger PR checks
2026-10-28 12:05:49 +08:00

33 lines
1.5 KiB
TypeScript

import { normalizeDecryptedMessage } from '@/chat/normalize'
import { reduceChatBlocks } from '@/chat/reducer'
import { buildVisibleChatBlocks } from '@/chat/toolGroups'
import type { NormalizedMessage } from '@/chat/types'
import type { FixtureExpected, FixtureInput } from './fixtureTypes'
import { projectChatBlock, projectLatestUsage, projectVisibleChatBlock } from './projection'
/**
* The exact pipeline a client must implement for chat rendering:
* normalize → reduce → group, then the normative projection. This module is
* shared by the generator and the self-conformance vitest so the two can
* never diverge.
*/
export function runFixturePipeline(input: FixtureInput): FixtureExpected {
const normalized = input.messages
.map((message) => normalizeDecryptedMessage(message))
.filter((message): message is NormalizedMessage => message !== null)
const reduced = reduceChatBlocks(normalized, input.agentState)
const visibleBlocks = buildVisibleChatBlocks(reduced.blocks, {
hasMoreMessages: input.options.hasMoreMessages,
// Golden fixtures describe the stable cross-client legacy grouping
// projection. Web-only grouped/classified presentation is selected by
// the UI and must not rewrite native fixture semantics.
groupingMode: 'legacy'
})
return {
blocks: reduced.blocks.map(projectChatBlock),
hasReadyEvent: reduced.hasReadyEvent,
latestUsage: projectLatestUsage(reduced.latestUsage),
visibleBlocks: visibleBlocks.map(projectVisibleChatBlock)
}
}