fix: 收口上下文压缩生命周期边界
This commit is contained in:
@@ -204,7 +204,7 @@ describe('OpenCode native session state', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('allows only the latest compaction in an active snapshot to remain running', () => {
|
||||
it('hydrates cold compaction snapshots as completed even while the session is busy', () => {
|
||||
const state = hydrateOpenCodeSession('ses_1', [{
|
||||
info: { id: 'msg_1', role: 'assistant', sessionID: 'ses_1' },
|
||||
parts: [
|
||||
@@ -214,7 +214,50 @@ describe('OpenCode native session state', () => {
|
||||
}], 'busy');
|
||||
|
||||
expect(getOrderedSessionCompactions(state).map((event) => event.status))
|
||||
.toEqual(['completed', 'running']);
|
||||
.toEqual(['completed', 'completed']);
|
||||
});
|
||||
|
||||
it('does not attach a historical compaction to a later ordinary busy run', () => {
|
||||
const current = hydrateOpenCodeSession('ses_1', [{
|
||||
info: { id: 'msg_2', role: 'user', sessionID: 'ses_1' },
|
||||
parts: [{ id: 'text_2', type: 'text', text: 'continue normally' }],
|
||||
}], 'busy');
|
||||
const state = hydrateOpenCodeSession('ses_1', [
|
||||
{
|
||||
info: { id: 'msg_1', role: 'assistant', sessionID: 'ses_1' },
|
||||
parts: [{ id: 'compact_1', type: 'compaction', auto: true }],
|
||||
},
|
||||
{
|
||||
info: { id: 'msg_2', role: 'user', sessionID: 'ses_1' },
|
||||
parts: [{ id: 'text_2', type: 'text', text: 'continue normally' }],
|
||||
},
|
||||
], 'busy', current);
|
||||
|
||||
expect(getOrderedSessionCompactions(state)).toEqual([
|
||||
expect.objectContaining({ nativePartID: 'compact_1', status: 'completed' }),
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps a matching real-time native compaction running during active hydration', () => {
|
||||
const current = reduceOpenCodeEvent(
|
||||
hydrateOpenCodeSession('ses_1', [], 'busy'),
|
||||
{
|
||||
type: 'message.part.updated',
|
||||
payload: {
|
||||
sessionID: 'ses_1',
|
||||
messageID: 'msg_1',
|
||||
part: { id: 'compact_1', type: 'compaction', auto: true },
|
||||
},
|
||||
},
|
||||
);
|
||||
const state = hydrateOpenCodeSession('ses_1', [{
|
||||
info: { id: 'msg_1', role: 'assistant', sessionID: 'ses_1' },
|
||||
parts: [{ id: 'compact_1', type: 'compaction', auto: true }],
|
||||
}], 'busy', current);
|
||||
|
||||
expect(getOrderedSessionCompactions(state)).toEqual([
|
||||
expect.objectContaining({ nativePartID: 'compact_1', status: 'running' }),
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not downgrade a completed compaction during busy history hydration', () => {
|
||||
|
||||
Reference in New Issue
Block a user