test(session-reference): 补齐预处理分支覆盖

This commit is contained in:
creatixchu
2026-08-17 21:25:12 +08:00
parent 9eab23c176
commit fdf6fec5c0
2 changed files with 10 additions and 5 deletions
@@ -138,9 +138,11 @@ export class SessionReferenceResolver extends TypertRemoteService {
if (references.length === 0) return [message]
const resolved = await this.prepare(agent, content, references, signal)
const direct = freezeMessage({ ...message, content: resolved.content })
return resolved.additionalContext === undefined
? [direct]
: [resolved.additionalContext, direct]
/* v8 ignore if -- a parsed canonical mention always leaves one normalized reference */
if (resolved.additionalContext === undefined) {
throw new Error('session-reference preparation omitted context for a canonical mention')
}
return [resolved.additionalContext, direct]
}))
return prepared.flat()
}
@@ -314,7 +314,7 @@ describe('session reference discovery and preparation', () => {
content: [{
type: 'text',
text: `compare ${formatSessionReferenceMention({ sessionId: source.id, label: 'Research' })} now`,
}],
}, { type: 'reasoning', text: 'preserve this non-text block' }],
source: { kind: 'user' },
})
const ordinary = createUserMessage({
@@ -342,7 +342,10 @@ describe('session reference discovery and preparation', () => {
})
expect(decision.messages[1]).toMatchObject({
id: direct.id,
content: [{ type: 'text', text: 'compare @Research now' }],
content: [
{ type: 'text', text: 'compare @Research now' },
{ type: 'reasoning', text: 'preserve this non-text block' },
],
})
expect(decision.messages[1]).not.toBe(direct)
expect(decision.messages[2]).toBe(ordinary)