Skip to content

Commit

Permalink
feat(Refactor user message bubble): When user uses refactoring comman…
Browse files Browse the repository at this point in the history
…d we can show the prompt which user has entered in the user message bubbles
  • Loading branch information
wadhia-yash committed Feb 27, 2024
1 parent 91f8e7a commit a896f22
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 41 deletions.
1 change: 1 addition & 0 deletions user_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"0.2.1"}
89 changes: 49 additions & 40 deletions vscode/media/onboarding/onboarding.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vscode/src/providers/chat_view_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ export class FlutterGPTViewProvider implements vscode.WebviewViewProvider {
const chipsData = data.chipsData;
data.message = data.message.replace(`/${actionType}`, '').trim();
if (actionType === 'refactor') {
this._publicConversationHistory.push({ role: 'user', parts: data.message });
this._view?.webview.postMessage({ type: 'displayMessages', value: this._publicConversationHistory });
this._view?.webview.postMessage({ type: 'showLoadingIndicator' });
const result = await RefactorActionManager.handleRequest(chipsData, data, this.aiRepo!, this.context, this.analyzer!, this);
this._view?.webview.postMessage({ type: 'hideLoadingIndicator' });
Expand Down
3 changes: 2 additions & 1 deletion vscode/src/tools/refactor/refactor_from_instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function refactorCode(generationRepository: GenerationRepository, g

const workspaceFolders = vscode.workspace.workspaceFolders;
let relativePath = editor.document.fileName;
const referenceContent = editor.document.getText(editor.selection);
if (workspaceFolders && workspaceFolders.length > 0) {
const workspaceRoot = workspaceFolders[0].uri.fsPath;
relativePath = path.relative(workspaceRoot, editor.document.fileName);
Expand All @@ -62,7 +63,7 @@ export async function refactorCode(generationRepository: GenerationRepository, g
});
flutterGPTViewProvider.postMessageToWebview({
type: 'addToReference', value: JSON.stringify({
relativePath: relativePath.trim(), referenceContent: '', referenceData: {
relativePath: relativePath.trim(), referenceContent: `\`\n${relativePath.trim()}\n\`\n\`\`\`\n${referenceContent.toString()}\n\`\`\`\n`, referenceData: {
'selection': {
'start': {
'line': replaceRange.start.line,
Expand Down
1 change: 1 addition & 0 deletions vscode/src/tools/reference/add_reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function addToReference(globalState: vscode.Memento, flutterGPTView
relativePath = path.relative(workspaceRoot, editor.document.fileName);
}

debugger;
flutterGPTViewProvider.postMessageToWebview({
type: 'addToReference', value: JSON.stringify({
relativePath: relativePath.trim(), referenceContent: `\`\n${relativePath.trim()}\n\`\n\`\`\`\n${referenceContent.toString()}\n\`\`\`\n`, referenceData: {
Expand Down

0 comments on commit a896f22

Please sign in to comment.