From 41fa6252717f8d107be744935c4ada597a02b375 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 20:12:59 +0000 Subject: [PATCH] feat: Modify canvas opening and collapse behavior Implements two main changes to the canvas functionality: 1. Conditional Canvas Opening: - The canvas panel now only opens if you have started a chat AND the currently active artifact is of type 'code' or 'text' (markdown). - This prevents the canvas from appearing for other artifact types or when no relevant file is being worked on. 2. Explicit Canvas Collapse/Expand: - A new state `isCanvasPanelCollapsed` is added to the `CanvasComponent`. - A collapse/expand button is added to the `ArtifactHeader`. This button toggles the `isCanvasPanelCollapsed` state. - If the canvas panel is collapsed, it and its resizable handle are hidden. - The chat panel dynamically adjusts its size: - If the canvas is collapsed, the chat panel expands to take the full width. - If the chat is collapsed, the canvas panel expands to take the full width. These changes provide you with more control over the canvas visibility and ensure it's only present when relevant. --- .../components/artifacts/ArtifactRenderer.tsx | 4 ++++ .../src/components/artifacts/header/index.tsx | 23 +++++++++++++++++-- apps/web/src/components/canvas/canvas.tsx | 21 +++++++++++++---- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/apps/web/src/components/artifacts/ArtifactRenderer.tsx b/apps/web/src/components/artifacts/ArtifactRenderer.tsx index 7a2caf4a..95e11cd2 100644 --- a/apps/web/src/components/artifacts/ArtifactRenderer.tsx +++ b/apps/web/src/components/artifacts/ArtifactRenderer.tsx @@ -26,6 +26,8 @@ export interface ArtifactRendererProps { setIsEditing: React.Dispatch>; chatCollapsed: boolean; setChatCollapsed: (c: boolean) => void; + isCanvasPanelCollapsed: boolean; + setIsCanvasPanelCollapsed: React.Dispatch>; } interface SelectionBox { @@ -318,6 +320,8 @@ function ArtifactRendererComponent(props: ArtifactRendererProps) { artifactUpdateFailed={artifactUpdateFailed} chatCollapsed={props.chatCollapsed} setChatCollapsed={props.setChatCollapsed} + isCanvasPanelCollapsed={props.isCanvasPanelCollapsed} + setIsCanvasPanelCollapsed={props.setIsCanvasPanelCollapsed} />
void; + isCanvasPanelCollapsed: boolean; + setIsCanvasPanelCollapsed: React.Dispatch>; } export function ArtifactHeader(props: ArtifactHeaderProps) { @@ -40,7 +42,24 @@ export function ArtifactHeader(props: ArtifactHeaderProps) { artifactUpdateFailed={props.artifactUpdateFailed} />
-
+
+ + props.setIsCanvasPanelCollapsed(!props.isCanvasPanelCollapsed) + } + > + {props.isCanvasPanelCollapsed ? ( + + ) : ( + + )} + )} - {chatStarted && ( + {shouldRenderCanvas && ( <>