Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a91f1b3
feat: show workspace badge in agent chat top bar
DanielleMaywood Apr 2, 2026
f350127
fix: add monitor icon and clarify tooltip for workspace badge
DanielleMaywood Apr 2, 2026
bb8031e
fix: compact workspace badge on mobile, group resource badges
DanielleMaywood Apr 2, 2026
d1f8998
refactor: split ChatTopBar into directory with extracted badge compon…
DanielleMaywood Apr 2, 2026
1e2f33b
refactor: clean up PullRequestBadge
DanielleMaywood Apr 2, 2026
7500e1a
refactor: destructure diffStatusData in function head
DanielleMaywood Apr 2, 2026
a9cc3d2
fix: use en dash in workspace badge tooltip
DanielleMaywood Apr 2, 2026
8a422d6
refactor: move workspace indicator from top bar to input toolbar pills
DanielleMaywood Apr 2, 2026
5a72b20
fix: remove stray whitespace in AgentChatPageView
DanielleMaywood Apr 2, 2026
e7e0c49
revert: restore ChatTopBar to original state
DanielleMaywood Apr 2, 2026
af57834
fix: remove comment and stray whitespace
DanielleMaywood Apr 2, 2026
8889f98
fix: use muted status dot for workspace pill
DanielleMaywood Apr 2, 2026
f7cf493
fix: use distinct icon shapes for workspace status
DanielleMaywood Apr 2, 2026
e78c578
fix: use hollow circle for stopped state instead of square
DanielleMaywood Apr 2, 2026
823653c
fix: use plain dot for running/stopped, drop CircleIcon
DanielleMaywood Apr 2, 2026
0ef76dd
fix: use filled muted grey dot for stopped state
DanielleMaywood Apr 2, 2026
7b9c4bf
fix: no dot for stopped workspace, dot means on
DanielleMaywood Apr 2, 2026
b274e9d
fix: use moon icon for stopped workspace state
DanielleMaywood Apr 2, 2026
7f3a142
fix: vary MonitorIcon by workspace state
DanielleMaywood Apr 2, 2026
d5972a6
test: add storybook stories for all 4 attached workspace states
DanielleMaywood Apr 2, 2026
b6859d1
feat: add tooltip to attached workspace pill
DanielleMaywood Apr 2, 2026
b16796d
fix: include 'Workspace' prefix in tooltip text
DanielleMaywood Apr 2, 2026
7275213
fix: self-review cleanup
DanielleMaywood Apr 2, 2026
c840310
fix: address deep review findings
DanielleMaywood Apr 2, 2026
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
2 changes: 2 additions & 0 deletions site/src/pages/AgentsPage/AgentChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ const AgentChatPage: FC = () => {
if (
prev &&
prev.latest_build.status === next.latest_build.status &&
prev.health.healthy === next.health.healthy &&
prev.name === next.name &&
prev.owner_name === next.owner_name &&
prevAgent?.id === nextAgent?.id &&
Expand Down Expand Up @@ -1108,6 +1109,7 @@ const AgentChatPage: FC = () => {
persistedError={persistedError}
isArchived={isArchived}
hasWorkspace={Boolean(workspaceId)}
workspace={workspace}
store={store}
editing={editing}
pendingEditMessageId={pendingEditMessageId}
Expand Down
46 changes: 45 additions & 1 deletion site/src/pages/AgentsPage/AgentChatPageView.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { ArchiveIcon } from "lucide-react";
import {
ArchiveIcon,
MonitorDotIcon,
MonitorIcon,
MonitorPauseIcon,
MonitorXIcon,
} from "lucide-react";

import { type FC, type RefObject, useRef, useState } from "react";
import type { UrlTransform } from "streamdown";
import type * as TypesGen from "#/api/typesGenerated";
import type { ChatDiffStatus, ChatMessagePart } from "#/api/typesGenerated";

import { cn } from "#/utils/cn";
import { pageTitle } from "#/utils/page";
import {
type DisplayWorkspaceStatusType,
getDisplayWorkspaceStatus,
} from "#/utils/workspace";

import {
AgentChatInput,
type ChatMessageInputRef,
Expand Down Expand Up @@ -233,6 +245,37 @@ export const AgentChatPageView: FC<AgentChatPageViewProps> = ({

// Compute local diff stats from git watcher unified diffs.

const workspaceRoute = workspace
? `/@${workspace.owner_name}/${workspace.name}`
: undefined;

const attachedWorkspace = (() => {
if (!workspace || !workspaceRoute) return undefined;
const { type, text } = getDisplayWorkspaceStatus(
workspace.latest_build.status,
workspace.latest_build.job,
);
const effectiveType = workspace.health.healthy ? type : "warning";
const statusLabel = workspace.health.healthy
? `Workspace ${text.toLowerCase()}`
: `Workspace ${text.toLowerCase()} (unhealthy)`;
const iconCls = "size-3";
const statusIconMap: Record<DisplayWorkspaceStatusType, React.ReactNode> = {
success: <MonitorIcon className={iconCls} />,
active: <MonitorDotIcon className={iconCls} />,
inactive: <MonitorPauseIcon className={iconCls} />,
error: <MonitorXIcon className={iconCls} />,
danger: <MonitorXIcon className={iconCls} />,
warning: <MonitorXIcon className={iconCls} />,
};
return {
name: workspace.name,
route: workspaceRoute,
statusIcon: statusIconMap[effectiveType],
statusLabel,
};
})();

const titleElement = (
<title>
{chatTitle ? pageTitle(chatTitle, "Agents") : pageTitle("Agents")}
Expand Down Expand Up @@ -362,6 +405,7 @@ export const AgentChatPageView: FC<AgentChatPageViewProps> = ({
onMCPSelectionChange={onMCPSelectionChange}
onMCPAuthComplete={onMCPAuthComplete}
lastInjectedContext={lastInjectedContext}
attachedWorkspace={attachedWorkspace}
/>
</div>
</div>
Expand Down
52 changes: 52 additions & 0 deletions site/src/pages/AgentsPage/components/AgentChatInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import {
MonitorDotIcon,
MonitorIcon,
MonitorPauseIcon,
MonitorXIcon,
} from "lucide-react";
import { useEffect, useRef } from "react";
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
import type * as TypesGen from "#/api/typesGenerated";
Expand Down Expand Up @@ -728,3 +734,49 @@ export const ContextNearLimit: Story = {
},
},
};

const iconCls = "size-3";

export const AttachedWorkspaceRunning: Story = {
args: {
attachedWorkspace: {
name: "my-workspace",
route: "/@admin/my-workspace",
statusIcon: <MonitorIcon className={iconCls} />,
statusLabel: "Workspace running",
},
},
};

export const AttachedWorkspaceStopped: Story = {
args: {
attachedWorkspace: {
name: "my-workspace",
route: "/@admin/my-workspace",
statusIcon: <MonitorPauseIcon className={iconCls} />,
statusLabel: "Workspace stopped",
},
},
};

export const AttachedWorkspaceStarting: Story = {
args: {
attachedWorkspace: {
name: "my-workspace",
route: "/@admin/my-workspace",
statusIcon: <MonitorDotIcon className={iconCls} />,
statusLabel: "Workspace starting",
},
},
};

export const AttachedWorkspaceError: Story = {
args: {
attachedWorkspace: {
name: "my-workspace",
route: "/@admin/my-workspace",
statusIcon: <MonitorXIcon className={iconCls} />,
statusLabel: "Workspace failed",
},
},
};
49 changes: 45 additions & 4 deletions site/src/pages/AgentsPage/components/AgentChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
useRef,
useState,
} from "react";
import { Link } from "react-router";
import type * as TypesGen from "#/api/typesGenerated";
import type { ChatMessagePart, ChatQueuedMessage } from "#/api/typesGenerated";
import { Alert, AlertDescription } from "#/components/Alert/Alert";
Expand All @@ -42,6 +43,11 @@ import { Separator } from "#/components/Separator/Separator";
import { Skeleton } from "#/components/Skeleton/Skeleton";
import { Spinner } from "#/components/Spinner/Spinner";
import { Switch } from "#/components/Switch/Switch";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "#/components/Tooltip/Tooltip";
import { cn } from "#/utils/cn";
import { countInvisibleCharacters } from "#/utils/invisibleUnicode";
import { isMobileViewport } from "#/utils/mobile";
Expand Down Expand Up @@ -141,9 +147,18 @@ interface AgentChatInputProps {
selectedMCPServerIds?: readonly string[];
onMCPSelectionChange?: (ids: string[]) => void;
onMCPAuthComplete?: (serverId: string) => void;
attachedWorkspace?: AttachedWorkspaceInfo;
}

export interface AttachedWorkspaceInfo {
name: string;
route: string;
statusIcon: React.ReactNode;
statusLabel: string;
}
type ToolBadgeData =
| { kind: "workspace"; name: string }
| ({ kind: "attached-workspace" } & AttachedWorkspaceInfo)
| { kind: "mcp"; server: TypesGen.MCPServerConfig };

const ToolBadge: FC<{
Expand All @@ -157,6 +172,28 @@ const ToolBadge: FC<{
className,
);

if (badge.kind === "attached-workspace") {
return (
<Tooltip>
<TooltipTrigger asChild>
<Link
to={badge.route}
target="_blank"
rel="noreferrer"
className={cn(
badgeCls,
"no-underline transition-colors hover:bg-surface-tertiary hover:text-content-primary",
)}
>
{badge.statusIcon}
{badge.name}
</Link>
</TooltipTrigger>
<TooltipContent>{badge.statusLabel}</TooltipContent>
</Tooltip>
);
}

if (badge.kind === "workspace") {
return (
<span className={badgeCls}>
Expand Down Expand Up @@ -247,6 +284,7 @@ export const AgentChatInput: FC<AgentChatInputProps> = ({
selectedMCPServerIds,
onMCPSelectionChange,
onMCPAuthComplete,
attachedWorkspace,
}) => {
const internalRef = useRef<ChatMessageInputRef>(null);
const [previewImage, setPreviewImage] = useState<string | null>(null);
Expand Down Expand Up @@ -355,6 +393,9 @@ export const AgentChatInput: FC<AgentChatInputProps> = ({
// Ordered list of active tool badge data so we can determine
// which ones ended up in the overflow popover.
const allBadges: ToolBadgeData[] = [];
if (attachedWorkspace) {
allBadges.push({ kind: "attached-workspace", ...attachedWorkspace });
}
if (selectedWorkspace && onWorkspaceChange) {
allBadges.push({ kind: "workspace", name: selectedWorkspace.name });
}
Expand Down Expand Up @@ -883,7 +924,7 @@ export const AgentChatInput: FC<AgentChatInputProps> = ({
const isOverflow = overflowCount > 0 && i >= visibleCount;
return (
<ToolBadge
key={badge.kind === "workspace" ? "ws" : badge.server.id}
key={badge.kind === "mcp" ? badge.server.id : badge.kind}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the diff resolution in git is lovely sometimes

badge={badge}
onRemoveWorkspace={handleRemoveWorkspace}
onRemoveMcp={handleRemoveMcp}
Expand Down Expand Up @@ -920,9 +961,9 @@ export const AgentChatInput: FC<AgentChatInputProps> = ({
{overflowBadges.map((badge) => (
<ToolBadge
key={
badge.kind === "workspace"
? "ws-overflow"
: badge.server.id
badge.kind === "mcp"
? badge.server.id
: `${badge.kind}-overflow`
}
badge={badge}
onRemoveWorkspace={handleRemoveWorkspace}
Expand Down
4 changes: 4 additions & 0 deletions site/src/pages/AgentsPage/components/ChatPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useFileAttachments } from "../hooks/useFileAttachments";
import type { ChatDetailError } from "../utils/usageLimitMessage";
import {
AgentChatInput,
type AttachedWorkspaceInfo,
type ChatMessageInputRef,
type UploadState,
} from "./AgentChatInput";
Expand Down Expand Up @@ -162,6 +163,7 @@ interface ChatPageInputProps {
onMCPSelectionChange?: (ids: string[]) => void;
onMCPAuthComplete?: (serverId: string) => void;
lastInjectedContext?: readonly TypesGen.ChatMessagePart[];
attachedWorkspace?: AttachedWorkspaceInfo;
}

export const ChatPageInput: FC<ChatPageInputProps> = ({
Expand Down Expand Up @@ -197,6 +199,7 @@ export const ChatPageInput: FC<ChatPageInputProps> = ({
onMCPSelectionChange,
onMCPAuthComplete,
lastInjectedContext,
attachedWorkspace,
}) => {
const messagesByID = useChatSelector(store, selectMessagesByID);
const orderedMessageIDs = useChatSelector(store, selectOrderedMessageIDs);
Expand Down Expand Up @@ -357,6 +360,7 @@ export const ChatPageInput: FC<ChatPageInputProps> = ({
selectedMCPServerIds={selectedMCPServerIds}
onMCPSelectionChange={onMCPSelectionChange}
onMCPAuthComplete={onMCPAuthComplete}
attachedWorkspace={attachedWorkspace}
/>
);
};
Loading