From ca3acb0d300a4cca29d22fc9b30f4174847da09f Mon Sep 17 00:00:00 2001 From: Mathew Pareles Date: Mon, 5 May 2025 03:22:54 -0700 Subject: [PATCH] commandbar draft --- .../VoidCommandBar.tsx | 285 +++++++----------- .../void/browser/voidCommandBarService.ts | 4 +- 2 files changed, 114 insertions(+), 175 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-editor-widgets-tsx/VoidCommandBar.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-editor-widgets-tsx/VoidCommandBar.tsx index 73b7a0e0..c8c60647 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-editor-widgets-tsx/VoidCommandBar.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-editor-widgets-tsx/VoidCommandBar.tsx @@ -24,16 +24,12 @@ export const VoidCommandBarMain = ({ uri, editor }: VoidCommandBarProps) => { } - - const stepIdx = (currIdx: number | null, len: number, step: -1 | 1) => { if (len === 0) return null return ((currIdx ?? 0) + step + len) % len // for some reason, small negatives are kept negative. just add len to offset } - - -const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { +export const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { const accessor = useAccessor() const editCodeService = accessor.get('IEditCodeService') const editorService = accessor.get('ICodeEditorService') @@ -43,11 +39,6 @@ const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { const voidModelService = accessor.get('IVoidModelService') const { stateOfURI: commandBarState, sortedURIs: sortedCommandBarURIs } = useCommandBarState() - - // useEffect(() => { - // console.log('MOUNTING!!!') - // }, []) - // latestUriIdx is used to remember place in leftRight const _latestValidUriIdxRef = useRef(null) @@ -120,7 +111,6 @@ const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { const sortedDiffIds = uri ? commandBarState[uri.fsPath]?.sortedDiffIds ?? [] : [] const sortedDiffZoneIds = uri ? commandBarState[uri.fsPath]?.sortedDiffZoneIds ?? [] : [] - const isADiffInThisFile = sortedDiffIds.length !== 0 const isADiffZoneInThisFile = sortedDiffZoneIds.length !== 0 const isADiffZoneInAnyFile = sortedCommandBarURIs.length !== 0 @@ -134,69 +124,7 @@ const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { const prevURIIdx = getNextUriIdx(-1) const upDownDisabled = prevDiffIdx === null || nextDiffIdx === null - const leftRightDisabled = prevURIIdx === null || nextURIIdx === null // || (sortedCommandBarURIs.length === 1 && isADiffZoneInThisFile) - - const upButton = - - const downButton = - - const leftButton = - - const rightButton = - - + const leftRightDisabled = prevURIIdx === null || nextURIIdx === null // accept/reject if current URI has changes const onAcceptAll = () => { @@ -210,109 +138,120 @@ const VoidCommandBar = ({ uri, editor }: VoidCommandBarProps) => { metricsService.capture('Reject All', {}) } - if (!isADiffZoneInAnyFile) return null - // const acceptAllButton = - - // const rejectAllButton = - - const acceptAllButton = - - const rejectAllButton = - - const acceptRejectAllButtons =
- {acceptAllButton} - {rejectAllButton} -
- - // const closeCommandBar = useCallback(() => { - // commandService.executeCommand('void.hideCommandBar'); - // }, [commandService]); - - // const hideButton = - - const leftRightUpDownButtons =
-
- {/* Changes in file */} -
- {upButton} - {downButton} - - {isADiffInThisFile ? - `Diff ${(currDiffIdx ?? 0) + 1} of ${sortedDiffIds.length}` - : streamState === 'streaming' ? - 'No changes yet' - : `No changes` - } - + // Triple colon button (menu) + const tripleColonButton = ( + + ) - {/* Files */} -
- {leftButton} - {/*
*/} - {rightButton} - {/*
*/} - - {currFileIdx !== null ? - `File ${currFileIdx + 1} of ${sortedCommandBarURIs.length}` - : `${sortedCommandBarURIs.length} file${sortedCommandBarURIs.length === 1 ? '' : 's'} changed` - } - + return ( +
+
+ {/* Diff Navigation Group */} +
+ + + {isADiffInThisFile + ? `Diff ${(currDiffIdx ?? 0) + 1}/${sortedDiffIds.length}` + : streamState === 'streaming' + ? 'No changes yet' + : 'No changes' + } + + +
+ + {/* File Navigation Group */} +
+ + + {currFileIdx !== null + ? `File ${currFileIdx + 1}/${sortedCommandBarURIs.length}` + : `${sortedCommandBarURIs.length} file${sortedCommandBarURIs.length === 1 ? '' : 's'}` + } + + +
+ + {/* Accept/Reject buttons - only shown when appropriate */} + {showAcceptRejectAll && ( +
+ + +
+ )} + + {/* Triple colon menu button */} + {tripleColonButton}
-
- - return
- {showAcceptRejectAll && acceptRejectAllButtons} - {leftRightUpDownButtons} - -
+ ) } diff --git a/src/vs/workbench/contrib/void/browser/voidCommandBarService.ts b/src/vs/workbench/contrib/void/browser/voidCommandBarService.ts index 4913e681..a8b5191f 100644 --- a/src/vs/workbench/contrib/void/browser/voidCommandBarService.ts +++ b/src/vs/workbench/contrib/void/browser/voidCommandBarService.ts @@ -417,8 +417,8 @@ class AcceptRejectAllFloatingWidget extends Widget implements IOverlayWidget { // Style the container // root.style.backgroundColor = 'rgb(248 113 113)'; - root.style.height = '16rem'; // make a fixed size, and all contents go on the bottom right. this fixes annoying VS Code mounting issues - root.style.width = '16rem'; + root.style.height = '256px'; // make a fixed size, and all contents go on the bottom right. this fixes annoying VS Code mounting issues + root.style.width = '100%'; root.style.flexDirection = 'column'; root.style.justifyContent = 'flex-end'; root.style.alignItems = 'flex-end';