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

[FIX] Non-files showing up in auto file context feature #159

Conversation

charlwillia6
Copy link

Description ✏️

Fixes issue with clicking inside other tabs in the code editor, causing non filenames to show up in the Current File feature in the chat input.

This has only had a little bit of testing.

Checklist ✅

  • I have added screenshots (if UI changes are present).
  • I have done a self-review of my code.
  • I have manually tested my code (if applicable).

Introduces a new `isFirstInSession` prop to the `ContinueInputBox` and `TipTapEditor` components. This prop determines whether the top bar should be displayed for the first input in a session. The top bar is now only shown for the first input in a session, providing a cleaner interface. Additionally, the `ContinueInputBox` now renders a visual indicator to indicate when the user is entering the first prompt in a new session.
- Add file path validation in uiStateSlice's setActiveFilePath reducer
- Add validation check in VsCodeExtension's updateNewWindowActiveFilePath
- Remove redundant activeFilePath management from stateSlice
- Fix import path for isValidFilePath utility

This fixes an issue where text from the Output console could appear in
the ActiveFileIndicator when clicking New Session by ensuring file paths
are validated at all entry points and managed in a single location.
Copy link

@Fryingpannn Fryingpannn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like although on the UI it's not indicating the wrong file anymore, though underlying it's still picking up the wrong thing. I clicked on output tab then pressed enter. Under context we can still see the active file is "tasks" which is what you get by pressing the output console tab.
image

…file handling. Key changes include:

- Updated VsCodeExtension.ts to streamline active file path management.
- Enhanced VsCodeIde in ideProtocol.ts with methods for setting and retrieving the active file path.
- Modified ActiveFileIndicator.tsx and TopBarIndicators.tsx to conditionally display active file information based on session state.
- Simplified state management logic in uiStateSlice.ts.
@charlwillia6
Copy link
Author

@Fryingpannn PR has been updated. All comments have been resolved.

}
});

this.ide.onDidChangeActiveTextEditor((filepath) => {
this.core.invoke("didChangeActiveTextEditor", { filepath });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is invoke removed?

this.sidebar.webviewProtocol.request("setActiveFilePath", filepath, [PEAR_CONTINUE_VIEW_ID]);
});
context.subscriptions.push(
vscode.window.onDidChangeActiveTextEditor((event) => {
Copy link

@Fryingpannn Fryingpannn Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we have to change to use the vscode's onDidChangeActiveTextEditor? Is it just to have the !event return?

@@ -175,6 +176,10 @@ function GUI() {
const [isAtBottom, setIsAtBottom] = useState<boolean>(false);
const state = useSelector((state: RootState) => state.state);

const getIsFirstInSession = useMemo(() => {
return (idx: number) => idx === state.history.findIndex(item => item.message.role === "user");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't just check history.length?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const isFirstMessage = state.history.length === 0;

@@ -5,7 +5,11 @@ import { useCallback, useContext, useEffect } from "react";
import { X } from "lucide-react";
import { setActiveFilePath } from "@/redux/slices/uiStateSlice";

export default function ActiveFileIndicator() {
interface ActiveFileIndicatorProps {
isFirstInSession?: boolean;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of using prop. We can just check the history within active file indicator. See this PR: https://github.com/trypear/pearai-submodule/pull/181/files#diff-ea630c971a646645666575d7bbfe531ea6c00a5cb7108f3dc66ded51fccfd963R20

This PR I made above i will not be merging. Was playing around with some stuff but not good. However I did do the history stuff in there to determine first chat input, which may be worth using instead of prop drilling. Also we should grey out the thing, with unchangeable text if conversation is prompted.

@charlwillia6
Copy link
Author

PR on hold. Currently polling the community as to whether the current file feature should be removed or not.

@charlwillia6
Copy link
Author

Active FIle feature being removed and chat interface is being redesigned. Closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants