Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
testing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiya1155 committed Jan 26, 2024
1 parent b5041da commit 7f66888
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 32 deletions.
5 changes: 1 addition & 4 deletions apps/desktop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
<!-- </script>-->
</head>

<body data-theme="default">
<body data-theme="system">
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
document.body.dataset['theme'] = localStorage.getItem('theme');
</script>
</body>

</html>
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>bloop</title>
</head>

<body data-theme="default">
<body data-theme="system">
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
Expand Down
6 changes: 5 additions & 1 deletion client/src/CommandBar/steps/Documentation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ const Documentation = ({}: Props) => {
useEffect(() => {
const mapped = indexedDocs.map((d) => ({
Component: DocItem,
componentProps: { doc: d, isIndexed: !!d.id, refetchDocs },
componentProps: {
doc: d,
isIndexed: d.index_status === 'done',
refetchDocs,
},
key: d.id,
}));
if (addedDoc) {
Expand Down
5 changes: 4 additions & 1 deletion client/src/CommandBar/steps/items/DocItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ const DocItem = ({

const startEventSource = useCallback(() => {
setIsIndexingFinished(false);
eventSourceRef.current?.close();
eventSourceRef.current = new EventSource(
`${apiUrl.replace('https:', '')}/docs/${doc.id}/status`,
);
setTimeout(refetchDocs, 1000);
eventSourceRef.current.onmessage = (ev) => {
try {
const data = JSON.parse(ev.data);
Expand Down Expand Up @@ -151,6 +153,7 @@ const DocItem = ({

const handleAddToProject = useCallback(() => {
if (project?.id) {
console.log('handleAddToProject', project.id, doc.id);
return addDocToProject(project.id, doc.id).finally(() => {
refreshCurrentProjectDocs();
});
Expand Down Expand Up @@ -256,7 +259,7 @@ const DocItem = ({
? favIconComponent
: MagazineIcon
}
label={docToShow.name}
label={`${docToShow.id} ${doc.id} ${docToShow.name}`}
id={'doc_settings'}
footerHint={
isIndexing ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const NoFilesMessage = ({ studioId }: Props) => {
}, [studioId]);

const isEmptyContext = useMemo(() => {
const fullStudio = project?.studios.find((s) => s.id === studioId);
const fullStudio = project?.studios.find(
(s) => s.id.toString() === studioId.toString(),
);
return !!fullStudio && !fullStudio.context.length;
}, [project?.studios, studioId]);

Expand Down
6 changes: 6 additions & 0 deletions client/src/context/projectContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export const ProjectContext = {
Current: createContext<{
project: ProjectFullType | null;
isReposLoaded: boolean;
isChatsLoaded: boolean;
isStudiosLoaded: boolean;
isDocsLoaded: boolean;
isLoading: boolean;
setCurrentProjectId: (id: string) => void;
refreshCurrentProject: () => void;
Expand All @@ -15,6 +18,9 @@ export const ProjectContext = {
}>({
project: null,
isReposLoaded: false,
isChatsLoaded: false,
isStudiosLoaded: false,
isDocsLoaded: false,
isLoading: true,
setCurrentProjectId: (id: string) => {},
refreshCurrentProject: () => {},
Expand Down
15 changes: 15 additions & 0 deletions client/src/context/providers/ProjectContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const ProjectContextProvider = ({ children }: PropsWithChildren<Props>) => {
const [project, setProject] = useState<ProjectFullType | null>(null);
const [projects, setProjects] = useState<ProjectShortType[]>([]);
const [isReposLoaded, setIsReposLoaded] = useState(false);
const [isChatsLoaded, setIsChatsLoaded] = useState(false);
const [isStudiosLoaded, setIsStudiosLoaded] = useState(false);
const [isDocsLoaded, setIsDocsLoaded] = useState(false);
const [isRegexSearchEnabled, setIsRegexSearchEnabled] = useState(false);
const [preferredAnswerSpeed, setPreferredAnswerSpeed] = useState<
'normal' | 'fast'
Expand All @@ -62,6 +65,7 @@ const ProjectContextProvider = ({ children }: PropsWithChildren<Props>) => {
const refreshCurrentProjectConversations = useCallback(async () => {
getProjectConversations(currentProjectId).then((r) => {
setProject((prev) => (prev ? { ...prev, conversations: r } : null));
setIsChatsLoaded(true);
});
}, [currentProjectId]);
const refreshCurrentProjectStudios = useCallback(async () => {
Expand All @@ -75,11 +79,13 @@ const ProjectContextProvider = ({ children }: PropsWithChildren<Props>) => {
}
: null,
);
setIsStudiosLoaded(true);
});
}, [currentProjectId]);
const refreshCurrentProjectDocs = useCallback(async () => {
getProjectDocs(currentProjectId).then((r) => {
setProject((prev) => (prev ? { ...prev, docs: r } : null));
setIsDocsLoaded(true);
});
}, [currentProjectId]);

Expand All @@ -95,6 +101,9 @@ const ProjectContextProvider = ({ children }: PropsWithChildren<Props>) => {

useEffect(() => {
setIsReposLoaded(false);
setIsChatsLoaded(false);
setIsStudiosLoaded(false);
setIsDocsLoaded(false);
}, [currentProjectId]);

useEffect(() => {
Expand Down Expand Up @@ -172,6 +181,9 @@ const ProjectContextProvider = ({ children }: PropsWithChildren<Props>) => {
() => ({
project,
isReposLoaded,
isChatsLoaded,
isStudiosLoaded,
isDocsLoaded,
setCurrentProjectId,
refreshCurrentProjectRepos,
refreshCurrentProjectConversations,
Expand All @@ -183,6 +195,9 @@ const ProjectContextProvider = ({ children }: PropsWithChildren<Props>) => {
[
project,
isReposLoaded,
isChatsLoaded,
isStudiosLoaded,
isDocsLoaded,
refreshCurrentProjectRepos,
refreshCurrentProjectConversations,
refreshCurrentProjectStudios,
Expand Down
64 changes: 59 additions & 5 deletions client/src/context/providers/TabsContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const TabsContextProvider = ({ children }: PropsWithChildren<Props>) => {
const {
project,
isReposLoaded,
isChatsLoaded,
isStudiosLoaded,
isDocsLoaded,
isLoading: isLoadingProjects,
} = useContext(ProjectContext.Current);
const { setFocusedTabItems } = useContext(CommandBarContext.Handlers);
Expand Down Expand Up @@ -387,17 +390,68 @@ const TabsContextProvider = ({ children }: PropsWithChildren<Props>) => {
[],
);

const checkIfTabsShouldClose = useCallback(
(checkIfTabShouldClose: (t: TabType | null) => boolean) => {
if (!isLoading && !isLoadingProjects) {
setActiveLeftTab((prev) => (checkIfTabShouldClose(prev) ? null : prev));
setActiveRightTab((prev) =>
checkIfTabShouldClose(prev) ? null : prev,
);
setLeftTabs((prev) => prev.filter((t) => !checkIfTabShouldClose(t)));
setRightTabs((prev) => prev.filter((t) => !checkIfTabShouldClose(t)));
}
},
[isLoading, isLoadingProjects],
);

useEffect(() => {
if (isReposLoaded && project?.repos && !isLoading && !isLoadingProjects) {
const checkIfTabShouldClose = (tab: TabType | null) =>
tab?.type === TabTypesEnum.FILE &&
!project.repos.find((r) => r.repo.ref === tab.repoRef);
setActiveLeftTab((prev) => (checkIfTabShouldClose(prev) ? null : prev));
setActiveRightTab((prev) => (checkIfTabShouldClose(prev) ? null : prev));
setLeftTabs((prev) => prev.filter((t) => !checkIfTabShouldClose(t)));
setRightTabs((prev) => prev.filter((t) => !checkIfTabShouldClose(t)));
checkIfTabsShouldClose(checkIfTabShouldClose);
}
}, [isReposLoaded, project?.repos, checkIfTabsShouldClose]);

useEffect(() => {
if (
isChatsLoaded &&
project?.conversations &&
!isLoading &&
!isLoadingProjects
) {
const checkIfTabShouldClose = (tab: TabType | null) =>
tab?.type === TabTypesEnum.CHAT &&
!!tab.conversationId &&
!project.conversations.find((r) => r.id === tab.conversationId);
checkIfTabsShouldClose(checkIfTabShouldClose);
}
}, [isChatsLoaded, project?.conversations, checkIfTabsShouldClose]);

useEffect(() => {
if (
isStudiosLoaded &&
project?.studios &&
!isLoading &&
!isLoadingProjects
) {
const checkIfTabShouldClose = (tab: TabType | null) =>
tab?.type === TabTypesEnum.STUDIO &&
!project.studios.find(
(r) => r.id.toString() === tab.studioId.toString(),
);
checkIfTabsShouldClose(checkIfTabShouldClose);
}
}, [isStudiosLoaded, project?.studios, checkIfTabsShouldClose]);

useEffect(() => {
if (isDocsLoaded && project?.docs && !isLoading && !isLoadingProjects) {
const checkIfTabShouldClose = (tab: TabType | null) =>
tab?.type === TabTypesEnum.DOC &&
!project.docs.find((r) => r.id === tab.docId);
checkIfTabsShouldClose(checkIfTabShouldClose);
}
}, [isReposLoaded, project?.repos, isLoading, isLoadingProjects]);
}, [isDocsLoaded, project?.docs, checkIfTabsShouldClose]);

const handlersContextValue = useMemo(
() => ({
Expand Down
4 changes: 2 additions & 2 deletions client/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,6 @@
"Go to current state": "Go to current state",
"Continue from this state": "Continue from this state",
"Restore session": "Restore session",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>{{repoName}}</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{repoName}} is currently indexing as soon as it is finished it will be added to your project."
}
}
10 changes: 5 additions & 5 deletions client/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,8 @@
"You can add 3 types of repositories, private, public and local.": "Puede agregar 3 tipos de repositorios, privados, públicos y locales.",
"Indexing repositories": "Repositorios de indexación",
"Skip": "Saltar",
"{{repoName}} has finished indexing and you can use it in your projects now.": "{{Reponame}} ha terminado de indexación y ahora puede usarla en sus proyectos.",
"{{repoName}} is currently indexing as soon as it is finished you will be able to add it to your project.": "{{Reponame}} actualmente está indexando tan pronto como esté terminado, podrá agregarlo a su proyecto.",
"{{repoName}} has finished indexing and you can use it in your projects now.": "{{repoName}} ha terminado de indexación y ahora puede usarla en sus proyectos.",
"{{repoName}} is currently indexing as soon as it is finished you will be able to add it to your project.": "{{repoName}} actualmente está indexando tan pronto como esté terminado, podrá agregarlo a su proyecto.",
"Ask a question": "Hacer una pregunta",
"Ask your first question": "Haz tu primera pregunta",
"<0>Create a new conversation with bloop by hitting <2></2> on your keyboard or by pressing the <4></4> in the header bar.</0>": "<0> Crea una nueva conversación con Bloop presionando <2> </2> en tu teclado o presionando el <4> </4> en la barra de encabezado. </0>",
Expand All @@ -697,6 +697,6 @@
"Back to current": "Volver a la corriente",
"Go to current state": "Ir al estado actual",
"Continue from this state": "Continuar desde este estado",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0> Reponame </0> ha terminado de indexación y se agregó al contexto del proyecto actual. También puede usarlo en sus otros proyectos ahora.",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{Reponame}} actualmente está indexando tan pronto como finalice, se agregará a su proyecto."
}
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>{{repoName}}</0> ha terminado de indexación y se agregó al contexto del proyecto actual. También puede usarlo en sus otros proyectos ahora.",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{repoName}} actualmente está indexando tan pronto como finalice, se agregará a su proyecto."
}
6 changes: 3 additions & 3 deletions client/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,6 @@
"Back to current": "Torna alla corrente",
"Go to current state": "Vai allo stato attuale",
"Continue from this state": "Continua da questo stato",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0> Reponame </0> ha terminato l'indicizzazione ed è stato aggiunto al contesto dell'attuale progetto. Ora puoi anche usarlo nei tuoi altri progetti.",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{Reponame}} sta attualmente indicizzando non appena sarà finito, verrà aggiunto al tuo progetto."
}
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>{{repoName}}</0> ha terminato l'indicizzazione ed è stato aggiunto al contesto dell'attuale progetto. Ora puoi anche usarlo nei tuoi altri progetti.",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{repoName}} sta attualmente indicizzando non appena sarà finito, verrà aggiunto al tuo progetto."
}
8 changes: 4 additions & 4 deletions client/src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@
"Bloop needs to index your repository first. This process takes a few seconds and happens only one time per repository.": "Bloopは最初にリポジトリをインデックス化する必要があります。 このプロセスには数秒かかり、リポジトリごとに1回しか発生しません。",
"Skip": "スキップ",
"Start by selecting again and pressing Enter (↵) on your keyboard.": "もう一度選択して、キーボードのEnter(‡)を押すことから始めます。",
"{{repoName}} is currently indexing as soon as it is finished you will be able to add it to your project.": "{{reponame}}は現在、完成したらすぐにインデックスを作成しています。プロジェクトに追加できるようになります。",
"{{repoName}} is currently indexing as soon as it is finished you will be able to add it to your project.": "{{repoName}}は現在、完成したらすぐにインデックスを作成しています。プロジェクトに追加できるようになります。",
"Ask a question": "質問する",
"Ask your first question": "あなたの最初の質問をしてください",
"<0>Create a new conversation with bloop by hitting <2></2> on your keyboard or by pressing the <4></4> in the header bar.</0>": "<0>キーボードで<2> </2>を押すか、ヘッダーバーの<4> </4>を押すことにより、Bloopとの新しい会話を作成します。</0>",
Expand All @@ -679,6 +679,6 @@
"Back to current": "現在に戻ります",
"Go to current state": "現在の状態に移動します",
"Continue from this state": "この状態から続けます",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>レプネーム</0>はインデックス作成が終了し、現在のプロジェクトのコンテキストに追加されました。 今すぐ他のプロジェクトで使用することもできます。",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{reponame}}は現在、完了するとすぐにインデックスを作成しています。プロジェクトに追加されます。"
}
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>{{repoName}}</0>はインデックス作成が終了し、現在のプロジェクトのコンテキストに追加されました。 今すぐ他のプロジェクトで使用することもできます。",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{repoName}}は現在、完了するとすぐにインデックスを作成しています。プロジェクトに追加されます。"
}
10 changes: 5 additions & 5 deletions client/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@
"You can add 3 types of repositories, private, public and local.": "您可以添加3种类型的存储库,即私人,公共和本地。",
"Indexing repositories": "索引存储库",
"Skip": "跳过",
"{{repoName}} has finished indexing and you can use it in your projects now.": "{{reponame}}已完成索引,您可以立即在项目中使用它。",
"{{repoName}} is currently indexing as soon as it is finished you will be able to add it to your project.": "{{reponame}}当前,一旦完成后,您就可以将其添加到项目中。",
"{{repoName}} has finished indexing and you can use it in your projects now.": "{{repoName}}已完成索引,您可以立即在项目中使用它。",
"{{repoName}} is currently indexing as soon as it is finished you will be able to add it to your project.": "{{repoName}}当前,一旦完成后,您就可以将其添加到项目中。",
"Ask a question": "问一个问题",
"Ask your first question": "问你的第一个问题",
"<0>Create a new conversation with bloop by hitting <2></2> on your keyboard or by pressing the <4></4> in the header bar.</0>": "<0>通过在键盘上击打<2> </2>或按下标题栏中的<4> </4>来创建一个新的对话。</0>。</0>",
Expand All @@ -690,6 +690,6 @@
"Back to current": "回到电流",
"Go to current state": "进入当前状态",
"Restore session": "还原会话",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0> reponame </0>已完成索引,并已添加到当前项目的上下文中。 您现在也可以在其他项目中使用它。",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{reponame}}当前索引一旦完成后,它将被添加到您的项目中。"
}
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>{{repoName}}</0>已完成索引,并已添加到当前项目的上下文中。 您现在也可以在其他项目中使用它。",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{repoName}}当前索引一旦完成后,它将被添加到您的项目中。"
}

0 comments on commit 7f66888

Please sign in to comment.