feat: 对接设计 Agent Gateway WebSocket

需求:服务端统一 Agent Gateway 将设计任务状态流切换为 WebSocket,客户端需要实时展示生成任务并支持断线恢复。

实现:Electron Main 管理 Session、一次性 Ticket、WebSocket 心跳与游标续传,按关闭码回收会话;Renderer 继续通过本机 Host API 的 SSE 投影接收任务事件,并保留 REST 降级同步。

验证:typecheck、变更文件 ESLint、37 个聚焦测试及 build:vite 通过。
This commit is contained in:
2026-08-02 20:15:37 +08:00
parent 83e21563dc
commit 518d7ab4cd
17 changed files with 1816 additions and 50 deletions

View File

@@ -272,6 +272,7 @@ describe('auth host api routes', () => {
);
vi.stubGlobal('fetch', fetchMock);
const stop = vi.fn(async () => undefined);
const closeEventSessions = vi.fn(async () => undefined);
const response = createResponse();
const handled = await handleAuthRoutes(
@@ -280,6 +281,7 @@ describe('auth host api routes', () => {
new URL('http://127.0.0.1:13210/api/auth/logout'),
{
opencodeManager: { stop },
imageWorkspace: { closeEventSessions },
} as never,
);
@@ -287,6 +289,7 @@ describe('auth host api routes', () => {
expect(response.statusCode).toBe(200);
expect(response.json()).toEqual({ success: true });
expect(stop).toHaveBeenCalledOnce();
expect(closeEventSessions).toHaveBeenCalledOnce();
expect(providerServiceMock.deleteAccountApiKey).toHaveBeenCalledWith('niancode-user-models');
});