mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-25 05:07:05 +00:00
feat(pi): import and reconcile local sessions (#1365)
* feat(pi): expose local session transcripts over machine rpc * feat(pi): import and incrementally reconcile local sessions * feat(web): import and resume local Pi sessions * build(web): precache the expanded app bundle * fix(pi): harden imported history reconciliation * fix(pi): persist import cursors and media placeholders * docs(web): warn about concurrent native Pi writers * feat(pi): sync native history from session menu * fix(pi): address import review findings * fix(web): preserve delivery mode for abort restores * test(hub): use the Bun test runtime * fix(pi): preserve custom names during sync * docs(pi): clarify concurrent session guidance * perf(hub): index imported Pi sessions once * perf(hub): reuse Pi import lookup for batches * fix(web): ignore stale Pi session scans
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
ClearOpencodeSessionCallbackRequestSchema,
|
||||
ClearOpencodeSessionResponseSchema,
|
||||
ListCodexSessionsRpcResponseSchema,
|
||||
ListPiSessionsRpcResponseSchema,
|
||||
MessagesQuerySchema,
|
||||
SendMessageRequestSchema
|
||||
} from './apiTypes'
|
||||
@@ -36,6 +37,36 @@ describe('ListCodexSessionsRpcResponseSchema', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('ListPiSessionsRpcResponseSchema', () => {
|
||||
it('preserves stable Pi entry and local ids', () => {
|
||||
const parsed = ListPiSessionsRpcResponseSchema.parse({
|
||||
success: true,
|
||||
sessions: [{
|
||||
id: 'pi-session-id',
|
||||
title: 'Pi Session',
|
||||
file: '/home/user/.pi/agent/sessions/session.jsonl',
|
||||
modifiedAt: 1_000,
|
||||
messageCount: 1,
|
||||
activeEntryIds: ['entry-1'],
|
||||
messages: [{
|
||||
localId: 'pi:pi-session-id:entry-1:user',
|
||||
entryId: 'entry-1',
|
||||
parentEntryId: null,
|
||||
createdAt: 900,
|
||||
content: {
|
||||
role: 'user',
|
||||
content: { type: 'text', text: 'hello' },
|
||||
meta: { sentFrom: 'cli' }
|
||||
}
|
||||
}]
|
||||
}]
|
||||
})
|
||||
|
||||
expect(parsed.success).toBe(true)
|
||||
if (parsed.success) expect(parsed.sessions[0]?.messages?.[0]?.entryId).toBe('entry-1')
|
||||
})
|
||||
})
|
||||
|
||||
describe('ClearOpencodeSessionResponseSchema', () => {
|
||||
it('requires the new HAPI session identity', () => {
|
||||
expect(ClearOpencodeSessionResponseSchema.parse({ ok: true, sessionId: 'fresh-session' })).toEqual({
|
||||
|
||||
Reference in New Issue
Block a user