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

feat(chat): add tooltips for files and folders (Issue #1227) #1431

Draft
wants to merge 16 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/chat-e2e/src/ui/selectors/sideBarSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const PromptBarSelectors = {
newPromptButton: '[data-qa="new-prompt"]',
prompts: '[data-qa="prompts"]',
prompt: '[data-qa="prompt"]',
promptName: '[data-qa="prompt-name"]',
deletePrompts: '[data-qa="delete-prompts"]',
leftResizeIcon: '[data-qa="left-resize-icon"]',
};
6 changes: 5 additions & 1 deletion apps/chat-e2e/src/ui/webElements/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ interface ConversationsChronologyType {

export class Conversations extends BaseConversation {
constructor(page: Page) {
super(page, ChatBarSelectors.conversations, ChatBarSelectors.conversation);
super(
page,
ChatBarSelectors.conversations,
ChatBarSelectors.conversationName,
);
}

public chronologyByTitle = (chronology: string) =>
Expand Down
6 changes: 5 additions & 1 deletion apps/chat-e2e/src/ui/webElements/folderConversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { Page } from '@playwright/test';

export class FolderConversations extends Folders {
constructor(page: Page) {
super(page, ChatBarSelectors.pinnedChats(), ChatBarSelectors.conversation);
super(
page,
ChatBarSelectors.pinnedChats(),
ChatBarSelectors.conversationName,
);
}

public async selectShareMenuOption() {
Expand Down
6 changes: 5 additions & 1 deletion apps/chat-e2e/src/ui/webElements/folderPrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { Page } from '@playwright/test';

export class FolderPrompts extends Folders {
constructor(page: Page) {
super(page, PromptBarSelectors.promptFolders, PromptBarSelectors.prompt);
super(
page,
PromptBarSelectors.promptFolders,
PromptBarSelectors.promptName,
);
}
}
26 changes: 15 additions & 11 deletions apps/chat/src/components/Chatbar/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,22 @@ export function ConversationView({
/>
)}
</ShareIcon>
<div
className="relative max-h-5 flex-1 truncate whitespace-pre break-all text-left"
data-qa="conversation-name"
>
<div className="relative max-h-5 flex-1 truncate whitespace-pre break-all text-left">
<Tooltip
tooltip={t(
getEntityNameError(isNameInvalid, isInvalidPath, isExternal),
)}
hideTooltip={!isNameOrPathInvalid}
triggerClassName="block max-h-5 flex-1 truncate whitespace-pre break-all text-left"
tooltip={
!isNameOrPathInvalid
? conversation.name
: t(getEntityNameError(isNameInvalid, isInvalidPath, isExternal))
}
triggerClassName="max-h-5 flex-1 truncate whitespace-pre text-left"
contentClassName="sm:max-w-[400px] max-w-[250px] break-all"
>
{conversation.name}
<span
className="block max-w-full truncate whitespace-pre"
data-qa="conversation-name"
>
{conversation.name}
</span>
</Tooltip>
</div>
</>
Expand Down Expand Up @@ -575,7 +579,7 @@ export const ConversationComponent = ({ item: conversation, level }: Props) => {
) : (
<button
className={classNames(
'group flex size-full cursor-pointer items-center gap-2 transition-colors duration-200 disabled:cursor-not-allowed [&:not(:disabled)]:group-hover:pr-6',
'group flex max-w-full cursor-pointer items-center gap-2 transition-colors duration-200 disabled:cursor-not-allowed [&:not(:disabled)]:group-hover:pr-6',
isSelected && 'pr-0',
)}
onClick={() => {
Expand Down
24 changes: 15 additions & 9 deletions apps/chat/src/components/Files/FileItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,22 @@ export const FileItem = ({
</div>
)}
</div>
<span
className={classNames(
'block max-w-full truncate whitespace-pre',
item.status === UploadStatus.FAILED && 'text-error',
isSelected && 'text-accent-primary',
)}
data-qa="attached-file-name"
<Tooltip
tooltip={item.name}
triggerClassName="block max-h-5 flex-1 truncate whitespace-pre text-left"
contentClassName="sm:max-w-[400px] max-w-[250px] break-all"
>
{item.name}
</span>
<span
className={classNames(
'block max-w-full truncate whitespace-pre',
item.status === UploadStatus.FAILED && 'text-error',
isSelected && 'text-accent-primary',
)}
data-qa="attached-file-name"
>
{item.name}
</span>
</Tooltip>
</div>

<div className="flex items-center gap-2">
Expand Down
24 changes: 16 additions & 8 deletions apps/chat/src/components/Folder/Folder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ const Folder = <T extends ConversationInfo | PromptInfo | DialFile>({
>
<div
className={classNames(
'group/folder-item group relative flex h-[30px] items-center rounded border-l-2 hover:bg-accent-primary-alpha',
'group/button group/folder-item group relative flex h-[30px] items-center rounded border-l-2 hover:bg-accent-primary-alpha',
!withBorderHighlight && 'border-transparent',
isHighlighted ? 'bg-accent-primary-alpha' : 'border-transparent',
isHighlighted && withBorderHighlight && 'border-accent-primary',
Expand Down Expand Up @@ -787,7 +787,7 @@ const Folder = <T extends ConversationInfo | PromptInfo | DialFile>({
</div>
) : (
<div
className="group/button group/folder-item flex size-full cursor-pointer items-center gap-1 py-2 pr-3"
className="group/folder-item flex max-w-full cursor-pointer items-center gap-1 py-2 pr-3"
style={{
paddingLeft: `${level * 24}px`,
}}
Expand Down Expand Up @@ -868,18 +868,26 @@ const Folder = <T extends ConversationInfo | PromptInfo | DialFile>({
)}
<div
className={classNames(
'relative max-h-5 flex-1 truncate break-all text-left group-hover/button:pr-5',
'relative max-h-5 flex-1 truncate text-left group-hover/button:pr-5',
isNameOrPathInvalid && 'text-secondary',
)}
data-qa="folder-name"
>
<Tooltip
tooltip={t(
getEntityNameError(isNameInvalid, isInvalidPath, isExternal),
)}
hideTooltip={!isNameOrPathInvalid}
tooltip={
!isNameOrPathInvalid
? currentFolder.name
: t(
getEntityNameError(
isNameInvalid,
isInvalidPath,
isExternal,
),
)
}
contentClassName="sm:max-w-[400px] max-w-[250px] break-all"
triggerClassName={classNames(
'max-h-5 flex-1 truncate whitespace-pre break-all text-left',
'block max-h-5 flex-1 truncate whitespace-pre break-all text-left',
highlightTemporaryFolders &&
(currentFolder.temporary
? 'text-primary'
Expand Down
27 changes: 20 additions & 7 deletions apps/chat/src/components/Promptbar/components/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export const PromptComponent = ({ item: prompt, level }: Props) => {
data-qa="prompt"
>
<div
className={classNames('flex size-full items-center gap-2', {
className={classNames('flex max-w-full items-center gap-2', {
'pr-6 xl:pr-0': !isDeleting && !isRenaming && isSelected,
})}
draggable={!isExternal && !isNameOrPathInvalid}
Expand All @@ -323,16 +323,29 @@ export const PromptComponent = ({ item: prompt, level }: Props) => {

<div className="relative max-h-5 flex-1 truncate whitespace-pre break-all text-left">
<Tooltip
tooltip={t(
getEntityNameError(isNameInvalid, isInvalidPath, isExternal),
)}
hideTooltip={!isNameOrPathInvalid}
tooltip={
!isNameOrPathInvalid
? prompt.name
: t(
getEntityNameError(
isNameInvalid,
isInvalidPath,
isExternal,
),
)
}
triggerClassName={classNames(
'block max-h-5 flex-1 truncate whitespace-pre break-all text-left',
'max-h-5 flex-1 truncate whitespace-pre text-left',
isNameOrPathInvalid && 'text-secondary',
)}
contentClassName="sm:max-w-[400px] max-w-[250px] break-all"
>
{prompt.name}
<span
className="block max-w-full truncate whitespace-pre"
data-qa="prompt-name"
>
{prompt.name}
</span>
</Tooltip>
</div>
</div>
Expand Down
Loading