mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-11 02:11:37 +00:00
fix(web): map codex-enveloped compact-summary to the chat block (#1582)
* fix(web): map codex-enveloped compact-summary to the chat block The merged #1570 renders Pi compaction summaries as a dedicated chat block via the event envelope. A compact-summary arriving in the codex payload envelope (older import paths, future producers) would still be silently dropped by the codex-content filter; map it to the same agent-event the live pi wrapper emits, mirroring the existing context_compacted handling. Adds a normalizeAgent regression test and tightens the /compact thinking-state test to assert the last keepAlive flips true (RPC outstanding) then false (settled). Verified: bun typecheck clean; web normalizeAgent 12/12, cli runPi 57/57 in an isolated TMPDIR. * fix(web): remove duplicate showSessionSummaryInChat in markdown-a fixture Regression from #1530: the fixture object literal sets the key twice, which breaks `bun typecheck` on upstream/main (Test workflow failing on push). One-line cleanup; no behavior change. Verified: bun typecheck exit 0 across cli/web/hub.
This commit is contained in:
@@ -1034,6 +1034,28 @@ export function normalizeAgentRecord(
|
||||
}
|
||||
}
|
||||
|
||||
// Defensive parity with context_compacted above: a compact-summary
|
||||
// arriving in the codex envelope (e.g. from an older import path or a
|
||||
// future producer) must not be silently dropped by the codex-content
|
||||
// filter — map it to the same agent-event the live pi wrapper emits
|
||||
// so it renders as the dedicated chat block.
|
||||
if (data.type === 'compact-summary' && typeof data.summary === 'string') {
|
||||
return {
|
||||
id: messageId,
|
||||
localId,
|
||||
createdAt,
|
||||
role: 'event',
|
||||
content: {
|
||||
type: 'compact-summary',
|
||||
summary: data.summary,
|
||||
tokensBefore: asNumber(data.tokensBefore) ?? undefined,
|
||||
estimatedTokensAfter: asNumber(data.estimatedTokensAfter) ?? undefined
|
||||
},
|
||||
isSidechain: false,
|
||||
meta
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'token_count') {
|
||||
const usage = normalizeCodexTokenUsage(data.info, data)
|
||||
return usage ? {
|
||||
|
||||
Reference in New Issue
Block a user