mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-07 01:21:37 +00:00
* feat(hub): generate fallback titles after the first completed turn * fix(hub): recognize batched first-turn title prompts * fix(hub): track heartbeat-only first turns for title fallback * fix(hub): preserve title turn identity across restarts
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { MetadataSchema } from './schemas';
|
|
|
|
describe('MetadataSchema cursorSessionProtocol', () => {
|
|
const base = {
|
|
path: '/tmp',
|
|
host: 'test'
|
|
};
|
|
|
|
it('accepts acp and stream-json protocol values', () => {
|
|
expect(MetadataSchema.safeParse({ ...base, cursorSessionProtocol: 'acp' }).success).toBe(true);
|
|
expect(MetadataSchema.safeParse({ ...base, cursorSessionProtocol: 'stream-json' }).success).toBe(true);
|
|
});
|
|
|
|
it('rejects unknown protocol values', () => {
|
|
expect(MetadataSchema.safeParse({ ...base, cursorSessionProtocol: 'websocket' }).success).toBe(false);
|
|
});
|
|
|
|
it('persists Pi native history entry ids', () => {
|
|
const result = MetadataSchema.safeParse({
|
|
...base,
|
|
conversationHistoryEntryIds: { 'local-user-id': 'pi-entry-id' },
|
|
});
|
|
expect(result.success).toBe(true);
|
|
expect(result.data?.conversationHistoryEntryIds).toEqual({ 'local-user-id': 'pi-entry-id' });
|
|
});
|
|
|
|
it('accepts the Hub-owned automatic title attempt marker', () => {
|
|
const result = MetadataSchema.safeParse({
|
|
...base,
|
|
titleSuggestionAutoAttemptedAt: 1234,
|
|
titleSuggestionTurn: { first: true, completed: false },
|
|
});
|
|
|
|
expect(result.success).toBe(true);
|
|
expect(result.data?.titleSuggestionAutoAttemptedAt).toBe(1234);
|
|
expect(result.data?.titleSuggestionTurn).toEqual({ first: true, completed: false });
|
|
});
|
|
});
|