22// SPDX-License-Identifier: Apache-2.0
33
44import { WaveUIMessagePart } from "@/app/aipanel/aitypes" ;
5- import { atoms } from "@/app/store/global" ;
5+ import { atoms , getSettingsKeyAtom } from "@/app/store/global" ;
66import { globalStore } from "@/app/store/jotaiStore" ;
77import { getWebServerEndpoint } from "@/util/endpoints" ;
88import { checkKeyPressed , keydownWrapper } from "@/util/keyutil" ;
99import { cn } from "@/util/util" ;
1010import { useChat } from "@ai-sdk/react" ;
1111import { DefaultChatTransport } from "ai" ;
12+ import * as jotai from "jotai" ;
1213import { memo , useEffect , useRef , useState } from "react" ;
1314import { createDataUrl , isAcceptableFile , normalizeMimeType } from "./ai-utils" ;
1415import { AIDroppedFiles } from "./aidroppedfiles" ;
@@ -29,6 +30,8 @@ const AIPanelComponent = memo(({ className, onClose }: AIPanelProps) => {
2930 const model = WaveAIModel . getInstance ( ) ;
3031 const realMessageRef = useRef < AIMessage > ( null ) ;
3132 const inputRef = useRef < AIPanelInputRef > ( null ) ;
33+ const isLayoutMode = jotai . useAtomValue ( atoms . controlShiftDelayAtom ) ;
34+ const showOverlayBlockNums = jotai . useAtomValue ( getSettingsKeyAtom ( "app:showoverlayblocknums" ) ) ?? true ;
3235
3336 const { messages, sendMessage, status, setMessages, error } = useChat ( {
3437 transport : new DefaultChatTransport ( {
@@ -198,7 +201,7 @@ const AIPanelComponent = memo(({ className, onClose }: AIPanelProps) => {
198201 // Check if the click target is an interactive element
199202 const target = e . target as HTMLElement ;
200203 const isInteractive = target . closest ( 'button, a, input, textarea, select, [role="button"], [tabindex]' ) ;
201-
204+
202205 if ( isInteractive ) {
203206 return ;
204207 }
@@ -212,10 +215,12 @@ const AIPanelComponent = memo(({ className, onClose }: AIPanelProps) => {
212215 } , 0 ) ;
213216 } ;
214217
218+ const showBlockMask = isLayoutMode && showOverlayBlockNums ;
219+
215220 return (
216221 < div
217222 className = { cn (
218- "bg-gray-900 border-t border-gray-600 flex flex-col relative mt-1" ,
223+ "bg-gray-900 border-t border-gray-600 flex flex-col relative h-[calc(100%-3px)] mt-1" ,
219224 className ,
220225 isDragOver && "bg-gray-800 border-accent"
221226 ) }
@@ -231,17 +236,39 @@ const AIPanelComponent = memo(({ className, onClose }: AIPanelProps) => {
231236 onClick = { handleClick }
232237 >
233238 { isDragOver && (
234- < div className = "absolute inset-0 bg-accent/20 border-2 border-dashed border-accent rounded-lg flex items-center justify-center z-10 p-4" >
239+ < div
240+ key = "drag-overlay"
241+ className = "absolute inset-0 bg-accent/20 border-2 border-dashed border-accent rounded-lg flex items-center justify-center z-10 p-4"
242+ >
235243 < div className = "text-accent text-center" >
236244 < i className = "fa fa-upload text-3xl mb-2" > </ i >
237245 < div className = "text-lg font-semibold" > Drop files here</ div >
238246 < div className = "text-sm" > Images, PDFs, and text/code files supported</ div >
239247 </ div >
240248 </ div >
241249 ) }
250+ { showBlockMask && (
251+ < div
252+ key = "block-mask"
253+ className = "absolute top-0 left-0 right-0 bottom-0 border-1 border-transparent pointer-events-auto select-none p-0.5"
254+ style = { {
255+ borderRadius : "var(--block-border-radius)" ,
256+ zIndex : "var(--zindex-block-mask-inner)" ,
257+ } }
258+ >
259+ < div
260+ className = "w-full mt-[44px] h-[calc(100%-44px)] flex items-center justify-center"
261+ style = { {
262+ backgroundColor : "rgb(from var(--block-bg-color) r g b / 50%)" ,
263+ } }
264+ >
265+ < div className = "font-bold opacity-70 mt-[-25%] text-[60px]" > 0</ div >
266+ </ div >
267+ </ div >
268+ ) }
242269 < AIPanelHeader onClose = { onClose } model = { model } />
243270
244- < div className = "flex-1 flex flex-col min-h-0" >
271+ < div key = "main-content" className = "flex-1 flex flex-col min-h-0" >
245272 < AIPanelMessages messages = { messages } status = { status } />
246273 { errorMessage && (
247274 < div className = "px-4 py-2 text-red-400 bg-red-900/20 border-l-4 border-red-500 mx-2 mb-2" >
0 commit comments