Skip to content

Commit

Permalink
Fix: CodeLens workflow (#147)
Browse files Browse the repository at this point in the history
* wip: saving current page for IDE & ToolUse type export

* chore: console.log removal
  • Loading branch information
alashchev17 authored Oct 14, 2024
1 parent 4b5e226 commit 0374321
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/events/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Careful with exports that include components, it'll cause this to compile to a large file.
import type { FileInfo } from "../features/Chat/activeFile";
// TODO: this cause more exports than needed :/
export { type ChatThread, type Chat } from "../features/Chat/Thread/types";
export {
type ChatThread,
type Chat,
type ToolUse,
} from "../features/Chat/Thread/types";
export { newChatAction } from "../features/Chat/Thread/actions";
import { type Chat } from "../features/Chat/Thread/types";
import type { Snippet } from "../features/Chat/selectedSnippet";
Expand Down Expand Up @@ -54,6 +58,7 @@ export {
ideAnimateFileStart,
ideAnimateFileStop,
ideWriteResultsToFile,
ideChatPageChange,
} from "../hooks/useEventBusForIDE";

export const fim = {
Expand Down
9 changes: 8 additions & 1 deletion src/features/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const InnerApp: React.FC<AppProps> = ({ style }: AppProps) => {
[pages],
);

const { setupHost } = useEventsBusForIDE();
const { setupHost, chatPageChange } = useEventsBusForIDE();
const tourState = useAppSelector((state: RootState) => state.tour);
const historyState = useAppSelector((state: RootState) => state.history);
const chatId = useAppSelector(selectChatId);
Expand Down Expand Up @@ -86,6 +86,13 @@ export const InnerApp: React.FC<AppProps> = ({ style }: AppProps) => {
historyState,
]);

useEffect(() => {
if (pages.length > 1) {
const currentPage = pages.slice(-1)[0];
chatPageChange(currentPage.name);
}
}, [pages, chatPageChange]);

const onPressNext = (host: Host) => {
if (host === "cloud") {
dispatch(push({ name: "cloud login" }));
Expand Down
11 changes: 11 additions & 0 deletions src/hooks/useEventBusForIDE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const ideWriteResultsToFile = createAction<PatchResult[]>(
"ide/writeResultsToFile",
);

export const ideChatPageChange = createAction<string>("ide/chatPageChange");

import { pathApi } from "../services/refact/path";

export const useEventsBusForIDE = () => {
Expand Down Expand Up @@ -146,6 +148,14 @@ export const useEventsBusForIDE = () => {
[postMessage],
);

const chatPageChange = useCallback(
(page: string) => {
const action = ideChatPageChange(page);
postMessage(action);
},
[postMessage],
);

const [getCustomizationPath] = pathApi.useLazyCustomizationPathQuery();
const [getPrivacyPath] = pathApi.useLazyPrivacyPathQuery();
const [getBringYourOwnKeyPath] = pathApi.useLazyBringYourOwnKeyPathQuery();
Expand Down Expand Up @@ -190,5 +200,6 @@ export const useEventsBusForIDE = () => {
stopFileAnimation,
startFileAnimation,
writeResultsToFile,
chatPageChange,
};
};

0 comments on commit 0374321

Please sign in to comment.