Skip to content

Commit a654cf3

Browse files
ericdalloeca-agent
andcommitted
Add chat flag, remove flag, and fork support
🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
1 parent d252609 commit a654cf3

4 files changed

Lines changed: 43 additions & 1 deletion

File tree

src/bridge/api.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,29 @@ export class EcaRemoteApi {
170170
return this.request(`/chats/${chatId}/clear`, { method: 'POST' });
171171
}
172172

173+
/** Add a flag to a chat at a specific content ID. */
174+
async addFlag(chatId: string, contentId: string, text: string): Promise<void> {
175+
return this.request(`/chats/${chatId}/flag`, {
176+
method: 'POST',
177+
body: { contentId, text },
178+
});
179+
}
180+
181+
/** Remove a flag from a chat. */
182+
async removeFlag(chatId: string, contentId: string): Promise<void> {
183+
return this.request(`/chats/${chatId}/flag/${contentId}`, {
184+
method: 'DELETE',
185+
});
186+
}
187+
188+
/** Fork a chat from a specific flag. */
189+
async forkChat(chatId: string, contentId: string): Promise<void> {
190+
return this.request(`/chats/${chatId}/fork`, {
191+
method: 'POST',
192+
body: { contentId },
193+
});
194+
}
195+
173196
/** Delete a chat entirely. */
174197
async deleteChat(chatId: string): Promise<void> {
175198
return this.request(`/chats/${chatId}`, { method: 'DELETE' });

src/bridge/outbound-handler.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ export async function handleOutbound(
8484
await api.clearChat(data.chatId);
8585
break;
8686

87+
case 'chat/addFlag': {
88+
const text = window.prompt('Enter flag name');
89+
if (text) {
90+
await api.addFlag(data.chatId, data.contentId, text);
91+
}
92+
break;
93+
}
94+
95+
case 'chat/removeFlag':
96+
await api.removeFlag(data.chatId, data.contentId);
97+
break;
98+
99+
case 'chat/fork':
100+
await api.forkChat(data.chatId, data.contentId);
101+
break;
102+
87103
// --- Config changes (apply to current chat) ---
88104
case 'chat/selectedModelChanged':
89105
await withCurrentChat(ctx, (chatId) => api.changeModel(chatId, data.model));

src/bridge/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ export type OutboundMessage =
243243
| { type: 'chat/delete'; data: { chatId: string } }
244244
| { type: 'chat/rollback'; data: { chatId: string; contentId: string } }
245245
| { type: 'chat/clearChat'; data: { chatId: string } }
246+
| { type: 'chat/addFlag'; data: { chatId: string; contentId: string } }
247+
| { type: 'chat/removeFlag'; data: { chatId: string; contentId: string } }
248+
| { type: 'chat/fork'; data: { chatId: string; contentId: string } }
246249
| { type: 'chat/selectedModelChanged'; data: { model: string } }
247250
| { type: 'chat/selectedAgentChanged'; data: { agent: string } }
248251
| { type: 'chat/selectedVariantChanged'; data: { variant: string } }

0 commit comments

Comments
 (0)