Files
hapi/shared/src/schemas.metadata.test.ts
T
AnanovoandGitHub 575e995480 feat(hub): generate fallback titles after the first completed turn (#2075)
* 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
2026-10-28 12:14:59 +08:00

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 });
});
});