fix(coding): preserve runtime model and failure contracts
This commit is contained in:
1 parent
52b2467d5d
commit
195979d30f
11 files changed
+427
-112
No files matched your search
@@ -187,6 +187,57 @@ describe('PI-100 coding core Host contract', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('switches a resolved active Conversation model through the target runtime without disposing it', async () => {
|
||||
const result = await setup();
|
||||
const conversation = await createConversation(result.conversations);
|
||||
await result.conversations.acceptPrompt({
|
||||
conversationId: conversation.id,
|
||||
clientRequestId: 'request-active-model-switch',
|
||||
mode: 'prompt',
|
||||
text: 'Keep this run active',
|
||||
attachments: [],
|
||||
});
|
||||
await expect(result.runtime.getSnapshot(conversation.id)).resolves.toMatchObject({
|
||||
run: { status: 'running' },
|
||||
});
|
||||
const setModel = vi.spyOn(result.runtime, 'setModel');
|
||||
const dispose = vi.spyOn(result.runtime, 'dispose');
|
||||
const nextModel = { ...MODEL, modelId: 'model-next' };
|
||||
|
||||
await expect(result.conversations.setModel(conversation.id, nextModel)).resolves.toEqual({
|
||||
model: nextModel,
|
||||
modelResolution: 'resolved',
|
||||
});
|
||||
expect(setModel).toHaveBeenCalledWith({
|
||||
conversationId: conversation.id,
|
||||
accountId: nextModel.accountId,
|
||||
modelId: nextModel.modelId,
|
||||
});
|
||||
expect(dispose).not.toHaveBeenCalled();
|
||||
await expect(result.runtime.getSnapshot(conversation.id)).resolves.toMatchObject({
|
||||
run: { status: 'running' },
|
||||
});
|
||||
await expect(result.projects.conversationStore(result.root).get(conversation.id)).resolves.toMatchObject({
|
||||
model: nextModel,
|
||||
modelResolution: 'resolved',
|
||||
});
|
||||
});
|
||||
|
||||
it('maps Conversation thinking metadata write failures to the stable storage error', async () => {
|
||||
const result = await setup();
|
||||
const conversation = await createConversation(result.conversations);
|
||||
await result.conversations.getSnapshot(conversation.id);
|
||||
const store = result.projects.conversationStore(result.root);
|
||||
vi.spyOn(result.projects, 'conversationStore').mockReturnValue(store);
|
||||
vi.spyOn(store, 'setModelState')
|
||||
.mockRejectedValueOnce(new Error('disk full'));
|
||||
|
||||
await expect(result.conversations.setThinking(conversation.id, 'high')).rejects.toMatchObject({
|
||||
status: 500,
|
||||
code: 'CODING_STORAGE_WRITE_FAILED',
|
||||
});
|
||||
});
|
||||
|
||||
it('disposes and moves a bound session to Main-owned trash before deleting metadata', async () => {
|
||||
const result = await setup();
|
||||
const conversation = await createConversation(result.conversations);
|
||||
|
||||
Reference in new issue
Block a user