Skip to content

Commit

Permalink
Tweak buffer output
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMcNeil committed Oct 29, 2024
1 parent ec7ff99 commit f8a6207
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/commands/runPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,15 @@ const getWorkspaceFolder = async () => {
};


export const runPrompt: (secrets: vscode.SecretStorage, mode: PromptOption) => void = (secrets: vscode.SecretStorage, mode: PromptOption) => vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: true }, async (progress, token) => {
export const runPrompt: (secrets: vscode.SecretStorage, mode: PromptOption) => void = (secrets: vscode.SecretStorage, mode: PromptOption) => vscode.window.withProgress({ location: vscode.ProgressLocation.Window, cancellable: true }, async (progress, token) => {
progress.report({ increment: 1, message: "Starting..." });
postToBackendSocket({ event: 'eventLabsPromptRunPrepare', properties: { mode } });
const result = await checkDockerDesktop();
if (result === 'RETRY') {
return runPrompt(secrets, mode);
}

progress.report({ increment: 0, message: "Starting..." });

progress.report({ increment: 5, message: "Checking for OpenAI key..." });

const hasOpenAIKey = await verifyHasOpenAIKey(secrets, true);
Expand Down Expand Up @@ -177,11 +178,12 @@ export const runPrompt: (secrets: vscode.SecretStorage, mode: PromptOption) => v
extensionOutput.appendLine(JSON.stringify(json))

Check warning on line 178 in src/commands/runPrompt.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
switch (json.method) {
case 'functions':
const { id, function: { arguments: args } } = json.params;
const { id, function: { arguments: args, name } } = json.params;
const params_str = args;
let functionRange = ranges[id] || getBaseFunctionRange();
if (functionRange.isSingleLine) {
// Add function to the end of the file and update the range
progress.report({ increment: 0, message: `Running ${name}` });
await writeToEditor(`\`\`\`json\n${params_str}`);
functionRange = new vscode.Range(functionRange.start.line, functionRange.start.character, doc.lineCount, 0);
}
Expand All @@ -192,16 +194,13 @@ export const runPrompt: (secrets: vscode.SecretStorage, mode: PromptOption) => v
}
ranges[id] = functionRange;
break;
case 'functions-done':
await writeToEditor('\n```\n\n');
break;
case 'start':
const { level, role, content } = json.params;
const header = Array(level + 1).fill('#').join('');
await writeToEditor(`${header} ROLE ${role}${content ? ` (${content})` : ''}\n\n`);
break;
case 'functions-done':
await writeToEditor(json.params.content+'\n\n');
await writeToEditor('\n```'+`\n\n*entering tool*\n\n`);
break;
case 'message':
await writeToEditor(json.params.content);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const clientOptions: LanguageClientOptions = {
documentSelector: [
{ language: "markdown", scheme: "file" },
],
progressOnInitialization: true,
progressOnInitialization: false,
outputChannel: window.createOutputChannel("Docker LSP (Markdown)"),
revealOutputChannelOn: 4,
};
Expand Down
5 changes: 5 additions & 0 deletions src/utils/promptRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export const spawnPromptImage = async (promptArg: string, projectDir: string, us
connection.dispose();
});

return new Promise<void>((resolve) => {
childProcess.on('exit', () => {
resolve();
});
});

};

Expand Down

0 comments on commit f8a6207

Please sign in to comment.