feat: integrate learning module
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
inman
2026-08-16 20:52:16 +08:00
parent 26b52d76e3
commit 01bee3188b
107 changed files with 6318 additions and 12063 deletions

View File

@@ -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);
}