Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depreciated active files and directory structure default #188

Merged
merged 3 commits into from
Nov 23, 2024
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
2 changes: 1 addition & 1 deletion core/protocol/ideWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
isSupermavenInstalled: [undefined, boolean];
uninstallVscodeExtension: [{ extensionId: string }, void];
completeWelcome: [undefined, void];
openInventory: [undefined, void];
openInventoryHome: [undefined, void];
getUrlTitle: [string, string];
pearAIinstallation: [{tools: ToolType[], installExtensions: boolean}, void];
};
Expand Down
2 changes: 1 addition & 1 deletion extensions/vscode/src/extension/VsCodeMessenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class VsCodeMessenger {
}
return 0;
});
this.onWebview("openInventory", (msg) => {
this.onWebview("openInventoryHome", (msg) => {
vscode.commands.executeCommand("pearai.toggleInventoryHome");
});
this.onWebview("pearAIinstallation", (msg) => {
Expand Down
6 changes: 6 additions & 0 deletions gui/src/components/ShortcutContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ const ShortcutContainer = () => {
};

const shortcuts = [
{
modifiers: [modifier],
keyCode: "E",
description: "Open Inventory",
onClick: () => ideMessenger.post("openInventoryHome", undefined),
},
{
modifiers: [modifier],
keyCode: "\\",
Expand Down
6 changes: 2 additions & 4 deletions gui/src/components/mainInput/TipTapEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ import {
} from "./getSuggestion";
import { ComboBoxItem } from "./types";
import { useLocation } from "react-router-dom";
import ActiveFileIndicator from "./ActiveFileIndicator";
import { setActiveFilePath } from "@/redux/slices/uiStateSlice";
import TopBar from "./TopBarIndicators";
import { isAiderMode, isPerplexityMode } from "../../util/bareChatMode";

Expand Down Expand Up @@ -969,8 +967,8 @@ const TipTapEditor = memo(function TipTapEditor({
});
event.preventDefault();
}}
>
{(!isPerplexity && !isAider) && <TopBar />}
>
{/* {(!isPerplexity && !isAider) && <TopBar />} */}
<EditorContent
spellCheck={false}
editor={editor}
Expand Down
9 changes: 4 additions & 5 deletions gui/src/components/mainInput/TopBarIndicators.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useContext } from "react";
import ActiveFileIndicator from "./ActiveFileIndicator";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import styled from "styled-components";
import {
Expand Down Expand Up @@ -35,19 +34,19 @@ export default function TopBar() {
const ideMessenger = useContext(IdeMessengerContext);

const handleClick = () => {
ideMessenger.post("openInventory", undefined);
ideMessenger.post("openInventoryHome", undefined);
}
return (
<div className="flex justify-between items-center mb-2 text-xs w-full">
<div className="flex items-center gap-1">
<ActiveFileIndicator />
</div>
<MenuButton
<MenuButton
offFocus={false}
onClick={handleClick}
>
{getMetaKeyLabel()}+1 Inventory
</MenuButton>
</div>

</div>
);
};
59 changes: 30 additions & 29 deletions gui/src/components/mainInput/resolveInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,35 +118,36 @@ async function resolveEditorContent(
}
}

const defaultModelTitle = (store.getState() as any).state.defaultModelTitle;
const excludeDirStructure =
defaultModelTitle?.toLowerCase() &&
EXCLUDE_DIR_STRUCTURE.some((term) =>
defaultModelTitle.toLowerCase().includes(term),
);

if (!excludeDirStructure) {
const previousDirectoryItems = (store.getState() as any).state
.directoryItems;
// use directory structure
const directoryItems = await ideMessenger.request(
"context/getContextItems",
{
name: "directory",
query: "",
fullInput: stripImages(parts),
selectedCode,
},
);

if (previousDirectoryItems !== directoryItems[0].content) {
store.dispatch(setDirectoryItems(directoryItems[0].content));
contextItems.push(...directoryItems);
for (const codebaseItem of directoryItems) {
contextItemsText += codebaseItem.content + "\n\n";
}
}
}
// Depreciated DirStructure on every request (-nang)
// const defaultModelTitle = (store.getState() as any).state.defaultModelTitle;
// const excludeDirStructure =
// defaultModelTitle?.toLowerCase() &&
// EXCLUDE_DIR_STRUCTURE.some((term) =>
// defaultModelTitle.toLowerCase().includes(term),
// );

// if (!excludeDirStructure) {
// const previousDirectoryItems = (store.getState() as any).state
// .directoryItems;
// // use directory structure
// const directoryItems = await ideMessenger.request(
// "context/getContextItems",
// {
// name: "directory",
// query: "",
// fullInput: stripImages(parts),
// selectedCode,
// },
// );

// if (previousDirectoryItems !== directoryItems[0].content) {
// store.dispatch(setDirectoryItems(directoryItems[0].content));
// contextItems.push(...directoryItems);
// for (const codebaseItem of directoryItems) {
// contextItemsText += codebaseItem.content + "\n\n";
// }
// }
// }

// cmd+enter to use codebase
if (modifiers.useCodebase) {
Expand Down
56 changes: 28 additions & 28 deletions gui/src/hooks/useChatHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger, source:
}
})
);

dispatch(setPerplexityCitations(citationsWithTitles));
}

Expand Down Expand Up @@ -208,34 +208,34 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger, source:
ideMessenger,
);

// Automatically use currently open file
if (source === 'continue' && (!modifiers.noContext || useActiveFile) && (history.length === 0 || index === 0)) {
const usingFreeTrial = defaultModel.provider === "free-trial";
// Depreciated: Automatically use currently open file (-nang)
// if (source === 'continue' && (!modifiers.noContext || useActiveFile) && (history.length === 0 || index === 0)) {
// const usingFreeTrial = defaultModel.provider === "free-trial";

const currentFilePath = await ideMessenger.ide.getCurrentFile();
if (typeof currentFilePath === "string") {
let currentFileContents =
await ideMessenger.ide.readFile(currentFilePath);
if (usingFreeTrial) {
currentFileContents = currentFileContents
.split("\n")
.slice(0, 1000)
.join("\n");
}
contextItems.unshift({
content: `The following file is currently open. Don't reference it if it's not relevant to the user's message.\n\n\`\`\`${getRelativePath(
currentFilePath,
await ideMessenger.ide.getWorkspaceDirs(),
)}\n${currentFileContents}\n\`\`\``,
name: `Active file: ${getBasename(currentFilePath)}`,
description: currentFilePath,
id: {
itemId: currentFilePath,
providerTitle: "file",
},
});
}
}
// const currentFilePath = await ideMessenger.ide.getCurrentFile();
// if (typeof currentFilePath === "string") {
// let currentFileContents =
// await ideMessenger.ide.readFile(currentFilePath);
// if (usingFreeTrial) {
// currentFileContents = currentFileContents
// .split("\n")
// .slice(0, 1000)
// .join("\n");
// }
// contextItems.unshift({
// content: `The following file is currently open. Don't reference it if it's not relevant to the user's message.\n\n\`\`\`${getRelativePath(
// currentFilePath,
// await ideMessenger.ide.getWorkspaceDirs(),
// )}\n${currentFileContents}\n\`\`\``,
// name: `Active file: ${getBasename(currentFilePath)}`,
// description: currentFilePath,
// id: {
// itemId: currentFilePath,
// providerTitle: "file",
// },
// });
// }
// }

const message: ChatMessage = {
role: "user",
Expand Down
5 changes: 0 additions & 5 deletions gui/src/pages/onboarding/OnboardingTutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,6 @@ const OnboardingTutorial: React.FC<OnboardingTutorialProps> = ({
<>
<p>
Lastly, press{" "}
<b>
<kbd className="font-mono">{getMetaKeyAndShortcutLabel()}</kbd>
&nbsp;<kbd className="font-mono">1</kbd>
</b>{" "}
/ {" "}
<b>
<kbd className="font-mono">{getMetaKeyAndShortcutLabel()}</kbd>
&nbsp;<kbd className="font-mono">E</kbd>
Expand Down