Skip to content

Commit 68efbaa

Browse files
author
mmiscool
committed
build: Added tools for making edits to the plan using chat better.
1 parent ee0754d commit 68efbaa

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

public/ChatManager.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,22 @@ export class ChatManager {
145145

146146
});
147147
individualMessageDiv.appendChild(savePlanButton);
148+
149+
150+
// button to append to plan
151+
const appendPlanButton = document.createElement('button');
152+
appendPlanButton.textContent = '📝 Append to plan';
153+
appendPlanButton.style.cursor = 'pointer';
154+
appendPlanButton.style.background = 'none';
155+
appendPlanButton.style.border = '1px solid white';
156+
appendPlanButton.style.color = 'white';
157+
appendPlanButton.style.padding = '2px 5px';
158+
appendPlanButton.style.borderRadius = '3px';
159+
appendPlanButton.addEventListener('click', async () => {
160+
await doAjax('/savePlan', { plan: message.content , append: true });
161+
162+
});
163+
individualMessageDiv.appendChild(appendPlanButton);
148164
}
149165

150166
this.chatMessageDiv.appendChild(individualMessageDiv);

public/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ProjectSettingsManager } from './ProjectSettingsManager.js';
44
import { ChatManager } from './ChatManager.js';
55
import { toolsManager } from './toolsManager.js';
66
import { FileManager } from './FileManager.js';
7-
import {ConfirmDialog} from './confirmDialog.js';
7+
import { ConfirmDialog } from './confirmDialog.js';
88

99
let ctx = {};
1010

@@ -35,7 +35,7 @@ async function setup() {
3535

3636
document.body.appendChild(tabs.getElement());
3737

38-
38+
3939
window.ctx = ctx;
4040
}
4141

src/aiCoderApiFunctions.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { applySnippets } from "./aiAssistedCodeChanges.js";
22
import { getMethodsWithArguments } from "./classListing.js";
3-
import { getAllFiles, readFile, readOrLoadFromDefault, writeFile } from "./fileIO.js";
3+
import { appendFile, getAllFiles, readFile, readOrLoadFromDefault, writeFile } from "./fileIO.js";
44
import { conversation, llmSettings, llmSettingsUpdate } from "./llmCall.js";
55
import { ctx } from "./main.js";
66
import { launchNano, printAndPause } from "./terminalHelpers.js";
@@ -103,7 +103,12 @@ Do not be lazy. Give me the complete plan as part of your response.
103103
}
104104

105105
async savePlan(parsedBody) {
106-
await writeFile('./.aiCoder/default-plan-prompt.md', parsedBody.plan);
106+
if (parsedBody.append) {
107+
await appendFile('./.aiCoder/default-plan-prompt.md', parsedBody.plan, true);
108+
} else {
109+
await writeFile('./.aiCoder/default-plan-prompt.md', parsedBody.plan);
110+
}
111+
107112
return { success: true };
108113
}
109114

src/intelligentMerge.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ export class codeManipulator {
277277

278278

279279
async readFile() {
280-
return fs.readFileSync(this.filePath, 'utf8');
280+
return readFile(this.filePath);
281281
}
282282

283283
async writeFile(newCode) {
284-
fs.writeFileSync(this.filePath, newCode, 'utf8');
284+
writeFile(this.filePath, newCode, );
285285
}
286286
}
287287

0 commit comments

Comments
 (0)