feat: integrate learning module
This commit is contained in:
@@ -13,6 +13,7 @@ async function installFirstChatHost(electronApp: ElectronApplication): Promise<v
|
||||
type MainState = {
|
||||
captured: CapturedRequest[];
|
||||
promptPosted: boolean;
|
||||
abortPosted: boolean;
|
||||
releaseInitialHistory: (() => void) | null;
|
||||
};
|
||||
const mainGlobal = globalThis as typeof globalThis & {
|
||||
@@ -21,6 +22,7 @@ async function installFirstChatHost(electronApp: ElectronApplication): Promise<v
|
||||
const state: MainState = {
|
||||
captured: [],
|
||||
promptPosted: false,
|
||||
abortPosted: false,
|
||||
releaseInitialHistory: null,
|
||||
};
|
||||
mainGlobal.__makeloreFirstChatE2EState = state;
|
||||
@@ -169,7 +171,7 @@ async function installFirstChatHost(electronApp: ElectronApplication): Promise<v
|
||||
if (path === '/api/opencode/sessions/status') {
|
||||
return respond({
|
||||
statuses: {
|
||||
[session.id]: { type: state.promptPosted ? 'idle' : 'busy' },
|
||||
[session.id]: { type: state.promptPosted && !state.abortPosted ? 'busy' : 'idle' },
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -183,6 +185,10 @@ async function installFirstChatHost(electronApp: ElectronApplication): Promise<v
|
||||
state.promptPosted = true;
|
||||
return respond({ success: true }, 202);
|
||||
}
|
||||
if (path === `/api/opencode/sessions/${session.id}/abort` && method === 'POST') {
|
||||
state.abortPosted = true;
|
||||
return respond({ success: true });
|
||||
}
|
||||
if (path.endsWith('/todos')) return respond({ todos: [] });
|
||||
if (path.endsWith('/diff')) return respond({ diffs: [] });
|
||||
if (path === '/api/opencode/questions') return respond({ questions: [] });
|
||||
@@ -249,6 +255,15 @@ test('submits the first prompt without waiting for the known-empty session histo
|
||||
));
|
||||
return { historyPending, promptPosted };
|
||||
}).toEqual({ historyPending: true, promptPosted: true });
|
||||
|
||||
await expect(page.getByTestId('assistant-waiting-placeholder')).toHaveCount(0);
|
||||
const stopButton = page.getByRole('button', { name: '停止当前对话' });
|
||||
await expect(stopButton).toBeEnabled();
|
||||
await expect(stopButton.getByTestId('opencode-agent-response-loader')).toBeVisible();
|
||||
await stopButton.click();
|
||||
await expect.poll(async () => (await capturedRequests(electronApp)).map(
|
||||
(request) => `${request.method} ${request.path}`,
|
||||
)).toContain('POST /api/opencode/sessions/ses_first_chat_e2e/abort');
|
||||
} finally {
|
||||
await releaseInitialHistory(electronApp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user