From 044a50ea2c9333b8ade6de1ba70218ca026d143d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=98=81=EC=A4=80E?= <105265001+flex-yj-kim@users.noreply.github.com> Date: Fri, 13 Feb 2026 04:19:14 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20resizable=20side=20pa?= =?UTF-8?q?nels=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add drag-to-resize for the annotation panel, table of contents, and file tree sidebar. Panel widths persist in cookie storage across sessions and random-port hook invocations. - Add useResizablePanel hook with left/right side support - Extract ResizeHandle component with spread-friendly handleProps API - Apply to AnnotationPanel, ReviewPanel, TableOfContents, FileTree - Double-click handle to reset to default width - Add min-w-0 on content areas for proper flex shrinking --- packages/editor/App.tsx | 36 ++++++-- packages/review-editor/App.tsx | 52 ++++++++---- .../review-editor/components/FileTree.tsx | 4 +- .../review-editor/components/ReviewPanel.tsx | 4 +- packages/ui/components/AnnotationPanel.tsx | 6 +- packages/ui/components/ResizeHandle.tsx | 21 +++++ packages/ui/components/TableOfContents.tsx | 3 + packages/ui/hooks/useResizablePanel.ts | 84 +++++++++++++++++++ 8 files changed, 180 insertions(+), 30 deletions(-) create mode 100644 packages/ui/components/ResizeHandle.tsx create mode 100644 packages/ui/hooks/useResizablePanel.ts diff --git a/packages/editor/App.tsx b/packages/editor/App.tsx index daa5e9f..acbb0c0 100644 --- a/packages/editor/App.tsx +++ b/packages/editor/App.tsx @@ -25,6 +25,8 @@ import { getAgentSwitchSettings, getEffectiveAgentName } from '@plannotator/ui/u import { getPlanSaveSettings } from '@plannotator/ui/utils/planSave'; import { getUIPreferences, needsUIFeaturesSetup, type UIPreferences } from '@plannotator/ui/utils/uiPreferences'; import { getEditorMode, saveEditorMode } from '@plannotator/ui/utils/editorMode'; +import { useResizablePanel } from '@plannotator/ui/hooks/useResizablePanel'; +import { ResizeHandle } from '@plannotator/ui/components/ResizeHandle'; import { getPermissionModeSettings, needsPermissionModeSetup, @@ -364,6 +366,14 @@ const App: React.FC = () => { const viewerRef = useRef(null); const containerRef = useRef(null); + // Resizable panels + const panelResize = useResizablePanel({ storageKey: 'plannotator-panel-width' }); + const tocResize = useResizablePanel({ + storageKey: 'plannotator-toc-width', + defaultWidth: 240, minWidth: 160, maxWidth: 400, side: 'left', + }); + const isResizing = panelResize.isDragging || tocResize.isDragging; + // Track active section for TOC highlighting const headingCount = useMemo(() => blocks.filter(b => b.type === 'heading').length, [blocks]); const activeSection = useActiveSection(containerRef, headingCount); @@ -1021,20 +1031,24 @@ const App: React.FC = () => { {/* Main Content */} -
+
{/* Table of Contents */} {uiPrefs.tocEnabled && ( - + <> + + + )} {/* Document Area */} -
+
{/* Mode Switcher */}
@@ -1061,6 +1075,9 @@ const App: React.FC = () => {
+ {/* Resize Handle */} + {isPanelOpen && } + {/* Annotation Panel */} { onEdit={handleEditAnnotation} shareUrl={shareUrl} sharingEnabled={sharingEnabled} + width={panelResize.width} />
diff --git a/packages/review-editor/App.tsx b/packages/review-editor/App.tsx index 9d7e847..7ce87fe 100644 --- a/packages/review-editor/App.tsx +++ b/packages/review-editor/App.tsx @@ -8,6 +8,8 @@ import { storage, getAutoClose } from '@plannotator/ui/utils/storage'; import { getIdentity } from '@plannotator/ui/utils/identity'; import { getAgentSwitchSettings, getEffectiveAgentName } from '@plannotator/ui/utils/agentSwitch'; import { CodeAnnotation, CodeAnnotationType, SelectedLineRange, DiffAnnotationMetadata } from '@plannotator/ui/types'; +import { useResizablePanel } from '@plannotator/ui/hooks/useResizablePanel'; +import { ResizeHandle } from '@plannotator/ui/components/ResizeHandle'; import { DiffViewer } from './components/DiffViewer'; import { ReviewPanel } from './components/ReviewPanel'; import { FileTree } from './components/FileTree'; @@ -155,6 +157,14 @@ const ReviewApp: React.FC = () => { const identity = useMemo(() => getIdentity(), []); + // Resizable panels + const panelResize = useResizablePanel({ storageKey: 'plannotator-review-panel-width' }); + const fileTreeResize = useResizablePanel({ + storageKey: 'plannotator-filetree-width', + defaultWidth: 256, minWidth: 160, maxWidth: 400, side: 'left', + }); + const isResizing = panelResize.isDragging || fileTreeResize.isDragging; + // Global keyboard shortcuts useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { @@ -714,28 +724,32 @@ const ReviewApp: React.FC = () => { {/* Main content */} -
+
{/* File tree sidebar - show when multiple files OR diff options available */} {(files.length > 1 || gitContext?.diffOptions) && ( - setHideViewedFiles(prev => !prev)} - enableKeyboardNav={!showExportModal} - diffOptions={gitContext?.diffOptions} - activeDiffType={diffType} - onSelectDiff={handleDiffSwitch} - isLoadingDiff={isLoadingDiff} - /> + <> + setHideViewedFiles(prev => !prev)} + enableKeyboardNav={!showExportModal} + diffOptions={gitContext?.diffOptions} + activeDiffType={diffType} + onSelectDiff={handleDiffSwitch} + isLoadingDiff={isLoadingDiff} + width={fileTreeResize.width} + /> + + )} {/* Diff viewer */} -
+
{activeFile ? ( { )}
+ {/* Resize Handle */} + {isPanelOpen && } + {/* Annotations panel */} { onSelectAnnotation={handleSelectAnnotation} onDeleteAnnotation={handleDeleteAnnotation} feedbackMarkdown={feedbackMarkdown} + width={panelResize.width} />
diff --git a/packages/review-editor/components/FileTree.tsx b/packages/review-editor/components/FileTree.tsx index f9447d0..e5a971a 100644 --- a/packages/review-editor/components/FileTree.tsx +++ b/packages/review-editor/components/FileTree.tsx @@ -28,6 +28,7 @@ interface FileTreeProps { activeDiffType?: string; onSelectDiff?: (diffType: string) => void; isLoadingDiff?: boolean; + width?: number; } export const FileTree: React.FC = ({ @@ -44,6 +45,7 @@ export const FileTree: React.FC = ({ activeDiffType, onSelectDiff, isLoadingDiff, + width, }) => { // Keyboard navigation: j/k or arrow keys const handleKeyDown = useCallback((e: KeyboardEvent) => { @@ -82,7 +84,7 @@ export const FileTree: React.FC = ({ }; return ( -