Skip to content
Open
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
6 changes: 1 addition & 5 deletions site/src/pages/TaskPage/TaskPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const TaskPage = () => {
return (
<>
<Helmet>
<title>{pageTitle(ellipsizeText(task.prompt, 64))}</title>
<title>{pageTitle(task.workspace.name)}</title>
</Helmet>

<div className="flex flex-col h-full">
Expand Down Expand Up @@ -265,7 +265,3 @@ export const data = {
} satisfies Task;
},
};

const ellipsizeText = (text: string, maxLength = 80): string => {
return text.length <= maxLength ? text : `${text.slice(0, maxLength - 3)}...`;
};
77 changes: 67 additions & 10 deletions site/src/pages/TaskPage/TaskTopbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import {
TooltipProvider,
TooltipTrigger,
} from "components/Tooltip/Tooltip";
import { ArrowLeftIcon } from "lucide-react";
import { useClipboard } from "hooks";
import {
ArrowLeftIcon,
CheckIcon,
CopyIcon,
LaptopMinimalIcon,
TerminalIcon,
} from "lucide-react";
import type { Task } from "modules/tasks/tasks";
import type { FC } from "react";
import { Link as RouterLink } from "react-router";
Expand All @@ -15,7 +22,7 @@ type TaskTopbarProps = { task: Task };

export const TaskTopbar: FC<TaskTopbarProps> = ({ task }) => {
return (
<header className="flex items-center px-3 h-14 border-solid border-border border-0 border-b">
<header className="flex items-center px-3 py-4 border-solid border-border border-0 border-b">
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
Expand All @@ -30,21 +37,71 @@ export const TaskTopbar: FC<TaskTopbarProps> = ({ task }) => {
</Tooltip>
</TooltipProvider>

<h1 className="m-0 text-base font-medium truncate">{task.prompt}</h1>
<h1 className="m-0 ml-2 text-base font-medium truncate">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that technically it won't be a huge deal, but could we swap the ml-2 for pl-2? That would reduce the risk of CSS styling side effects

{task.workspace.name}
</h1>

{task.workspace.latest_app_status?.uri && (
<div className="flex items-center gap-2 flex-wrap ml-4">
<TaskStatusLink uri={task.workspace.latest_app_status.uri} />
</div>
)}

<Button asChild size="sm" variant="outline" className="ml-auto">
<RouterLink
to={`/@${task.workspace.owner_name}/${task.workspace.name}`}
>
View workspace
</RouterLink>
</Button>
<div className="ml-auto gap-2 flex items-center">
<TooltipProvider delayDuration={0}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the duration to be set so aggressively low? Radix's default value is 700ms

<Tooltip>
<TooltipTrigger asChild>
<Button variant="outline" size="sm">
<TerminalIcon />
Prompt
</Button>
</TooltipTrigger>
<TooltipContent className="max-w-xs bg-surface-secondary p-4">
<p className="m-0 mb-2 select-all text-sm font-normal text-content-primary leading-snug">
{task.prompt}
</p>
<CopyPromptButton prompt={task.prompt} />
</TooltipContent>
</Tooltip>
</TooltipProvider>

<Button asChild variant="outline" size="sm">
<RouterLink
to={`/@${task.workspace.owner_name}/${task.workspace.name}`}
>
<LaptopMinimalIcon />
Workspace
</RouterLink>
</Button>
</div>
</header>
);
};

type CopyPromptButtonProps = { prompt: string };

const CopyPromptButton: FC<CopyPromptButtonProps> = ({ prompt }) => {
const { copyToClipboard, showCopiedSuccess } = useClipboard({
textToCopy: prompt,
});

return (
<Button
disabled={showCopiedSuccess}
onClick={copyToClipboard}
size="sm"
variant="subtle"
className="p-0 min-w-0"
>
{showCopiedSuccess ? (
<>
<CheckIcon /> Copied!
</>
) : (
<>
<CopyIcon /> Copy
</>
)}
</Button>
);
Comment on lines +88 to +106
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In isolation, I think this is perfectly fine, but do we want to centralize the implementation for this, so we can make sure the UI stays more consistent?

I'm seeing a few other buttons in the codebase that are wired up very similarly (making a call to useClipboard, using the CheckIcon and CopyIcon components), and I'm just worried about them drifting over time

};
Loading