The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
fix(ui): keep task tabs steady when switching views (#17068)
Tonio043f2514e67c
diff --git a/ui/src/components/task-side-panel/TaskSidePanel.test.tsx b/ui/src/components/task-side-panel/TaskSidePanel.test.tsxindex 4ea43c2be5..2e2a9f61cd 100644--- a/ui/src/components/task-side-panel/TaskSidePanel.test.tsx+++ b/ui/src/components/task-side-panel/TaskSidePanel.test.tsx@@ -179,6 +179,28 @@ describe("TaskSidePanel", () => {);}+ it("keeps the upload slot mounted and inert when switching away from Artifacts", async () => {+ await render(panel({ streamlinedTabs: true, artifactsOpenRequestId: 1 }));+ const slot = container.querySelector<HTMLElement>("[data-artifact-upload-slot]");+ expect(slot).not.toBeNull();+ await act(async () => container.querySelector<HTMLButtonElement>("#side-panel-tab-artifacts")?.click());+ expect(slot?.getAttribute("aria-hidden")).toBe("false");+ expect(slot?.hasAttribute("inert")).toBe(false);+ expect(slot?.className).not.toContain("invisible");++ await act(async () => container.querySelector<HTMLButtonElement>("#side-panel-tab-properties")?.click());+ expect(container.querySelector("[data-artifact-upload-slot]")).toBe(slot);+ expect(slot?.getAttribute("aria-hidden")).toBe("true");+ expect(slot?.hasAttribute("inert")).toBe(true);+ expect(slot?.className).toContain("invisible");++ await act(async () => container.querySelector<HTMLButtonElement>("#side-panel-tab-artifacts")?.click());+ expect(container.querySelector("[data-artifact-upload-slot]")).toBe(slot);+ expect(slot?.hasAttribute("inert")).toBe(false);+ await act(async () => container.querySelector<HTMLButtonElement>('button[aria-label="Close Artifacts"]')?.click());+ expect(container.querySelector("[data-artifact-upload-slot]")).toBeNull();+ });+it("opens, deduplicates, switches and closes text attachment tabs", async () => {const onAttachmentOpened = vi.fn();await render(panel({ openAttachment: { id: "file-1", title: "AGENTS.md", requestId: 1 }, onAttachmentOpened }));diff --git a/ui/src/components/task-side-panel/TaskSidePanel.tsx b/ui/src/components/task-side-panel/TaskSidePanel.tsxindex ee28cab900..5f7f738ac2 100644--- a/ui/src/components/task-side-panel/TaskSidePanel.tsx+++ b/ui/src/components/task-side-panel/TaskSidePanel.tsx@@ -357,7 +357,9 @@ export function TaskSidePanel({}}, [openBrowserId, controller.activeTabId, onBrowserOpened, accountScope, issue.companyId, issue.id, fileTabsEnabled]);const activeTab = controller.tabs.find((tab) => tab.id === controller.activeTabId) ?? null;- const canUploadArtifacts = activeTab?.payload.kind === "artifacts" && !conversationAgentId && !issue.id.startsWith("chat:");+ const hasArtifactUploadSlot = !conversationAgentId && !issue.id.startsWith("chat:")+ && controller.tabs.some((tab) => tab.payload.kind === "artifacts");+ const canUploadArtifacts = hasArtifactUploadSlot && activeTab?.payload.kind === "artifacts";const subtasksAvailable = showRelatedTasks && (taskCount > 0 || tasksTab?.hasError === true);const hasSubtasksTab = controller.tabs.some((tab) => tab.id === "subtasks");@@ -820,7 +822,18 @@ export function TaskSidePanel({}const contentMode = activeTab?.contentMode ?? "full-bleed";- const header = <>{tabStrip}{canUploadArtifacts ? <ArtifactUploadButton onUpload={artifactUploads.upload} /> : null}</>;+ const header = <>{tabStrip}{hasArtifactUploadSlot ? (+ // Keep the header footprint stable when selection changes. Hidden controls+ // retain their space but cannot receive focus or open the file picker.+ <div+ data-artifact-upload-slot+ className={cn("shrink-0", !canUploadArtifacts && "invisible")}+ aria-hidden={!canUploadArtifacts}+ inert={!canUploadArtifacts}+ >+ <ArtifactUploadButton onUpload={artifactUploads.upload} />+ </div>+ ) : null}</>;return (<ArtifactDropzone enabled={canUploadArtifacts} target={paneHeaderSlot?.closest<HTMLElement>("[data-presentation]")} onUpload={artifactUploads.upload}><div className="flex h-full min-h-0 flex-col">diff --git a/ui/storybook/stories/documents-artifacts/html-artifacts/03-task-journey.stories.tsx b/ui/storybook/stories/documents-artifacts/html-artifacts/03-task-journey.stories.tsxindex 8b28b5ee04..7479c138a5 100644--- a/ui/storybook/stories/documents-artifacts/html-artifacts/03-task-journey.stories.tsx+++ b/ui/storybook/stories/documents-artifacts/html-artifacts/03-task-journey.stories.tsx@@ -1,5 +1,6 @@import { useState } from "react";import type { Meta, StoryObj } from "@storybook/react-vite";+import { expect, userEvent, waitFor, within } from "storybook/test";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import type { IssueAttachment } from "@paperclipai/shared";import { Routes, Route } from "@/lib/router";@@ -26,7 +27,13 @@ const attachment: IssueAttachment = {updatedAt: new Date("2026-10-07T12:54:00Z"),};-function TaskJourney({ openInitially = false }: { openInitially?: boolean }) {+interface JourneyProps {+ openInitially?: boolean;+ streamlinedTabs?: boolean;+ panelWidth?: number;+}++function TaskJourney({ openInitially = false, streamlinedTabs = false, panelWidth }: JourneyProps) {const [open, setOpen] = useState<{ id: string; title: string; requestId: number } | null>(() => openInitially ? { id: attachment.id, title: attachment.originalFilename!, requestId: 1 } : null);const [client] = useState(() => {const cache = new QueryClient({ defaultOptions: { queries: { staleTime: Infinity, retry: false } } });@@ -49,15 +56,15 @@ function TaskJourney({ openInitially = false }: { openInitially?: boolean }) {<TaskChatBubble item={{ id: "response", kind: "message", author: "agent", text: "Hyperswitch and Storybook lead the combined ranking. Open the report to explore the weighting and filter the results." }} /><IssueArtifactFile id={attachment.id} attachmentId={attachment.id} title="Interactive repository usage report" summary="" filename={attachment.originalFilename!} contentType={attachment.contentType} contentPath={attachment.contentPath} downloadPath={attachment.downloadPath!} byteSize={attachment.byteSize} author="CodexRunner" updatedAt="7:54 AM" /></section>- <section className="h-(--sz-640px) min-w-0 flex-1 overflow-hidden rounded-lg border border-border" aria-label="Task side panel">- <TaskSidePanel issue={issue} accountScope="storybook-html" inline onUpdate={() => {}} fileTabsEnabled={false} openAttachment={open} />+ <section className={`h-(--sz-640px) min-w-0 max-w-full overflow-hidden rounded-lg border border-border ${panelWidth ? "shrink-0" : "flex-1"}`} style={panelWidth ? { width: panelWidth } : undefined} aria-label="Task side panel">+ <TaskSidePanel issue={issue} accountScope="storybook-html" inline onUpdate={() => {}} fileTabsEnabled={false} openAttachment={open} streamlinedTabs={streamlinedTabs} artifactsOpenRequestId={streamlinedTabs ? 1 : undefined} /></section></div></TextAttachmentContext.Provider></QueryClientProvider>;}-function Journey(props: { openInitially?: boolean }) {+function Journey(props: JourneyProps) {return <PluginLauncherProvider><Routes><Route path="/:companyPrefix" element={<Layout />}><Route path="issues/:issueId" element={<TaskJourney {...props} />} /></Route></Routes></PluginLauncherProvider>;@@ -69,7 +76,8 @@ const meta = {paperclip: {"capabilities": ["documents-artifacts/attachments",- "workspaces/files-git"+ "workspaces/files-git",+ "navigation-preferences/navigation"],"implementation": "production","boundary": "fixtures"@@ -92,3 +100,30 @@ type Story = StoryObj<typeof meta>;export const OpenFromTask: Story = {};export const ReportOpen: Story = { args: { openInitially: true } };export const Mobile: Story = { args: { openInitially: true }, globals: { viewport: { value: "mobile", isRotated: false } } };++export const StableTabWidths: Story = {+ args: { openInitially: true, streamlinedTabs: true, panelWidth: 320 },+ parameters: {+ docs: { description: { story: "Production task panel in a constrained pane. Switching between Artifacts, Properties, and the report keeps every tab the same width while the upload control appears or disappears. Upload requests remain outside this fixture's scope." } },+ },+ play: async ({ canvasElement }) => {+ const panel = within(canvasElement).getByRole("region", { name: "Task side panel" });+ const canvas = within(panel);+ const widths = () => Array.from(panel.querySelectorAll<HTMLElement>("[data-side-panel-tab-wrapper]"))+ .map((tab) => tab.getBoundingClientRect().width);+ await userEvent.click(await canvas.findByRole("tab", { name: "Artifacts" }));+ await expect(canvas.getByRole("button", { name: "Upload files" })).toBeVisible();+ const baseline = widths();+ await expect(baseline).toHaveLength(3);+ await expect(new Set(baseline).size).toBe(1);+ for (const name of ["Properties", "repository-usage.html", "Artifacts"]) {+ await userEvent.click(canvas.getByRole("tab", { name }));+ await waitFor(() => expect(widths()).toEqual(baseline));+ if (name === "Artifacts") {+ await expect(canvas.getByRole("button", { name: "Upload files" })).toBeVisible();+ } else {+ await expect(canvas.queryByRole("button", { name: "Upload files" })).toBeNull();+ }+ }+ },+};