-
Notifications
You must be signed in to change notification settings - Fork 92
chore(DATAGO-120962): replacing custom components with standard ones in project (and prompt) UI #740
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
chore(DATAGO-120962): replacing custom components with standard ones in project (and prompt) UI #740
Changes from all commits
c12cffb
e2157ff
90cd7e3
5bdad03
08c6fdc
0dc5443
333f052
48a0e1e
971373c
2e86e31
0cfc180
f8c8f07
3a6ac79
a4abc10
dfec097
a8ad161
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| import { useState, useCallback, useEffect } from "react"; | ||
| import { Search, X } from "lucide-react"; | ||
| import { Input } from "@/lib/components/ui/input"; | ||
| import { Button } from "@/lib/components/ui/button"; | ||
| import { Badge } from "@/lib/components/ui/badge"; | ||
| import { useDebounce } from "@/lib/hooks/useDebounce"; | ||
| import type { Session } from "@/lib/types"; | ||
|
|
||
| import { api } from "@/lib/api"; | ||
| import { ProjectBadge } from "@/lib/components/chat"; | ||
| import { Button, Input } from "@/lib/components/ui"; | ||
| import { useDebounce } from "@/lib/hooks"; | ||
| import type { Session } from "@/lib/types"; | ||
|
|
||
| interface SessionSearchProps { | ||
| onSessionSelect: (sessionId: string) => void; | ||
|
|
@@ -98,11 +98,7 @@ export const SessionSearch = ({ onSessionSelect, projectId }: SessionSearchProps | |
| <button key={session.id} onClick={() => handleSessionClick(session.id)} className="hover:bg-accent hover:text-accent-foreground w-full rounded-sm px-3 py-2 text-left text-sm"> | ||
| <div className="mb-1 flex items-center justify-between gap-2"> | ||
| <div className="flex-1 truncate font-medium">{session.name || "Untitled Session"}</div> | ||
| {session.projectName && ( | ||
| <Badge variant="outline" className="bg-primary/10 border-primary/30 text-primary flex-shrink-0 px-2 py-0.5 text-xs font-semibold shadow-sm"> | ||
| {session.projectName} | ||
| </Badge> | ||
| )} | ||
| {session.projectName && <ProjectBadge text={session.projectName} />} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use extracted badge. |
||
| </div> | ||
| <div className="text-muted-foreground text-xs">{new Date(session.updatedTime).toLocaleDateString()}</div> | ||
| </button> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| import React, { useState, useEffect } from "react"; | ||
| import { Download, ChevronDown, Trash, Info, ChevronUp, CircleAlert } from "lucide-react"; | ||
| import { Download, ChevronDown, Trash, Info, ChevronUp, CircleAlert, Pencil } from "lucide-react"; | ||
|
|
||
| import { Button, Spinner, Badge } from "@/lib/components/ui"; | ||
| import { FileIcon } from "../file/FileIcon"; | ||
| import { Button, Spinner } from "@/lib/components/ui"; | ||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| import { FileIcon, ProjectBadge } from "../file"; | ||
|
|
||
| const ErrorState: React.FC<{ message: string }> = ({ message }) => ( | ||
| <div className="w-full rounded-lg border border-[var(--color-error-w100)] bg-[var(--color-error-wMain-50)] p-3"> | ||
| <div className="text-sm text-[var(--color-error-wMain)]">Error: {message}</div> | ||
|
|
@@ -26,6 +27,7 @@ export interface ArtifactBarProps { | |
| onDelete?: () => void; | ||
| onInfo?: () => void; | ||
| onExpand?: () => void; | ||
| onEdit?: () => void; | ||
| }; | ||
| // For creation progress | ||
| bytesTransferred?: number; | ||
|
|
@@ -211,11 +213,7 @@ export const ArtifactBar: React.FC<ArtifactBarProps> = ({ | |
| {hasDescription ? displayDescription : filename.length > 50 ? `${filename.substring(0, 47)}...` : filename} | ||
| </div> | ||
| {/* Project badge */} | ||
| {source === "project" && ( | ||
| <Badge variant="outline" className="bg-primary/10 border-primary/30 text-primary px-2 py-0.5 text-xs font-semibold shadow-sm"> | ||
| Project | ||
| </Badge> | ||
| )} | ||
| {source === "project" && <ProjectBadge />} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use extracted badge |
||
| </div> | ||
|
|
||
| {/* Secondary line: Filename (if description shown) or status */} | ||
|
|
@@ -298,6 +296,24 @@ export const ArtifactBar: React.FC<ArtifactBarProps> = ({ | |
| </Button> | ||
| )} | ||
|
|
||
| {status === "completed" && actions?.onEdit && !isDeleted && ( | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| onClick={e => { | ||
| e.stopPropagation(); | ||
| try { | ||
| actions.onEdit?.(); | ||
| } catch (error) { | ||
| console.error("Edit failed:", error); | ||
| } | ||
| }} | ||
| tooltip="Edit Description" | ||
| > | ||
| <Pencil className="h-4 w-4" /> | ||
| </Button> | ||
| )} | ||
|
|
||
| {status === "completed" && actions?.onDelete && !isDeleted && ( | ||
| <Button | ||
| variant="ghost" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,14 +5,14 @@ import { useProjectContext } from "@/lib/providers"; | |
| import type { FileAttachment } from "@/lib/types"; | ||
| import { api } from "@/lib/api"; | ||
| import { downloadFile, parseArtifactUri } from "@/lib/utils/download"; | ||
| import { formatBytes, formatRelativeTime } from "@/lib/utils/format"; | ||
| import { Spinner } from "@/lib/components/ui/spinner"; | ||
|
|
||
| import { MessageBanner } from "../../common"; | ||
| import { ContentRenderer } from "../preview/ContentRenderer"; | ||
| import { getFileContent, getRenderType } from "../preview/previewUtils"; | ||
| import { ArtifactBar } from "../artifact/ArtifactBar"; | ||
| import { ArtifactTransitionOverlay } from "../artifact/ArtifactTransitionOverlay"; | ||
| import { Spinner } from "../../ui"; | ||
| import { FileDetails } from "./FileDetails"; | ||
|
|
||
| type ArtifactMessageProps = ( | ||
| | { | ||
|
|
@@ -417,32 +417,7 @@ export const ArtifactMessage: React.FC<ArtifactMessageProps> = props => { | |
| const infoContent = useMemo(() => { | ||
| if (!isInfoExpanded || !artifact) return null; | ||
|
|
||
| return ( | ||
| <div className="space-y-2 text-sm"> | ||
| {artifact.description && ( | ||
| <div> | ||
| <span className="text-secondary-foreground">Description:</span> | ||
| <div className="mt-1">{artifact.description}</div> | ||
| </div> | ||
| )} | ||
| <div className="grid grid-cols-2 gap-2"> | ||
| <div> | ||
| <span className="text-secondary-foreground">Size:</span> | ||
| <div>{formatBytes(artifact.size)}</div> | ||
| </div> | ||
| <div> | ||
| <span className="text-secondary-foreground">Modified:</span> | ||
| <div>{formatRelativeTime(artifact.last_modified)}</div> | ||
| </div> | ||
| </div> | ||
| {artifact.mime_type && ( | ||
| <div> | ||
| <span className="text-secondary-foreground">Type:</span> | ||
| <div>{artifact.mime_type}</div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| return <FileDetails description={artifact.description ?? undefined} size={artifact.size} lastModified={artifact.last_modified} mimeType={artifact.mime_type} />; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use extracted file details. |
||
| }, [isInfoExpanded, artifact]); | ||
|
|
||
| // Determine what content to show in expanded area - can show both info and content | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import React from "react"; | ||
|
|
||
| import { formatBytes, formatRelativeTime } from "@/lib/utils/format"; | ||
|
|
||
| interface FileDetailsProps { | ||
| description?: string; | ||
| size: number; | ||
| lastModified: string; | ||
| mimeType?: string; | ||
| } | ||
|
|
||
| export const FileDetails: React.FC<FileDetailsProps> = ({ description, size, lastModified, mimeType }) => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return ( | ||
| <div className="space-y-2 text-sm"> | ||
| {description && ( | ||
| <div> | ||
| <span className="text-secondary-foreground">Description:</span> | ||
| <div className="mt-1">{description}</div> | ||
| </div> | ||
| )} | ||
| <div className="grid grid-cols-2 gap-2"> | ||
| <div> | ||
| <span className="text-secondary-foreground">Size:</span> | ||
| <div>{formatBytes(size)}</div> | ||
| </div> | ||
| <div> | ||
| <span className="text-secondary-foreground">Modified:</span> | ||
| <div>{formatRelativeTime(lastModified)}</div> | ||
| </div> | ||
| </div> | ||
| {mimeType && ( | ||
| <div> | ||
| <span className="text-secondary-foreground">Type:</span> | ||
| <div>{mimeType}</div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { File } from "lucide-react"; | ||
|
|
||
| export const FileLabel = ({ fileName, fileSize }: { fileName: string; fileSize: number }) => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return ( | ||
| <div className="flex items-center gap-3"> | ||
| <File className="text-muted-foreground size-5 shrink-0" /> | ||
| <div className="overflow-hidden"> | ||
| <div className="truncate" title={fileName}> | ||
| {fileName} | ||
| </div> | ||
| <div className="text-muted-foreground text-xs">{(fileSize / 1024).toFixed(1)} KB</div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { Badge, Tooltip, TooltipContent, TooltipTrigger } from "@/lib"; | ||
|
|
||
| export const ProjectBadge = ({ text = "Project", className = "" }: { text?: string; className?: string }) => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return ( | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> | ||
| <Badge variant="default" className={`max-w-[120px] ${className}`}> | ||
| <span className="block truncate font-semibold">{text}</span> | ||
| </Badge> | ||
| </TooltipTrigger> | ||
| <TooltipContent>{text}</TooltipContent> | ||
| </Tooltip> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| export * from "./ArtifactMessage"; | ||
| export * from "./FileBadge"; | ||
| export * from "./FileDetails"; | ||
| export * from "./FileIcon"; | ||
| export * from "./FileMessage"; | ||
| export * from "./fileUtils"; | ||
| export * from "./ProjectBadge"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| export { AudioRecorder } from "./AudioRecorder"; | ||
| export { ChatInputArea } from "./ChatInputArea"; | ||
| export { ChatMessage } from "./ChatMessage"; | ||
| export { ChatSessionDeleteDialog } from "./ChatSessionDeleteDialog"; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add missing exports. |
||
| export { ChatSessionDialog } from "./ChatSessionDialog"; | ||
| export { ChatSessions } from "./ChatSessions"; | ||
| export { ChatSidePanel } from "./ChatSidePanel"; | ||
| export { LoadingMessageRow } from "./LoadingMessageRow"; | ||
|
|
@@ -9,4 +11,5 @@ export { MoveSessionDialog } from "./MoveSessionDialog"; | |
| export { VariableDialog } from "./VariableDialog"; | ||
| export { SessionSearch } from "./SessionSearch"; | ||
| export { MessageHoverButtons } from "./MessageHoverButtons"; | ||
| export * from "./file"; | ||
| export * from "./selection"; | ||




There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This badge was used in 4 places so extracted it to a component.