Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
51d076f
feat(site): expose workspace apps in chat workspace pill
DanielleMaywood Apr 13, 2026
057ac8d
test(site): add storybook stories for WorkspacePill
DanielleMaywood Apr 13, 2026
dd3f0be
refactor(site): drop appendChatIdToHref, match AgentRow pattern
DanielleMaywood Apr 13, 2026
da60ae8
chore(site): remove stale-prone comments from WorkspacePill
DanielleMaywood Apr 13, 2026
fd165c9
refactor(site): WorkspacePill owns its status display, eliminate Reac…
DanielleMaywood Apr 13, 2026
f366b30
fix(site): remove stray whitespace expression in ChatTopBar
DanielleMaywood Apr 13, 2026
ba6fda9
fix(site): update AgentChatPage story for meatball menu changes
DanielleMaywood Apr 13, 2026
3441075
refactor(site): use Popover styling from #24308 for WorkspacePill
DanielleMaywood Apr 13, 2026
9689199
refactor(site): move Copy SSH and View Workspace from meatball to pill
DanielleMaywood Apr 13, 2026
6610110
fix(site): flip chevron direction for top popover, suppress tooltip w…
DanielleMaywood Apr 13, 2026
20de227
fix(site): show all workspace apps in pill, not just external ones
DanielleMaywood Apr 13, 2026
9c4be48
fix(site): address self-review findings (separator, overflow, story)
DanielleMaywood Apr 13, 2026
29ae400
fix(site): address review feedback (folder, status indicator, null gu…
DanielleMaywood Apr 13, 2026
0dcd9bd
fix(site): address panel review feedback (dropdown, token guard, stor…
DanielleMaywood Apr 13, 2026
5d6aa30
fix(site): address self-review findings (mutation unmount, disabled s…
DanielleMaywood Apr 13, 2026
559e05b
fix(site): address self-review round 2 (tooltip, alt, folder fallback…
DanielleMaywood Apr 13, 2026
1b186da
refactor(site): inline cls variables and remove workspaceStatusDisplay
DanielleMaywood Apr 13, 2026
19ba116
refactor(site): extract StatusIcon component to deduplicate status ic…
DanielleMaywood Apr 13, 2026
a95bf52
fix(site): address R3 review feedback (shared status, mutation lift, …
DanielleMaywood Apr 14, 2026
831572d
fix(site/src/pages/AgentsPage): add external app disabled assertions,…
DanielleMaywood Apr 14, 2026
6373d75
fix(site/src/pages/AgentsPage): fix WithWorkspace story props, add en…
DanielleMaywood Apr 14, 2026
ef908e8
fix(site/src/pages/AgentsPage): useClipboard, restore Cursor, fix fak…
DanielleMaywood Apr 14, 2026
95d78c5
fix(site/src/pages/AgentsPage): remove builtin Cursor, fix clipboard/…
DanielleMaywood Apr 14, 2026
cff4e04
fix(site/src/pages/AgentsPage): assert href absence on disabled exter…
DanielleMaywood Apr 14, 2026
aedb81c
fix(site/src/pages/AgentsPage): group launch items above separator
DanielleMaywood Apr 14, 2026
ed94b48
fix(site/src/pages/AgentsPage): use consistent app names without Open…
DanielleMaywood Apr 14, 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
10 changes: 6 additions & 4 deletions site/src/pages/AgentsPage/AgentChatPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,13 @@ export const CompletedWithDiffPanel: Story = {
// Verify menu items are rendered.
const body = within(document.body);
await waitFor(() => {
expect(body.getByText("Open in Cursor")).toBeInTheDocument();
expect(body.getByText("Archive Agent")).toBeInTheDocument();
});
expect(body.getByText("Open in VS Code")).toBeInTheDocument();
expect(body.getByText("View Workspace")).toBeInTheDocument();
expect(body.getByText("Archive Agent")).toBeInTheDocument();
// Workspace items moved to the workspace pill popover.
expect(body.queryByText("Open in Cursor")).not.toBeInTheDocument();
expect(body.queryByText("Open in VS Code")).not.toBeInTheDocument();
expect(body.queryByText("View Workspace")).not.toBeInTheDocument();
expect(body.queryByText("Copy SSH Command")).not.toBeInTheDocument();
},
};

Expand Down
77 changes: 1 addition & 76 deletions site/src/pages/AgentsPage/AgentChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
useQueryClient,
} from "react-query";
import { useOutletContext, useParams } from "react-router";
import { toast } from "sonner";
import type { UrlTransform } from "streamdown";
import { API, watchWorkspace } from "#/api/api";
import { watchWorkspace } from "#/api/api";
import { isApiError } from "#/api/errors";
import { buildOptimisticEditedMessage } from "#/api/queries/chatMessageEdits";
import {
Expand All @@ -31,11 +30,6 @@ import { workspaceById, workspaceByIdKey } from "#/api/queries/workspaces";
import type * as TypesGen from "#/api/typesGenerated";
import type { ChatMessagePart } from "#/api/typesGenerated";
import { useProxy } from "#/contexts/ProxyContext";
import {
getTerminalHref,
getVSCodeHref,
openAppInNewWindow,
} from "#/modules/apps/apps";
import { isMobileViewport } from "#/utils/mobile";
import { pageTitle } from "#/utils/page";
import { rewriteLocalhostURL } from "#/utils/portForward";
Expand Down Expand Up @@ -1069,75 +1063,11 @@ const AgentChatPage: FC = () => {
);

const parentChat = parentChatQuery.data;
const workspaceRoute = workspace
? `/@${workspace.owner_name}/${workspace.name}`
: null;
const canOpenWorkspace = Boolean(workspaceRoute);
const canOpenEditors = Boolean(workspace && workspaceAgent);
const terminalHref =
workspace && workspaceAgent
? getTerminalHref({
username: workspace.owner_name,
workspace: workspace.name,
agent: workspaceAgent.name,
})
: null;
const sshCommand =
workspace && workspaceAgent && sshConfigQuery.data?.hostname_suffix
? `ssh ${workspaceAgent.name}.${workspace.name}.${workspace.owner_name}.${sshConfigQuery.data.hostname_suffix}`
: undefined;

// See mutation destructuring comment above (React Compiler).
const { mutate: generateKey } = useMutation({
mutationFn: () => API.getApiKey(),
});

const handleOpenInEditor = (editor: "cursor" | "vscode") => {
if (!workspace || !workspaceAgent) {
return;
}

// Prefer the active git repo root so VS Code opens to the
// actual project directory, falling back to the agent's
// configured directory.
const repoRoots = Array.from(gitWatcher.repositories.keys()).sort();
const folder = repoRoots[0] ?? workspaceAgent.expanded_directory;

generateKey(undefined, {
onSuccess: ({ key }) => {
location.href = getVSCodeHref(editor, {
owner: workspace.owner_name,
workspace: workspace.name,
token: key,
agent: workspaceAgent.name,
folder,
chatId: agentId,
});
},
onError: () => {
toast.error(
editor === "cursor"
? "Failed to open in Cursor."
: "Failed to open in VS Code.",
);
},
});
};

const handleViewWorkspace = () => {
if (!workspaceRoute) {
return;
}
window.open(workspaceRoute, "_blank");
};

const handleOpenTerminal = () => {
if (!terminalHref) {
return;
}
openAppInNewWindow(terminalHref);
};

const handleArchiveAgentAction = () => {
if (!agentId || isArchived) {
return;
Expand Down Expand Up @@ -1261,12 +1191,7 @@ const AgentChatPage: FC = () => {
prNumber={prNumber}
diffStatusData={chatQuery.data?.diff_status}
gitWatcher={gitWatcher}
canOpenEditors={canOpenEditors}
canOpenWorkspace={canOpenWorkspace}
sshCommand={sshCommand}
handleOpenInEditor={handleOpenInEditor}
handleViewWorkspace={handleViewWorkspace}
handleOpenTerminal={handleOpenTerminal}
handleCommit={handleCommit}
handleInterrupt={handleInterrupt}
handleDeleteQueuedMessage={handleDeleteQueuedMessage}
Expand Down
17 changes: 3 additions & 14 deletions site/src/pages/AgentsPage/AgentChatPageView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,7 @@ const StoryAgentChatPageView: FC<StoryProps> = ({ editing, ...overrides }) => {
typeof AgentChatPageView
>["diffStatusData"],
gitWatcher: buildGitWatcher(),
canOpenEditors: false,
canOpenWorkspace: false,
sshCommand: undefined as string | undefined,
handleOpenInEditor: fn(),
handleViewWorkspace: fn(),
handleOpenTerminal: fn(),
handleCommit: fn(),
handleInterrupt: fn(),
handleDeleteQueuedMessage: fn(),
Expand Down Expand Up @@ -367,15 +362,9 @@ export const NoModelOptions: Story = {
),
};

/** Top bar has workspace action buttons visible. */
export const WithWorkspaceActions: Story = {
render: () => (
<StoryAgentChatPageView
canOpenEditors
canOpenWorkspace
sshCommand="ssh coder.workspace"
/>
),
/** Chat with an attached workspace. */
export const WithWorkspace: Story = {
Comment thread
DanielleMaywood marked this conversation as resolved.
render: () => <StoryAgentChatPageView sshCommand="ssh coder.workspace" />,
};

// ---------------------------------------------------------------------------
Expand Down
76 changes: 20 additions & 56 deletions site/src/pages/AgentsPage/AgentChatPageView.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
ArchiveIcon,
MonitorDotIcon,
MonitorIcon,
MonitorPauseIcon,
MonitorXIcon,
} from "lucide-react";
import { ArchiveIcon } from "lucide-react";

import {
type FC,
Expand All @@ -20,11 +14,7 @@ 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 { getDisplayWorkspaceStatus } from "#/utils/workspace";
import {
AgentChatInput,
type ChatMessageInputRef,
Expand All @@ -43,6 +33,7 @@ import { ChatTopBar } from "./components/ChatTopBar";
import { GitPanel } from "./components/GitPanel/GitPanel";
import { RightPanel } from "./components/RightPanel/RightPanel";
import { SidebarTabView } from "./components/Sidebar/SidebarTabView";
import { StatusIcon } from "./components/StatusIcon";
import { TerminalPanel } from "./components/TerminalPanel";
import { ChatWorkspaceContext } from "./context/ChatWorkspaceContext";
import { chatWidthClass, useChatFullWidth } from "./hooks/useChatFullWidth";
Expand Down Expand Up @@ -132,12 +123,7 @@ interface AgentChatPageViewProps {
};

// Workspace action handlers.
canOpenEditors: boolean;
canOpenWorkspace: boolean;
sshCommand: string | undefined;
handleOpenInEditor: (editor: "cursor" | "vscode") => void;
handleViewWorkspace: () => void;
handleOpenTerminal: () => void;
handleCommit: (repoRoot: string) => void;

// Chat action handlers.
Expand Down Expand Up @@ -206,12 +192,7 @@ export const AgentChatPageView: FC<AgentChatPageViewProps> = ({
prNumber,
diffStatusData,
gitWatcher,
canOpenEditors,
canOpenWorkspace,
sshCommand,
handleOpenInEditor,
handleViewWorkspace,
handleOpenTerminal,
handleCommit,
handleInterrupt,
handleDeleteQueuedMessage,
Expand Down Expand Up @@ -275,16 +256,25 @@ export const AgentChatPageView: FC<AgentChatPageViewProps> = ({

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

// Prefer the git repository root over the agent's expanded directory
// for VS Code folder resolution (important for monorepos).
const preferredFolder = (() => {
const repoRoots = Array.from(gitWatcher?.repositories.keys() ?? []).sort();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like it could have unexpected consequences if gitWatcher is tracking multiple repositories? Your diff view shows one repo and then the editor or what not opens up in another.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Definitely agree with you although that's the existing behavior.

-		// Prefer the active git repo root so VS Code opens to the
-		// actual project directory, falling back to the agent's
-		// configured directory.
-		const repoRoots = Array.from(gitWatcher.repositories.keys()).sort();
-		const folder = repoRoots[0] ?? workspaceAgent.expanded_directory;

We should definitely noodle on a better approach here.

return repoRoots[0] || workspaceAgent?.expanded_directory;
})();

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

const attachedWorkspace = (() => {
if (!workspace || !workspaceRoute) return undefined;

let { type, text } = getDisplayWorkspaceStatus(
workspace.latest_build.status,
workspace.latest_build.job,
);

const agentPreparing =
workspace.latest_build.status === "running" &&
(workspaceAgent?.lifecycle_state === "created" ||
Expand All @@ -300,23 +290,16 @@ export const AgentChatPageView: FC<AgentChatPageViewProps> = ({
type = "warning";
text = "Startup failed";
}

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} />,
};
const statusIcon = <StatusIcon type={effectiveType} />;
return {
name: workspace.name,
route: workspaceRoute,
statusIcon: statusIconMap[effectiveType],
statusIcon,
statusLabel,
};
})();
Expand Down Expand Up @@ -357,14 +340,6 @@ export const AgentChatPageView: FC<AgentChatPageViewProps> = ({
showSidebarPanel,
onToggleSidebar: () => onSetShowSidebarPanel((prev) => !prev),
}}
workspace={{
canOpenEditors,
canOpenWorkspace,
onOpenInEditor: handleOpenInEditor,
onViewWorkspace: handleViewWorkspace,
onOpenTerminal: handleOpenTerminal,
sshCommand,
}}
onArchiveAgent={handleArchiveAgentAction}
onUnarchiveAgent={handleUnarchiveAgentAction}
onArchiveAndDeleteWorkspace={
Expand Down Expand Up @@ -454,7 +429,12 @@ export const AgentChatPageView: FC<AgentChatPageViewProps> = ({
onMCPSelectionChange={onMCPSelectionChange}
onMCPAuthComplete={onMCPAuthComplete}
lastInjectedContext={lastInjectedContext}
workspace={workspace}
workspaceAgent={workspaceAgent}
chatId={agentId}
sshCommand={sshCommand}
attachedWorkspace={attachedWorkspace}
folder={preferredFolder}
/>
</div>
</div>
Expand Down Expand Up @@ -568,14 +548,6 @@ export const AgentChatPageLoadingView: FC<AgentChatPageLoadingViewProps> = ({
showSidebarPanel: false,
onToggleSidebar: () => {},
}}
workspace={{
canOpenEditors: false,
canOpenWorkspace: false,
onOpenInEditor: () => {},
onViewWorkspace: () => {},
onOpenTerminal: () => {},
sshCommand: undefined,
}}
onArchiveAgent={() => {}}
onUnarchiveAgent={() => {}}
onRegenerateTitle={() => {}}
Expand Down Expand Up @@ -646,14 +618,6 @@ export const AgentChatPageNotFoundView: FC<AgentChatPageNotFoundViewProps> = ({
showSidebarPanel: false,
onToggleSidebar: () => {},
}}
workspace={{
canOpenEditors: false,
canOpenWorkspace: false,
onOpenInEditor: () => {},
onViewWorkspace: () => {},
onOpenTerminal: () => {},
sshCommand: undefined,
}}
onArchiveAgent={() => {}}
onUnarchiveAgent={() => {}}
onRegenerateTitle={() => {}}
Expand Down
25 changes: 24 additions & 1 deletion site/src/pages/AgentsPage/components/AgentChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { ContextUsageIndicator } from "./ContextUsageIndicator";
import { ImageLightbox } from "./ImageLightbox";
import { QueuedMessagesList } from "./QueuedMessagesList";
import { TextPreviewDialog } from "./TextPreviewDialog";
import { WorkspacePill } from "./WorkspacePill";

export {
ImageThumbnail,
Expand Down Expand Up @@ -148,7 +149,12 @@ interface AgentChatInputProps {
selectedMCPServerIds?: readonly string[];
onMCPSelectionChange?: (ids: string[]) => void;
onMCPAuthComplete?: (serverId: string) => void;
workspace?: TypesGen.Workspace;
workspaceAgent?: TypesGen.WorkspaceAgent;
chatId?: string;
sshCommand?: string;
attachedWorkspace?: AttachedWorkspaceInfo;
folder?: string;
}

export interface AttachedWorkspaceInfo {
Expand Down Expand Up @@ -285,7 +291,12 @@ export const AgentChatInput: FC<AgentChatInputProps> = ({
selectedMCPServerIds,
onMCPSelectionChange,
onMCPAuthComplete,
workspace,
workspaceAgent,
chatId,
sshCommand,
attachedWorkspace,
folder,
}) => {
const [chatFullWidth] = useChatFullWidth();
const internalRef = useRef<ChatMessageInputRef>(null);
Expand Down Expand Up @@ -395,7 +406,10 @@ 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) {
// When workspace data is available, WorkspacePill handles
// the display (including app dropdown). Otherwise fall back
// to the simple attached-workspace ToolBadge.
if (!(workspace && workspaceAgent && chatId) && attachedWorkspace) {
Comment thread
DanielleMaywood marked this conversation as resolved.
allBadges.push({ kind: "attached-workspace", ...attachedWorkspace });
}
if (selectedWorkspace && onWorkspaceChange) {
Expand Down Expand Up @@ -918,6 +932,15 @@ export const AgentChatInput: FC<AgentChatInputProps> = ({
* hide and reorder via CSS. The pill is invisible
* when there's no overflow but still occupies
* layout space, preventing measurement flicker. */}
{workspace && workspaceAgent && chatId && (
<WorkspacePill
workspace={workspace}
agent={workspaceAgent}
chatId={chatId}
sshCommand={sshCommand}
folder={folder}
/>
)}
<div
ref={badgeContainerRef}
className="flex min-w-0 items-center gap-1 overflow-hidden"
Expand Down
Loading
Loading