fix: restore coding history and quota feedback
This commit is contained in:
1 parent
38f85f6b5e
commit
d523b72cf8
14 files changed
+480
-49
No files matched your search
@@ -242,7 +242,7 @@ describe('Pi session projector', () => {
|
||||
expect(snapshot.cursor).toEqual({ workerGeneration: 1, seq: 7 });
|
||||
});
|
||||
|
||||
it('applies retained-tail compaction and reconciles durable entries without replacing live IDs', async () => {
|
||||
it('projects the full active history around compaction and reconciles durable entries without replacing live IDs', async () => {
|
||||
const live: ConversationSnapshot = {
|
||||
...baseSnapshot(),
|
||||
nodes: [
|
||||
@@ -371,10 +371,11 @@ describe('Pi session projector', () => {
|
||||
});
|
||||
|
||||
expect(snapshot.nodes.map(({ kind, id }) => ({ kind, id }))).toEqual([
|
||||
{ kind: 'compaction', id: 'live-compaction-a' },
|
||||
{ kind: 'message', id: 'entry:entry-old-user' },
|
||||
{ kind: 'message', id: 'live-user-a' },
|
||||
{ kind: 'message', id: 'live-assistant-a' },
|
||||
{ kind: 'tool', id: 'live-tool-a' },
|
||||
{ kind: 'compaction', id: 'live-compaction-a' },
|
||||
{ kind: 'message', id: 'entry:entry-after-user' },
|
||||
]);
|
||||
expect(snapshot.nodes).toContainEqual(expect.objectContaining({
|
||||
@@ -401,10 +402,55 @@ describe('Pi session projector', () => {
|
||||
compaction: 'idle',
|
||||
recalculating: true,
|
||||
});
|
||||
expect(JSON.stringify(snapshot)).not.toContain('Summarized old question');
|
||||
expect(JSON.stringify(snapshot)).toContain('Summarized old question');
|
||||
expect(JSON.stringify(snapshot)).not.toContain('summary must stay hidden');
|
||||
});
|
||||
|
||||
it('restores persisted Provider quota failures as safe actionable notices', async () => {
|
||||
const snapshot = await projectPiSessionSnapshot({
|
||||
snapshot: baseSnapshot(),
|
||||
workerGeneration: 2,
|
||||
state: { sessionId: 'pi-session-a', isStreaming: false, isCompacting: false },
|
||||
entries: {
|
||||
leafId: 'entry-quota-error',
|
||||
entries: [
|
||||
{
|
||||
type: 'message',
|
||||
id: 'entry-quota-user',
|
||||
parentId: null,
|
||||
message: { role: 'user', content: 'Continue', timestamp: 1 },
|
||||
},
|
||||
{
|
||||
type: 'message',
|
||||
id: 'entry-quota-error',
|
||||
parentId: 'entry-quota-user',
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: [],
|
||||
stopReason: 'error',
|
||||
errorMessage: '403: {"message":"词元点数余额不足","code":"token_point_balance_exhausted","request_id":"secret-request"}',
|
||||
timestamp: 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(snapshot.nodes).toContainEqual(expect.objectContaining({
|
||||
kind: 'message',
|
||||
id: 'entry:entry-quota-error',
|
||||
status: 'error',
|
||||
}));
|
||||
expect(snapshot.nodes).toContainEqual({
|
||||
kind: 'notice',
|
||||
id: 'entry:entry-quota-error:provider-error',
|
||||
code: 'CODING_PROVIDER_QUOTA_EXHAUSTED',
|
||||
level: 'error',
|
||||
message: '词元点数余额不足,请充值后重试。',
|
||||
});
|
||||
expect(JSON.stringify(snapshot)).not.toContain('secret-request');
|
||||
});
|
||||
|
||||
it('projects persisted images through attachment storage without retaining base64', async () => {
|
||||
const rawImage = 'A'.repeat(1024 * 1024);
|
||||
const projected = await projectPiSessionSnapshot({
|
||||
|
||||
Reference in new issue
Block a user