fix(chat): list quote-only user messages in the prompt navigator
Context parts are marked synthetic, so a message made only of quoted fragments was skipped as an injected message and could not be navigated to. Such turns now appear with the same caption the bubble shows.
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
contextPayloadFromDraft,
|
||||
createContextPart,
|
||||
formatContextText,
|
||||
hasContextParts,
|
||||
readContextPart,
|
||||
type ContextPartPayload,
|
||||
} from './contextParts';
|
||||
@@ -126,4 +127,11 @@ describe('round-trip through part metadata', () => {
|
||||
metadata: { [CONTEXT_METADATA_KEY]: { kind: 'github-issue', number: 0, title: 't', url: 'u' } },
|
||||
})).toBeNull();
|
||||
});
|
||||
|
||||
test('hasContextParts detects user-attached context in a message', () => {
|
||||
const quote = asPart(contextPayloadFromDraft(draft({ source: 'chat-quote', fileLabel: 'msg_1' })));
|
||||
expect(hasContextParts([quote])).toBe(true);
|
||||
expect(hasContextParts([{ type: 'text' }])).toBe(false);
|
||||
expect(hasContextParts([])).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -312,3 +312,8 @@ export function readContextPart(part: ContextCarrierPart): ContextPartPayload |
|
||||
const parsed = contextPayloadSchema.safeParse(part.metadata?.[CONTEXT_METADATA_KEY]);
|
||||
return parsed.success ? parsed.data : null;
|
||||
}
|
||||
|
||||
/** Whether a message carries any user-attached context part. */
|
||||
export function hasContextParts(parts: ContextCarrierPart[]): boolean {
|
||||
return parts.some((part) => readContextPart(part) !== null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user