Skip to content

Commit 4cb7744

Browse files
Merge pull request #248 from olasunkanmi-SE/development
Development
2 parents 6f3d197 + b254bf4 commit 4cb7744

File tree

11 files changed

+108
-37
lines changed

11 files changed

+108
-37
lines changed

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@
99
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
1010
"typescript.tsc.autoDetect": "off",
1111
"liveServer.settings.port": 5501,
12-
"chatview.theme": "Code Pen",
13-
"generativeAi.option": "Anthropic",
14-
"font.family": "Source Code Pro",
1512

1613
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
"XGrok",
160160
"Deepseek"
161161
],
162-
"default": "Groq",
162+
"default": "Gemini",
163163
"description": "Select Model"
164164
},
165165
"google.gemini.apiKeys": {

src/commands/handler.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export abstract class CodeCommandHandler implements ICodeCommandHandler {
387387
}
388388
}
389389

390-
async execute(message?: string): Promise<void> {
390+
async execute(message?: string, action?: string): Promise<void> {
391391
try {
392392
let prompt: string | undefined;
393393
const response = (await this.generateResponse(
@@ -404,18 +404,30 @@ export abstract class CodeCommandHandler implements ICodeCommandHandler {
404404
}
405405
switch (this.generativeAi) {
406406
case generativeAiModels.GROQ:
407+
await GroqWebViewProvider.webView?.webview.postMessage({
408+
type: "codebuddy-commands",
409+
message: action,
410+
});
407411
await GroqWebViewProvider.webView?.webview.postMessage({
408412
type: "bot-response",
409413
message: formattedResponse,
410414
});
411415
break;
412416
case generativeAiModels.GEMINI:
417+
await GeminiWebViewProvider.webView?.webview.postMessage({
418+
type: "codebuddy-commands",
419+
message: action,
420+
});
413421
await GeminiWebViewProvider.webView?.webview.postMessage({
414422
type: "bot-response",
415423
message: formattedResponse,
416424
});
417425
break;
418426
case generativeAiModels.ANTHROPIC || generativeAiModels.GROK:
427+
await AnthropicWebViewProvider.webView?.webview.postMessage({
428+
type: "codebuddy-commands",
429+
message: action,
430+
});
419431
await AnthropicWebViewProvider.webView?.webview.postMessage({
420432
type: "bot-response",
421433
message: formattedResponse,

src/emitter/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type AgentEventKeys =
2828
| "onFix"
2929
| "onExplain"
3030
| "onCommitMessage"
31-
| "generateMermaidDiagram"
31+
| "onGenerateMermaidDiagram"
3232
| "onInlineChat"
3333
| "onCommenting"
3434
| "onReviewing"

src/emitter/publisher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class EventEmitter extends BaseEmitter<Record<string, IEventPayload>> {
5555
onExplain: vscode.Event<IEventPayload> = this.createEvent("onExplain");
5656
onCommitMessage: vscode.Event<IEventPayload> =
5757
this.createEvent("onCommitMessage");
58-
generateMermaidDiagram: vscode.Event<IEventPayload> = this.createEvent(
58+
onGenerateMermaidDiagram: vscode.Event<IEventPayload> = this.createEvent(
5959
"generateMermaidDiagram",
6060
);
6161
onInlineChat: vscode.Event<IEventPayload> = this.createEvent("onInlineChat");

src/extension.ts

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export async function activate(context: vscode.ExtensionContext) {
9999
await credentials.getSession();
100100
logger.info(`Logged into GitHub as ${session?.account.label}`);
101101
Memory.getInstance();
102-
102+
// TODO for RAG codeIndexing incase user allows
103103
// const index = CodeIndexingService.createInstance();
104104
// Get each of the folders and call the next line for each
105105
// const result = await index.buildFunctionStructureMap();
@@ -156,48 +156,65 @@ export async function activate(context: vscode.ExtensionContext) {
156156

157157
const actionMap = {
158158
[comment]: async () => {
159-
orchestrator.publish("onCommenting");
160-
await getComment.execute();
159+
await getComment.execute(
160+
undefined,
161+
"💭 Add a helpful comment to explain the code logic",
162+
);
161163
},
162164
[review]: async () => {
163-
orchestrator.publish("onReviewing");
164-
await generateReview.execute();
165+
await generateReview.execute(
166+
undefined,
167+
"🔍 Perform a thorough code review to ensure best practices",
168+
);
165169
},
166170
[refactor]: async () => {
167-
orchestrator.publish("onRefactoring");
168-
await generateRefactoredCode.execute();
171+
await generateRefactoredCode.execute(
172+
undefined,
173+
" 🔄 Improve code readability and maintainability",
174+
);
169175
},
170176
[optimize]: async () => {
171-
orchestrator.publish("onOptimizing");
172-
await generateOptimizeCode.execute();
177+
await generateOptimizeCode.execute(
178+
undefined,
179+
"⚡ optimize for performance and efficiency",
180+
);
173181
},
174182
[interviewMe]: async () => {
175-
orchestrator.publish("onInterviewMe");
176-
await generateInterviewQuestions.execute();
183+
await generateInterviewQuestions.execute(
184+
undefined,
185+
"📚 Prepare for technical interviews with relevant questions",
186+
);
177187
},
178188
[fix]: (errorMessage: string) => {
179-
orchestrator.publish("onFix");
180189
new FixError(
181190
`${USER_MESSAGE} finds a solution to the error...`,
182191
context,
183192
errorMessage,
184-
).execute(errorMessage);
193+
).execute(errorMessage, "🔧 Debug and fix the issue");
185194
},
186195
[explain]: async () => {
187-
orchestrator.publish("onExplain");
188-
await explainCode.execute();
196+
await explainCode.execute(
197+
undefined,
198+
"💬 Get a clear and concise explanation of the code concept",
199+
);
189200
},
190201
[commitMessage]: async () => {
191-
orchestrator.publish("onCommitMessage");
192-
await generateCommitMessage.execute("commitMessage");
202+
await generateCommitMessage.execute(
203+
undefined,
204+
"🧪 generating commit message",
205+
);
193206
},
194207
[generateDiagram]: async () => {
195-
orchestrator.publish("generateMermaidDiagram");
196-
await generateMermaidDiagram.execute();
208+
await generateMermaidDiagram.execute(
209+
undefined,
210+
"📈 Visualize the code with a Mermaid diagram",
211+
);
197212
},
198213
[inlineChat]: async () => {
199-
orchestrator.publish("onInlineChat");
200-
await getInLineChat.execute();
214+
await getInLineChat.execute(
215+
undefined,
216+
"💬 Discuss and reason about your code with me",
217+
);
201218
},
202219
};
203220

src/webview-providers/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { formatText } from "../utils/utils";
1414
import { getWebviewContent } from "../webview/chat";
1515
import { ChatHistoryManager } from "../services/chat-history-manager";
1616
import { LogLevel } from "../services/telemetry";
17+
import { CODEBUDDY_ACTIONS } from "../application/constant";
1718

1819
let _view: vscode.WebviewView | undefined;
1920
export abstract class BaseWebViewProvider implements vscode.Disposable {

webviewUi/src/components/context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const styles: { [key: string]: React.CSSProperties } = {
1717
padding: "0.5rem",
1818
border: "2px solid var(--vscode-editor-background)",
1919
borderRadius: "4px",
20-
backgroundColor: "var(--vscode-input-background, #252526)",
20+
background: "#16161e",
2121
color: "inherit",
2222
},
2323
dropdown: {

webviewUi/src/components/webview.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,38 @@ export const WebviewUI = () => {
7777
type: "bot",
7878
content: message.message,
7979
language: "Typescript",
80+
alias: "O",
8081
},
8182
]);
8283
break;
83-
case "user-prompt":
84+
// case "user-prompt":
85+
// setMessages((prevMessages) => [
86+
// ...(prevMessages || []),
87+
// {
88+
// type: "user",
89+
// // display only the user query with the highlighted code
90+
// content: message.message.split("\n").slice(0, 2),
91+
// alias: "O",
92+
// },
93+
// ]);
94+
// break;
95+
case "bootstrap":
96+
setFolders(message);
97+
break;
98+
case "codebuddy-commands":
8499
setMessages((prevMessages) => [
85100
...(prevMessages || []),
86101
{
87102
type: "user",
88-
// display only the user query with the highlighted code
89-
content: message.message.split("\n").slice(0, 2),
103+
content:
104+
message.message.toLowerCase() === "inline chat"
105+
? message.message.split("\n").slice(0, 2)
106+
: message.message,
107+
language: "Typescript",
90108
alias: "O",
91109
},
92110
]);
93111
break;
94-
case "bootstrap":
95-
setFolders(message);
96-
break;
97112
case "chat-history":
98113
try {
99114
setMessages((prevMessages) => [
@@ -284,6 +299,7 @@ export const WebviewUI = () => {
284299
value={username}
285300
className="text-input"
286301
maxLength={10}
302+
disabled={true}
287303
/>
288304
</span>
289305
<span style={{ marginLeft: "5px" }}>
@@ -292,6 +308,7 @@ export const WebviewUI = () => {
292308
initialText="save"
293309
clickedText="saving..."
294310
duration={2000}
311+
disabled={true}
295312
></Button>
296313
</span>
297314
</div>
@@ -380,6 +397,7 @@ export const WebviewUI = () => {
380397
onInput={handleTextChange}
381398
placeholder="Ask Anything"
382399
onKeyDown={handleKeyDown}
400+
style={{ background: "#16161e" }}
383401
/>
384402
</div>
385403
<div className="horizontal-stack">

webviewUi/src/constants/constant.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,33 @@ export const faqItems: FAQItem[] = [
9494

9595
{
9696
question: "CAN I DOWNLOAD MY CHAT HISTORY",
97-
answer: `This version of codebuddy give the data back to the user by creating a gitignored file called .codebuddy. This file can be found at the root level of your application. It houses your chatHistory and in the future, your logs.`,
97+
answer: `Yes you can. This version of codebuddy give the data back to the user by creating a gitignored file called .codebuddy. This file can be found at the root level of your application. It houses your chatHistory and in the future, your logs.`,
98+
},
99+
{
100+
question: "WHAT IS THE ACTIVE WORKSPACE",
101+
answer: `<p>The active workspace displays the current working workspace of the user within VS Code, providing the following benefits:</p>
102+
103+
<ul>
104+
<li><strong>Workspace Context:</strong>Your current workspace appears at the top of the file and directory hierarchy as you navigate through your codebase, making it easier to stay oriented</li>
105+
<li><strong>Workspace Management:</strong> Particularly useful when different workspace is opened, as it confirms which project CodeBuddy is analyzing</li>
106+
</ul>
107+
`,
108+
},
109+
{
110+
question:
111+
"WHAT IS THE CHAT CONTEXT AND HOW CAN IT HELP ME TO ENHANCE MY CODING EXPERIENCE ",
112+
answer: `
113+
114+
<p>Chat Context in CodeBuddy is a powerful feature that allows you to add multiple files to provide relevant background information to the AI model when you ask questions. Here's how it works and why it's beneficial:</p>
115+
116+
<h3>How Chat Context Works:</h3> <ul> <li>When working on complex code problems, you can select specific files from your workspace to include as "context"</li> <li>These files are bundled together and sent to the LLM (Gemini, Anthropic, or Groq) along with your question</li> <li>The AI can then analyze these files to understand your codebase's structure, dependencies, and implementation details</li> <li>This gives the AI a more comprehensive understanding of your project, enabling it to provide more accurate and contextually relevant answers</li> </ul>
117+
118+
<h3>Benefits of Using Chat Context:</h3> <ul> <li><strong>More accurate responses:</strong> The AI can provide solutions that align with your existing code patterns and architectural decisions</li> <li><strong>Reduced explanation effort:</strong> Instead of describing your code structure in detail, you can simply include relevant files</li> <li><strong>Contextual debugging:</strong> Include error logs or problematic files to help the AI pinpoint issues faster</li> <li><strong>Project-aware recommendations:</strong> Receive suggestions that take into account your specific implementation, not just generic advice</li> <li><strong>Time savings:</strong> Eliminate back-and-forth exchanges where the AI requests more information about your code</li> </ul>
119+
120+
<h3>When to Use Chat Context:</h3> <ul> <li>When debugging complex issues that span multiple files</li> <li>When asking how to implement a feature that needs to integrate with your existing code</li> <li>When seeking code optimization advice for specific parts of your application</li> <li>When requesting explanations about code functionality across different components</li> </ul>
121+
122+
<p>By utilizing Chat Context, you transform CodeBuddy from a general coding assistant into a specialized collaborator that truly understands your unique project environment.</p> </div>
123+
`,
98124
},
99125

100126
{

0 commit comments

Comments
 (0)