From a1c7b254d3ae16289f3cbe7b15efca0587de3df1 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Mon, 17 Mar 2025 22:38:45 -0700 Subject: [PATCH] flex instead of observer --- .../contrib/void/browser/editCodeService.ts | 3 + .../react/src/sidebar-tsx/SidebarChat.tsx | 71 +++++-------------- 2 files changed, 22 insertions(+), 52 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/editCodeService.ts b/src/vs/workbench/contrib/void/browser/editCodeService.ts index 4b966db3..6fef2290 100644 --- a/src/vs/workbench/contrib/void/browser/editCodeService.ts +++ b/src/vs/workbench/contrib/void/browser/editCodeService.ts @@ -1733,6 +1733,9 @@ class EditCodeService extends Disposable implements IEditCodeService { const originalBounds = findTextInCode(block.orig, originalFileCode) // if error if (typeof originalBounds === 'string') { + console.log('fullText', { fullText }) + console.log('error:', originalBounds) + console.log('block.orig:', block.orig) const content = errMsgOfInvalidStr(originalBounds, block.orig) messages.push( { role: 'assistant', content: fullText, anthropicReasoning: null }, // latest output diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index 8f314049..6469400b 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -377,33 +377,6 @@ export const VoidChatArea: React.FC = ({ ); }; -const useResizeObserver = () => { - const ref = useRef(null); - const [dimensions, setDimensions] = useState({ height: 0, width: 0 }); - - useEffect(() => { - if (ref.current) { - const resizeObserver = new ResizeObserver((entries) => { - if (entries.length > 0) { - const entry = entries[0]; - setDimensions({ - height: entry.contentRect.height, - width: entry.contentRect.width - }); - } - }); - - resizeObserver.observe(ref.current); - - return () => { - if (ref.current) - resizeObserver.unobserve(ref.current); - }; - } - }, []); - - return [ref, dimensions] as const; -}; @@ -474,7 +447,6 @@ const ScrollToBottomContainer = ({ children, className, style, scrollContainerRe return (
// ts isnt smart enough... - if (ToolRequestWrapper) { // && isLast // if it's the last message + if (ToolRequestWrapper && isLast) { // if it's the last message return <> @@ -1924,13 +1896,11 @@ export const SidebarChat = () => { const isDisabled = instructionsAreEmpty || !!isFeatureNameDisabled('Chat', settingsState) - const [sidebarRef, sidebarDimensions] = useResizeObserver() - const [chatAreaRef, chatAreaDimensions] = useResizeObserver() - const [historyRef, historyDimensions] = useResizeObserver() + const sidebarRef = useRef(null) + const scrollContainerRef = useRef(null) useScrollbarStyles(sidebarRef) - const onSubmit = useCallback(async () => { if (isDisabled) return @@ -1961,12 +1931,9 @@ export const SidebarChat = () => { chatThreadsService.stopRunning(threadId) } - // const [_test_messages, _set_test_messages] = useState([]) - const keybindingString = accessor.get('IKeybindingService').lookupKeybinding(VOID_CTRL_L_ACTION_ID)?.getLabel() // scroll to top on thread switch - const scrollContainerRef = useRef(null) useEffect(() => { if (isHistoryOpen) scrollContainerRef.current?.scrollTo({ top: 0, left: 0 }) @@ -2003,8 +1970,8 @@ export const SidebarChat = () => { const allMessagesHTML = [...previousMessagesHTML, currStreamingMessageHTML] - const threadSelector =
@@ -2015,12 +1982,11 @@ export const SidebarChat = () => { className={` flex flex-col px-4 py-4 space-y-4 - w-full h-auto + w-full h-full overflow-x-hidden overflow-y-auto ${previousMessagesHTML.length === 0 && !messageSoFar ? 'hidden' : ''} `} - style={{ maxHeight: sidebarDimensions.height - historyDimensions.height - chatAreaDimensions.height - (25) }} // the height of the previousMessages is determined by all other heights > {/* previous messages */} {allMessagesHTML} @@ -2052,12 +2018,12 @@ export const SidebarChat = () => { onAbort() } }, [onSubmit, onAbort, isRunning]) + const inputForm =
0 ? 'absolute bottom-0' : ''}`}> + className='px-2 pb-2'> { onClickAnywhere={() => { textAreaRef.current?.focus() }} > 0 ? 'min-h-[9px]' : 'min-h-[81px]'} px-0.5`} className={`min-h-[81px] px-0.5 py-0.5`} placeholder={`${keybindingString ? `${keybindingString} to select. ` : ''}Enter instructions...`} onChangeText={onChangeText} @@ -2084,13 +2049,15 @@ export const SidebarChat = () => {
- return
- {threadSelector} - - {messagesHTML} - - {inputForm} - -
+ return ( +
+ {threadSelector} +
+
+ {messagesHTML} +
+ {inputForm} +
+
+ ) } -