Skip to content

Commit d14b3b7

Browse files
ericdalloeca-agent
andcommitted
Add chat/askQuestion support
- Forward chat:ask-question SSE events to webview - Route chat/answerQuestion from webview to REST API - Add answerQuestion method to API client - Update eca-webview submodule with question UI 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
1 parent be544fa commit d14b3b7

5 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/bridge/api.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,18 @@ export class EcaRemoteApi {
230230
});
231231
}
232232

233+
// ---------------------------------------------------------------------------
234+
// Ask Question (chat/askQuestion flow)
235+
// ---------------------------------------------------------------------------
236+
237+
/** Answer a pending question from the server (identified by requestId). */
238+
async answerQuestion(requestId: string, answer: string | null, cancelled?: boolean): Promise<void> {
239+
return this.request('/answer', {
240+
method: 'POST',
241+
body: { requestId, answer: answer ?? null, cancelled: !!cancelled },
242+
});
243+
}
244+
233245
// ---------------------------------------------------------------------------
234246
// Trust
235247
// ---------------------------------------------------------------------------

src/bridge/outbound-handler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export async function handleOutbound(
100100
await api.forkChat(data.chatId, data.contentId);
101101
break;
102102

103+
case 'chat/answerQuestion':
104+
await api.answerQuestion(data.requestId, data.answer, data.cancelled);
105+
break;
106+
103107
// --- Config changes (apply to current chat) ---
104108
case 'chat/selectedModelChanged':
105109
await withCurrentChat(ctx, (chatId) => api.changeModel(chatId, data.model));

src/bridge/transport.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,10 @@ export class WebBridge {
719719
break;
720720
}
721721

722+
case 'chat:ask-question':
723+
this.dispatch('chat/askQuestion', data);
724+
break;
725+
722726
case 'jobs:updated':
723727
this.dispatch('jobs/updated', data);
724728
break;

src/bridge/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export type SSEEventType =
165165
| 'chat:cleared'
166166
| 'chat:deleted'
167167
| 'chat:status-changed'
168+
| 'chat:ask-question'
168169
| 'config:updated'
169170
| 'tool:server-updated'
170171
| 'trust:updated'
@@ -247,6 +248,7 @@ export type OutboundMessage =
247248
| { type: 'chat/addFlag'; data: { chatId: string; contentId: string } }
248249
| { type: 'chat/removeFlag'; data: { chatId: string; contentId: string } }
249250
| { type: 'chat/fork'; data: { chatId: string; contentId: string } }
251+
| { type: 'chat/answerQuestion'; data: { requestId: string; answer: string | null; cancelled: boolean } }
250252
| { type: 'chat/selectedModelChanged'; data: { model: string } }
251253
| { type: 'chat/selectedAgentChanged'; data: { agent: string } }
252254
| { type: 'chat/selectedVariantChanged'; data: { variant: string } }
@@ -334,6 +336,7 @@ export type DispatchType =
334336
| 'chat/cleared'
335337
| 'chat/deleted'
336338
| 'chat/opened'
339+
| 'chat/askQuestion'
337340
| 'chat/queryContext'
338341
| 'chat/queryCommands'
339342
| 'chat/queryFiles'

0 commit comments

Comments
 (0)