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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const WORKSPACE_ID_PREFIX_PATTERN = /^workspace\/(?:ws_[^/]+|\d+|[0-9a-f-]{6,})\
const FILE_PATTERN = /(?:^|[\s"'`([{])((?:\.{1,2}[/\\]|~[/\\]|[/\\])?[\w.\-]+(?:[/\\][\w.\-]+)+\.[a-z][a-z0-9]{0,9}|[\w.\-]+\.[a-z][a-z0-9]{0,9})/gi;
const URL_PATTERN = /https?:\/\/[^\s)\]}>"'`]+/gi;
const SOCKET_PATTERN = /(?:ws|wss):\/\/[^\s)\]}>"'`]+/gi;
const ARTIFACT_FILE_PREVIEWS = new Set<OpenTargetPreview>(["markdown", "sheet", "image", "pdf", "html"]);
const ARTIFACT_FILE_PREVIEWS = new Set<OpenTargetPreview>(["markdown", "sheet", "image", "pdf", "html", "text"]);
const DISCOVERY_TOOL_NAMES = new Set(["glob", "grep", "search", "find"]);
const ARTIFACT_METADATA_TOOL_NAMES = new Set(["openwork_extension_call"]);
const WRITE_TOOL_NAMES = new Set([
Expand Down
28 changes: 4 additions & 24 deletions apps/app/src/react-app/domains/session/chat/session-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,33 +371,13 @@ export function SessionPage(props: SessionPageProps) {
}, [toggleCurrentSidePanel]);
const openArtifactRailPane = useCallback(() => {
if (!hasArtifactTargets || !props.selectedSessionId) return;
const activeTab = sessionPanelState.tabs.find((tab) => tab.id === sessionPanelState.activeTabId);
const artifactTargetIds = new Set(artifactFileTargets.map((target) => target.id));
const artifactTab = sessionPanelState.tabs.find((tab) => (
tab.type === "artifact" && artifactTargetIds.has(tab.id)
));
const firstArtifact = artifactFileTargets[0];
if (panelRailActive && activeTab?.type === "artifact") {
if (panelRailActive) {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 30, 2026

Choose a reason for hiding this comment

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

P2: The Artifacts button now closes an already-open panel instead of switching it to the artifact list.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/app/src/react-app/domains/session/chat/session-page.tsx, line 374:

<comment>The Artifacts button now closes an already-open panel instead of switching it to the artifact list.</comment>

<file context>
@@ -371,33 +371,13 @@ export function SessionPage(props: SessionPageProps) {
-    ));
-    const firstArtifact = artifactFileTargets[0];
-    if (panelRailActive && activeTab?.type === "artifact") {
+    if (panelRailActive) {
       toggleCurrentSidePanel("panel");
       return;
</file context>
Fix with Cubic

toggleCurrentSidePanel("panel");
return;
}
if (!panelRailActive) {
preserveSidePanelOnPanelOpenRef.current = true;
}
if (artifactTab) {
selectTab(props.selectedSessionId, artifactTab.id);
} else if (firstArtifact) {
openTab(props.selectedSessionId, {
id: firstArtifact.id,
type: "artifact",
label: firstArtifact.name,
preview: firstArtifact.preview,
});
}
if (!panelRailActive) {
toggleCurrentSidePanel("panel");
}
}, [artifactFileTargets, hasArtifactTargets, openTab, panelRailActive, props.selectedSessionId, selectTab, sessionPanelState, toggleCurrentSidePanel]);
preserveSidePanelOnPanelOpenRef.current = true;
toggleCurrentSidePanel("panel");
}, [hasArtifactTargets, panelRailActive, props.selectedSessionId, toggleCurrentSidePanel]);
const openExtensionsRailPane = useCallback(() => {
toggleCurrentSidePanel("extensions");
}, [toggleCurrentSidePanel]);
Expand Down
51 changes: 50 additions & 1 deletion apps/app/src/react-app/domains/session/panel/side-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ import {
InputGroupInput,
} from "@/components/ui/input-group";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { formatFileSize } from "@/lib/utils";

import { isCollectibleArtifactTarget, type OpenTarget } from "../artifacts/open-target";
import { ArtifactIcon } from "../artifacts/artifact-icon";
import { ArtifactPanel } from "../artifacts/artifact-panel";
import {
type BrowserPanelTab,
type PanelTab as PanelTabEntry,
useActivePanelTab,
usePanelTabStore,
useSessionPanelState,
} from "./panel-tab-store";
import { useSidePanelTabs } from "./use-side-panel-tabs";
Expand Down Expand Up @@ -433,7 +436,7 @@ export function SidePanel({
</div>
</div>
{!activeTab ? (
<PanelEmpty />
<ArtifactList sessionId={sessionId} />
) : null}
{activeTab?.type === "browser" ? (
<BrowserPanelContent tab={activeTab} onClose={onClose} />
Expand All @@ -455,6 +458,52 @@ export function SidePanel({
);
}

function ArtifactList({ sessionId }: { sessionId: string }) {
const openTab = usePanelTabStore((state) => state.openTab);
const targets = usePanelTabStore((state) =>
(state.transcriptArtifactTargets[sessionId] ?? []).filter(isCollectibleArtifactTarget)
);

if (targets.length === 0) {
return (
<div className="flex h-full items-center justify-center p-4 text-center">
<p className="text-sm text-muted-foreground">No artifacts yet.</p>
</div>
);
}

return (
<div className="flex h-full flex-col overflow-hidden">
<div className="shrink-0 px-3 py-2">
<p className="text-xs font-medium text-muted-foreground">Artifacts ({targets.length})</p>
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-1 pb-2">
{targets.map((target) => (
<button
key={target.id}
type="button"
className="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent/50 focus:bg-accent/50 focus:outline-none"
onClick={() => {
openTab(sessionId, {
id: target.id,
type: "artifact",
label: target.name,
preview: target.preview,
});
}}
>
<ArtifactIcon type={target.preview} />
<span className="min-w-0 flex-1 truncate">{target.name}</span>
{target.size !== undefined ? (
<span className="shrink-0 text-xs text-muted-foreground">{formatFileSize(target.size)}</span>
) : null}
</button>
))}
</div>
</div>
);
}

function PanelEmpty() {
return (
<div className="flex h-full items-center justify-center p-4 text-center">
Expand Down