Skip to content

Commit

Permalink
Minor fixes (#1222)
Browse files Browse the repository at this point in the history
* focus first item on search changed

* fix model param name

* set focus on the panel where user types, fix scroll to line when clicking from chat

* fix missing highlights in left sidebar for currently focused tab

* fix long names in command bar items

* don't add repos to project automatically, but add a button to 'indexing finished' toast
  • Loading branch information
anastasiya1155 authored Jan 31, 2024
1 parent 477047a commit c387128
Show file tree
Hide file tree
Showing 27 changed files with 206 additions and 60 deletions.
4 changes: 2 additions & 2 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const toastOptions = {
unStyled: true,
classNames: {
toast:
'w-[20.75rem] p-4 pl-5 flex items-start gap-3 rounded-md border border-bg-border bg-bg-base shadow-high',
'w-[20.75rem] p-4 pl-5 grid grid-cols-[1rem_1fr] items-start gap-3 rounded-md border border-bg-border bg-bg-base shadow-high',
error: 'text-red',
info: 'text-label-title',
title: 'body-s-b',
description: '!text-label-muted body-s mt-1.5',
actionButton: 'bg-zinc-400',
actionButton: 'col-span-full',
cancelButton: 'bg-orange-400',
closeButton:
'!bg-bg-base !text-label-muted !border-none !left-[unset] !right-2 !top-6 !w-6 !h-6',
Expand Down
2 changes: 1 addition & 1 deletion client/src/CommandBar/Body/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const CommandBarItem = ({
/>
)}
</div>
<p className="flex-1 body-s-b">{label}</p>
<p className="flex-1 body-s-b ellipsis">{label}</p>
{!!shortcutKeys && (
<div className="flex items-center gap-1">
{shortcutKeys.map((k) => (
Expand Down
6 changes: 6 additions & 0 deletions client/src/CommandBar/Body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const CommandBarBody = ({
const { focusedIndex, setFocusedIndex, handleArrowKey, navContainerRef } =
useArrowNavigation();

useEffect(() => {
if (sections?.[0]?.items?.[0]) {
setFocusedIndex(`${sections[0].key}-${sections[0].items[0].key}`);
}
}, [sections]);

useEffect(() => {
if (onFocusedIndexChange) {
onFocusedIndexChange(focusedIndex);
Expand Down
8 changes: 2 additions & 6 deletions client/src/CommandBar/steps/ManageRepos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,14 @@ const ManageRepos = ({ shouldShowTutorial }: Props) => {
setTutorialStep(3);
},
onDone: () => {
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(4);
},
onAddToProject: () => {
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(4);
setTutorialStep(5);
},
},
key: r.ref,
Expand Down Expand Up @@ -234,7 +230,7 @@ const ManageRepos = ({ shouldShowTutorial }: Props) => {
placeholder={t('')}
disableKeyNav={isDropdownVisible}
/>
{shouldShowTutorial && tutorialStep < 4 ? (
{shouldShowTutorial && tutorialStep < 5 ? (
<TutorialTooltip
content={
<TutorialBody
Expand Down
8 changes: 2 additions & 6 deletions client/src/CommandBar/steps/PrivateRepos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,14 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => {
setTutorialStep(3);
},
onDone: () => {
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(4);
},
onAddToProject: () => {
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(4);
setTutorialStep(5);
},
},
key: r.ref,
Expand Down Expand Up @@ -131,7 +127,7 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => {
placeholder={t('Search private repos...')}
disableKeyNav={isDropdownVisible}
/>
{shouldShowTutorial && tutorialStep < 4 ? (
{shouldShowTutorial && tutorialStep < 5 ? (
<TutorialTooltip
content={
<TutorialBody
Expand Down
2 changes: 1 addition & 1 deletion client/src/CommandBar/steps/items/RepoItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ const RepoItem = ({
{t(repoStatusMap[status].text)}
{indexingStatus?.percentage !== null &&
indexingStatus?.percentage !== undefined &&
${indexingStatus?.percentage}%`}
` · ${indexingStatus?.percentage}%`}
</p>
) : undefined
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ const ChatPersistentState = ({
options ? `/explain` : ``
}`;
const queryParams: Record<string, string> = {
model:
answer_model:
preferredAnswerSpeed === 'normal'
? 'gpt-4'
? 'gpt-4-turbo-24k'
: 'gpt-3.5-turbo-finetuned',
};
if (conversationId) {
Expand Down
3 changes: 3 additions & 0 deletions client/src/Project/CurrentTabContent/ChatTab/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { MentionOptionType } from '../../../../types/results';
import { splitPath } from '../../../../utils';
import { openTabsCache } from '../../../../services/cache';
import { CommandBarContext } from '../../../../context/commandBarContext';
import { UIContext } from '../../../../context/uiContext';
import InputCore from './InputCore';
import { mapEditorContentToInputValue } from './utils';

Expand Down Expand Up @@ -76,6 +77,7 @@ const ConversationInput = ({
const { t } = useTranslation();
const { envConfig } = useContext(EnvContext);
const { isVisible } = useContext(CommandBarContext.General);
const { setIsLeftSidebarFocused } = useContext(UIContext.Focus);
const [initialValue, setInitialValue] = useState<
Record<string, any> | null | undefined
>({
Expand Down Expand Up @@ -135,6 +137,7 @@ const ConversationInput = ({

const onChangeInput = useCallback((inputState: InputEditorContent[]) => {
setInputValue(mapEditorContentToInputValue(inputState));
setIsLeftSidebarFocused(false);
}, []);

const onSubmitButtonClicked = useCallback(() => {
Expand Down
1 change: 1 addition & 0 deletions client/src/Project/CurrentTabContent/FileTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ const FileTab = ({
<div
className="flex-1 h-full max-w-full pl-4 py-4 overflow-auto"
data-active={(focusedPanel === side).toString()}
data-path={path}
>
{file?.lang === 'jupyter notebook' ? (
<IpynbRenderer data={file.contents} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,31 @@ import { useArrowNavigationItemProps } from '../../../../hooks/useArrowNavigatio

type Props = ConversationShortType & {
index: string;
isCurrentPath?: boolean;
};

const ConversationEntry = ({ title, id, index }: Props) => {
const ConversationEntry = ({ title, id, index, isCurrentPath }: Props) => {
const { openNewTab } = useContext(TabsContext.Handlers);

const onClick = useCallback(() => {
openNewTab({ type: TabTypesEnum.CHAT, conversationId: id, title });
}, [openNewTab, id, title]);

const { isFocused, props } = useArrowNavigationItemProps<HTMLAnchorElement>(
index,
onClick,
);
const { isFocused, isLeftSidebarFocused, props } =
useArrowNavigationItemProps<HTMLAnchorElement>(index, onClick);

return (
<a
href="#"
className={`w-full text-left h-7 flex-shrink-0 flex items-center gap-3 pr-2 cursor-pointer
ellipsis body-mini group pl-10.5 ${
isFocused ? 'bg-bg-sub-hover text-label-title' : 'text-label-base'
isCurrentPath
? isLeftSidebarFocused
? 'bg-bg-shade-hover text-label-title'
: 'bg-bg-shade text-label-title'
: isFocused
? 'bg-bg-sub-hover text-label-title'
: 'text-label-base'
}`}
{...props}
>
Expand Down
15 changes: 13 additions & 2 deletions client/src/Project/LeftSidebar/NavPanel/Conversations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ type Props = {
setExpanded: Dispatch<SetStateAction<string>>;
isExpanded: boolean;
index: string;
currentPath?: string;
};

const reactRoot = document.getElementById('root')!;

const ConversationsNav = ({ isExpanded, setExpanded, index }: Props) => {
const ConversationsNav = ({
isExpanded,
setExpanded,
index,
currentPath,
}: Props) => {
const { t } = useTranslation();
const { project } = useContext(ProjectContext.Current);
const { noPropagate, itemProps } = useNavPanel(
Expand Down Expand Up @@ -70,7 +76,12 @@ const ConversationsNav = ({ isExpanded, setExpanded, index }: Props) => {
{isExpanded && (
<div className={'overflow-hidden'}>
{project?.conversations.map((c) => (
<ConversationEntry key={c.id} {...c} index={`${index}-${c.id}`} />
<ConversationEntry
key={c.id}
{...c}
index={`${index}-${c.id}`}
isCurrentPath={currentPath === c.id}
/>
))}
</div>
)}
Expand Down
18 changes: 12 additions & 6 deletions client/src/Project/LeftSidebar/NavPanel/Doc/DocEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useArrowNavigationItemProps } from '../../../../hooks/useArrowNavigatio
type Props = DocPageType & {
index: string;
favicon?: string;
isCurrentPath?: boolean;
};

const DocEntry = ({
Expand All @@ -16,6 +17,7 @@ const DocEntry = ({
doc_title,
relative_url,
favicon,
isCurrentPath,
}: Props) => {
const { openNewTab } = useContext(TabsContext.Handlers);

Expand All @@ -29,17 +31,21 @@ const DocEntry = ({
});
}, [openNewTab, doc_id, doc_title, favicon, relative_url]);

const { isFocused, props } = useArrowNavigationItemProps<HTMLAnchorElement>(
index,
onClick,
);
const { isFocused, isLeftSidebarFocused, props } =
useArrowNavigationItemProps<HTMLAnchorElement>(index, onClick);

return (
<a
href="#"
className={`w-full text-left h-7 flex-shrink-0 flex items-center gap-3 pr-2 cursor-pointer
ellipsis body-mini group pl-10.5 ${
isFocused ? 'bg-bg-sub-hover text-label-title' : 'text-label-base'
ellipsis body-mini group pl-10.5 ${
isCurrentPath
? isLeftSidebarFocused
? 'bg-bg-shade-hover text-label-title'
: 'bg-bg-shade text-label-title'
: isFocused
? 'bg-bg-sub-hover text-label-title'
: 'text-label-base'
}`}
{...props}
>
Expand Down
3 changes: 3 additions & 0 deletions client/src/Project/LeftSidebar/NavPanel/Doc/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Props = {
favicon?: string;
title?: string;
url: string;
currentPath?: string;
};

const reactRoot = document.getElementById('root')!;
Expand All @@ -47,6 +48,7 @@ const DocNav = ({
docId,
title,
url,
currentPath,
}: Props) => {
const { t } = useTranslation();
const [pages, setPages] = useState<DocPageType[]>([]);
Expand Down Expand Up @@ -134,6 +136,7 @@ const DocNav = ({
{...p}
index={`${index}-${p.relative_url}`}
favicon={favicon}
isCurrentPath={currentPath === p.relative_url}
/>
))}
</div>
Expand Down
13 changes: 13 additions & 0 deletions client/src/Project/LeftSidebar/NavPanel/Studios/StudioEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type Props = CodeStudioType & {
indexingStatus: IndexingStatusType;
projectId: string;
previewingSnapshot: HistoryConversationTurn | null;
currentPath?: { path: string; repoRef: string };
currentDoc?: { docId: string; relativeUrl: string };
isViewingPrompts?: boolean;
};

const StudioEntry = ({
Expand All @@ -47,6 +50,9 @@ const StudioEntry = ({
indexingStatus,
projectId,
previewingSnapshot,
currentPath,
currentDoc,
isViewingPrompts,
}: Props) => {
const { t } = useTranslation();

Expand Down Expand Up @@ -98,11 +104,13 @@ const StudioEntry = ({
projectId={projectId}
shouldRefresh={token_counts}
index={`${index}-history`}
previewingSnapshot={previewingSnapshot?.id}
/>
<StudioSubItem
studioId={id}
index={`${index}-prompts`}
studioName={name}
isCurrentPath={isViewingPrompts}
>
<PromptIcon sizeClassName="w-3.5 h-3.5" />
<span className="flex-1 ellipsis">
Expand All @@ -124,6 +132,7 @@ const StudioEntry = ({
studioName={name}
tokens={token_counts.per_file[i]}
indexingData={indexingStatus[f.repo]}
currentPath={currentPath}
{...f}
/>
))}
Expand All @@ -143,6 +152,10 @@ const StudioEntry = ({
docTitle={d.doc_title || ''}
docFavicon={d.doc_icon || ''}
sections={d.ranges}
isCurrentPath={
currentDoc?.docId === d.doc_id &&
currentDoc?.relativeUrl === d.relative_url
}
>
{d.doc_icon ? (
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Props = StudioContextFile & {
studioName: string;
tokens?: number | null;
indexingData?: RepoIndexingStatusType;
currentPath?: { path: string; repoRef: string };
};

const StudioFile = ({
Expand All @@ -31,6 +32,7 @@ const StudioFile = ({
studioName,
tokens,
indexingData,
currentPath,
}: Props) => {
const { t } = useTranslation();

Expand All @@ -55,6 +57,9 @@ const StudioFile = ({
repoRef={repo}
branch={branch}
ranges={ranges}
isCurrentPath={
currentPath?.path === path && currentPath?.repoRef === repo
}
>
{isIndexing && indexingData ? (
<Tooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Props = {
shouldRefresh: any;
index: string;
studioName: string;
previewingSnapshot?: string;
};

const StudioHistory = ({
Expand All @@ -31,6 +32,7 @@ const StudioHistory = ({
shouldRefresh,
index,
studioName,
previewingSnapshot,
}: Props) => {
const { t } = useTranslation();
const { locale } = useContext(LocaleContext);
Expand Down Expand Up @@ -87,6 +89,7 @@ const StudioHistory = ({
index={`${index}-${s.id}`}
studioName={studioName}
snapshot={i === 0 ? null : s}
isCurrentPath={previewingSnapshot === s.id}
>
<DateTimeCalendarIcon sizeClassName="w-3.5 h-3.5" />
<span className="flex-1 ellipsis">
Expand Down
Loading

0 comments on commit c387128

Please sign in to comment.