Skip to content

Commit 6757f5e

Browse files
feat: auto-prompt AI to resolve merge conflicts on failure
1 parent f049e96 commit 6757f5e

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

crates/tauri-app/frontend/src/components/chat/ChatArea.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,29 @@ export function ChatArea() {
102102
{ id: crypto.randomUUID(), thread_id: tab, role: "system" as const, content: msg },
103103
]);
104104
} catch (e) {
105-
appStore.setStore("threadMessages", tab, (msgs) => [
106-
...(msgs || []),
107-
{ id: crypto.randomUUID(), thread_id: tab, role: "system" as const, content: `Merge failed: ${e}` },
108-
]);
105+
// Auto-prompt the AI to help resolve the conflict
106+
const errorMsg = String(e);
107+
const prompt = `My merge/push just failed with this error:\n\n\`\`\`\n${errorMsg}\n\`\`\`\n\nPlease help me resolve this. Check the git status, identify any conflicts, and fix them.`;
108+
109+
try {
110+
const msgId = await ipc.persistUserMessage(tab, prompt);
111+
appStore.setStore("threadMessages", tab, (msgs) => [
112+
...(msgs || []),
113+
{ id: msgId, thread_id: tab, role: "user" as const, content: prompt },
114+
]);
115+
116+
const wt = store.worktrees[tab];
117+
const cwd = wt?.active ? wt.path : (project && project.path !== "." ? project.path : ".");
118+
119+
appStore.setStore("sessionStatuses", tab, "generating");
120+
await ipc.sendMessage(tab, prompt, store.selectedProvider, cwd, store.selectedModel ?? undefined);
121+
} catch (sendErr) {
122+
// If sending fails too, just show the error
123+
appStore.setStore("threadMessages", tab, (msgs) => [
124+
...(msgs || []),
125+
{ id: crypto.randomUUID(), thread_id: tab, role: "system" as const, content: `Merge failed: ${errorMsg}` },
126+
]);
127+
}
109128
}
110129
}
111130

0 commit comments

Comments
 (0)