hide chat peek, better add docs form buttons
This commit is contained in:
parent
26482064a9
commit
999a1fff9b
4 changed files with 65 additions and 44 deletions
|
|
@ -7,7 +7,7 @@ import { SiteIndexingConfig } from "core";
|
|||
import { usePostHog } from "posthog-js/react";
|
||||
import { useContext, useLayoutEffect, useRef, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { Button, HelperText, Input, lightGray } from "..";
|
||||
import { Button, HelperText, Input, lightGray, SecondaryButton } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import {
|
||||
setDialogMessage,
|
||||
|
|
@ -15,6 +15,7 @@ import {
|
|||
} from "../../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../../redux/store";
|
||||
import IndexingStatusViewer from "../indexing/IndexingStatus";
|
||||
import { NewSessionButton } from "../mainInput/NewSessionButton";
|
||||
|
||||
function AddDocsDialog() {
|
||||
const posthog = usePostHog();
|
||||
|
|
@ -31,7 +32,7 @@ function AddDocsDialog() {
|
|||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const indexingStatuses = useSelector(
|
||||
(store: RootState) => store.state.indexingStatuses,
|
||||
(store: RootState) => store.state.indexing.statuses,
|
||||
);
|
||||
|
||||
const isFormValid = startUrl && title;
|
||||
|
|
@ -92,23 +93,23 @@ function AddDocsDialog() {
|
|||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-4 flex flex-row items-center gap-4">
|
||||
<Button
|
||||
className="flex-1"
|
||||
<div className="mt-4 flex flex-row items-center justify-end gap-4">
|
||||
<SecondaryButton
|
||||
className=""
|
||||
onClick={() => {
|
||||
setSubmittedConfig(undefined);
|
||||
}}
|
||||
>
|
||||
Add another
|
||||
</Button>
|
||||
</SecondaryButton>
|
||||
<Button
|
||||
className="flex-1"
|
||||
className=""
|
||||
onClick={() => {
|
||||
dispatch(setDialogMessage(undefined));
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
>
|
||||
Close
|
||||
Done
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
import { useSelector } from "react-redux";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { RootState } from "../../redux/store";
|
||||
|
||||
import { IndexingStatus } from "core";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { ArrowPathIcon, EyeSlashIcon } from "@heroicons/react/24/outline";
|
||||
import { setIndexingChatPeekHidden } from "../../redux/slices/stateSlice";
|
||||
|
||||
interface MergedIndexingState {
|
||||
displayName: string;
|
||||
type: string;
|
||||
type: IndexingStatus["type"];
|
||||
titles: IndexingStatus["title"][];
|
||||
progressPercentage: number;
|
||||
}
|
||||
|
|
@ -21,14 +22,16 @@ const mergeProgress = (states: IndexingStatus[]): number => {
|
|||
|
||||
export interface ChatIndexingPeekProps {
|
||||
state: MergedIndexingState;
|
||||
hidden: boolean;
|
||||
setHidden: (hidden: boolean) => void;
|
||||
}
|
||||
|
||||
function ChatIndexingPeek({ state, hidden, setHidden }: ChatIndexingPeekProps) {
|
||||
function ChatIndexingPeek({ state }: ChatIndexingPeekProps) {
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const hiddenPeeks = useSelector(
|
||||
(store: RootState) => store.state.indexing.hiddenChatPeekTypes,
|
||||
);
|
||||
|
||||
if (hidden) return null;
|
||||
if (hiddenPeeks[state.type]) return null;
|
||||
return (
|
||||
<div
|
||||
className="flex flex-row items-center border-0 border-t border-solid border-t-zinc-700 px-3 py-0.5"
|
||||
|
|
@ -65,7 +68,9 @@ function ChatIndexingPeek({ state, hidden, setHidden }: ChatIndexingPeekProps) {
|
|||
<EyeSlashIcon
|
||||
className="ml-2 h-4 w-4 cursor-pointer text-stone-500 hover:opacity-80"
|
||||
onClick={(e) => {
|
||||
setHidden(true);
|
||||
dispatch(
|
||||
setIndexingChatPeekHidden({ type: state.type, hidden: true }),
|
||||
);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
|
|
@ -75,13 +80,8 @@ function ChatIndexingPeek({ state, hidden, setHidden }: ChatIndexingPeekProps) {
|
|||
|
||||
function ChatIndexingPeeks() {
|
||||
const indexingStatuses = useSelector(
|
||||
(store: RootState) => store.state.indexingStatuses,
|
||||
(store: RootState) => store.state.indexing.statuses,
|
||||
);
|
||||
|
||||
const [hidden, setHidden] = useState<{
|
||||
[key: string]: boolean;
|
||||
}>({});
|
||||
|
||||
const mergedIndexingStates: MergedIndexingState[] = useMemo(() => {
|
||||
const mergedStates: MergedIndexingState[] = [];
|
||||
|
||||
|
|
@ -95,12 +95,6 @@ function ChatIndexingPeeks() {
|
|||
titles: docsStates.map((state) => state.title),
|
||||
progressPercentage: mergeProgress(docsStates),
|
||||
});
|
||||
} else {
|
||||
// So that next indexing will show again if hidden
|
||||
setHidden({
|
||||
...hidden,
|
||||
docs: false,
|
||||
});
|
||||
}
|
||||
return mergedStates;
|
||||
}, [indexingStatuses]);
|
||||
|
|
@ -110,18 +104,7 @@ function ChatIndexingPeeks() {
|
|||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
{mergedIndexingStates.map((state) => {
|
||||
return (
|
||||
<ChatIndexingPeek
|
||||
state={state}
|
||||
hidden={hidden[state.type]}
|
||||
setHidden={() =>
|
||||
setHidden({
|
||||
...hidden,
|
||||
[state.type]: true,
|
||||
})
|
||||
}
|
||||
/>
|
||||
);
|
||||
return <ChatIndexingPeek state={state} />;
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import AddDocsDialog from "../dialogs/AddDocsDialog";
|
|||
|
||||
function IndexingStatuses() {
|
||||
const indexingStatuses = useSelector(
|
||||
(store: RootState) => store.state.indexingStatuses,
|
||||
(store: RootState) => store.state.indexing.statuses,
|
||||
);
|
||||
const docsStatuses = useMemo(() => {
|
||||
const docs = Object.values(indexingStatuses).filter(
|
||||
|
|
@ -28,6 +28,7 @@ function IndexingStatuses() {
|
|||
{/* <div className="border-1 rounded-full border">
|
||||
<ChevronUpIcon className="h-8 w-8" />
|
||||
</div> */}
|
||||
{/* TODO add some way to hide, scroll, etc. */}
|
||||
</div>
|
||||
<span className="text-xs text-stone-500">
|
||||
Manage your documentation sources
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ type State = {
|
|||
isMultifileEdit: boolean;
|
||||
applyStates: ApplyState[];
|
||||
nextCodeBlockToApplyIndex: number;
|
||||
indexingStatuses: Record<string, IndexingStatus>;
|
||||
indexing: {
|
||||
hiddenChatPeekTypes: Record<IndexingStatus["type"], boolean>;
|
||||
statuses: Record<string, IndexingStatus>;
|
||||
};
|
||||
};
|
||||
|
||||
const initialState: State = {
|
||||
|
|
@ -70,7 +73,12 @@ const initialState: State = {
|
|||
curCheckpointIndex: 0,
|
||||
nextCodeBlockToApplyIndex: 0,
|
||||
applyStates: [],
|
||||
indexingStatuses: {},
|
||||
indexing: {
|
||||
statuses: {},
|
||||
hiddenChatPeekTypes: {
|
||||
docs: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const stateSlice = createSlice({
|
||||
|
|
@ -366,10 +374,37 @@ export const stateSlice = createSlice({
|
|||
state,
|
||||
{ payload }: PayloadAction<IndexingStatus>,
|
||||
) => {
|
||||
state.indexingStatuses = {
|
||||
...state.indexingStatuses,
|
||||
state.indexing.statuses = {
|
||||
...state.indexing.statuses,
|
||||
[payload.id]: payload,
|
||||
};
|
||||
|
||||
// This check is so that if all indexing is stopped for e.g. docs
|
||||
// The next time docs indexing starts the peek will show again
|
||||
const indexingThisType = Object.values(state.indexing.statuses).filter(
|
||||
(status) =>
|
||||
status.type === payload.type && status.status === "indexing",
|
||||
);
|
||||
if (indexingThisType.length === 0) {
|
||||
state.indexing.hiddenChatPeekTypes = {
|
||||
...state.indexing.hiddenChatPeekTypes,
|
||||
[payload.type]: false,
|
||||
};
|
||||
}
|
||||
},
|
||||
setIndexingChatPeekHidden: (
|
||||
state,
|
||||
{
|
||||
payload,
|
||||
}: PayloadAction<{
|
||||
type: IndexingStatus["type"];
|
||||
hidden: boolean;
|
||||
}>,
|
||||
) => {
|
||||
state.indexing.hiddenChatPeekTypes = {
|
||||
...state.indexing.hiddenChatPeekTypes,
|
||||
[payload.type]: payload.hidden,
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -401,6 +436,7 @@ export const {
|
|||
resetNextCodeBlockToApplyIndex,
|
||||
updateApplyState,
|
||||
updateIndexingStatus,
|
||||
setIndexingChatPeekHidden,
|
||||
} = stateSlice.actions;
|
||||
|
||||
export default stateSlice.reducer;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue