Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 32 additions & 22 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as path from "path";
import * as vscode from "vscode";
import {
APP_CONFIG,
Expand Down Expand Up @@ -28,6 +29,7 @@ import { FileUploader } from "./services/file-uploader";
import { initializeGenerativeAiEnvironment } from "./services/generative-ai-model-manager";
import { Credentials } from "./services/github-authentication";
import { getConfigValue } from "./utils/utils";
import { Logger } from "./infrastructure/logger/logger";

const {
geminiKey,
Expand All @@ -40,40 +42,48 @@ const {
grokModel,
} = APP_CONFIG;

const connectDB = async () => {
await dbManager.connect(
"file:/Users/olasunkanmi/Documents/Github/codebuddy/patterns/dev.db",
);
};
const logger = new Logger("extension");

let quickFixCodeAction: vscode.Disposable;
let agentEventEmmitter: EventEmitter;

async function connectToDatabase() {
try {
const dbPath = path.join(__dirname, "..", "patterns", "dev.db");
const urlPath = dbPath.replace(/\\/g, "/");
const isWindows = dbPath.includes("\\");
const filePath = isWindows ? `file:/${urlPath}` : `file:${urlPath}`;
await dbManager.connect(filePath);
} catch (error: any) {
logger.error("Unable to connect to DB", error);
throw new Error(error);
}
}

async function createFileDB(context: vscode.ExtensionContext) {
try {
const fileUploader = new FileUploader(context);
const files = await fileUploader.getFiles();
if (!files?.find((file) => file.includes("dev.db"))) {
await fileUploader.createFile("dev.db");
}
} catch (error: any) {
logger.error("Unable to ", error);
throw new Error(error);
}
}

export async function activate(context: vscode.ExtensionContext) {
try {
await createFileDB(context);
await connectToDatabase();
const credentials = new Credentials();
await credentials.initialize(context);
const session: vscode.AuthenticationSession | undefined =
await credentials.getSession();
vscode.window.showInformationMessage(
`Logged into GitHub as ${session?.account.label}`,
);
logger.info(`Logged into GitHub as ${session?.account.label}`);
Memory.getInstance();
await connectDB();
// const web = WebSearchService.getInstance();
// const x = CodeRepository.getInstance();
// const apiKey = getGeminiAPIKey();
// const embeddingService = new EmbeddingService(apiKey);
// const embedding = await embeddingService.generateEmbedding("is jwt web token used withnin this app ?");
// const y = await x.searchSimilarFunctions(embedding, 2);
// console.log(y);
const fileUpload = new FileUploader(context);
// await fileUpload.createFile("aiix.db");

// const files = await fileUpload.getFiles();
// const names = await fileUpload.getFileNames();
// console.log(files, names);

// const index = CodeIndexingService.createInstance();
// Get each of the folders and call the next line for each
// const result = await index.buildFunctionStructureMap();
Expand Down
2 changes: 1 addition & 1 deletion src/webview/chat_html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const chartComponent = (webview: Webview, extensionUri: Uri) => {
<link rel="stylesheet" type="text/css" href="${stylesUri}">
</head>

<body>
<body style="background-color: rgb(22, 22, 30);">
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js" integrity="sha512-EBLzUL8XLl+va/zAsmXwS7Z2B1F9HUHkZwyS/VKwh3S7T/U0nF4BaU29EP/ZSf6zgiIxYAnKLu6bJ8dqpmX5uw==" crossorigin="anonymous" referrerpolicy="no-referrer" charset="utf-8"></script>
<script enable=true type="module" nonce="${nonce}" src="${scriptUri}">
Expand Down
6 changes: 5 additions & 1 deletion webviewUi/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
margin: 0 auto;
padding: 2rem;
text-align: center;
background-color: rgb(22, 22, 30);
}

.logo {
Expand All @@ -11,9 +12,11 @@
will-change: filter;
transition: filter 300ms;
}

.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}

.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
Expand All @@ -22,6 +25,7 @@
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
Expand All @@ -39,4 +43,4 @@

.read-the-docs {
color: #888;
}
}
2 changes: 1 addition & 1 deletion webviewUi/src/components/webview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const WebviewUI = () => {
</VSCodePanelTab>

<VSCodePanelView id="view-1" style={{ height: "calc(100vh - 55px)", position: "relative" }}>
<div style={{ height: "calc(100% - 120px)", overflowY: "auto", paddingBottom: "20px" }}>
<div className="chat-content">
<div className="dropdown-container">
<div>
{messages?.map((msg) =>
Expand Down
10 changes: 9 additions & 1 deletion webviewUi/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ vscode-dropdown[open] {

vscode-text-area {
display: block;
width: 100%;
max-width: 100%;
background-color: var(--vscode-input-background, #252526);
color: var(--vscode-input-foreground, #cccccc);
Expand All @@ -142,6 +141,7 @@ vscode-text-area {
line-height: 1.6;
min-height: 36px;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
width: -webkit-fill-available
}

vscode-text-area:hover {
Expand Down Expand Up @@ -663,4 +663,12 @@ hr {
grid-template-columns: 1fr;
/* 1 card per row on small screens */
}
}

.chat-content {
height: "calc(100% - 120px)";
overflow-y: auto;
padding-bottom: 20px;
max-width: 100%;
width: "-webkit-fill-available";
}