From a63a48db446949bb70091be7485912e311401dc5 Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Wed, 1 Jul 2026 14:08:43 +0700 Subject: [PATCH] refactor(editor): reposition the view toggle and restyle its segments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the "View" row to the bottom of each actions dropdown — directly above Delete when a Delete row exists, otherwise last. Swap the segment icons to SquareMenu (rich editor) and Type (raw source), and give the segmented control a dark-friendly treatment (bg-background track with a bg-card active segment, matching the System/Human prompt tabs) so the active segment reads as raised on dark. Apply the same treatment to the Theme picker in the sidebar for consistency. Co-Authored-By: Claude Opus 4.8 --- .../components/layouts/main/main-sidebar.tsx | 8 +- .../components/shared/editor-view-mode.tsx | 12 +-- .../features/knowledges/knowledge-header.tsx | 81 ++++++++++--------- .../src/pages/settings/settings-prompt.tsx | 26 +++--- frontend/src/pages/templates/template.tsx | 30 ++++--- 5 files changed, 84 insertions(+), 73 deletions(-) diff --git a/frontend/src/components/layouts/main/main-sidebar.tsx b/frontend/src/components/layouts/main/main-sidebar.tsx index b717337c..7a699047 100644 --- a/frontend/src/components/layouts/main/main-sidebar.tsx +++ b/frontend/src/components/layouts/main/main-sidebar.tsx @@ -332,24 +332,24 @@ export function MainSidebar() { onValueChange={(value) => setTheme(value as Theme)} value={theme || 'system'} > - + diff --git a/frontend/src/components/shared/editor-view-mode.tsx b/frontend/src/components/shared/editor-view-mode.tsx index aa602bca..e68cdb72 100644 --- a/frontend/src/components/shared/editor-view-mode.tsx +++ b/frontend/src/components/shared/editor-view-mode.tsx @@ -1,4 +1,4 @@ -import { Code, Eye } from 'lucide-react'; +import { SquareMenu, Type } from 'lucide-react'; import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'; @@ -19,21 +19,21 @@ export function EditorViewModeToggle({ className, mode, onModeChange, rawTooltip onValueChange={(value) => onModeChange(value as EditorViewMode)} value={mode} > - + - + - + diff --git a/frontend/src/features/knowledges/knowledge-header.tsx b/frontend/src/features/knowledges/knowledge-header.tsx index e3ed9f8e..fa830014 100644 --- a/frontend/src/features/knowledges/knowledge-header.tsx +++ b/frontend/src/features/knowledges/knowledge-header.tsx @@ -101,6 +101,8 @@ export function KnowledgeHeader({ // the cache, and the form picks up the new value separately. const knowledgeName = knowledge?.question ?? null; const canShowActions = !isNew && !!knowledge; + const hasAnonymizeRow = isMobile && canAnonymize; + const hasNavRow = isMobile && knowledgeNav.total > 0; const { handleDropdownCloseAutoFocus, @@ -232,29 +234,27 @@ export function KnowledgeHeader({ className="min-w-24" onCloseAutoFocus={handleDropdownCloseAutoFocus} > - {isMobile && canAnonymize && ( - <> - - {isAnonymizing ? ( - <> - - Anonymizing... - - ) : ( - <> - - Anonymize - - )} - - {(canShowActions || onModeChange) && } - + {hasAnonymizeRow && ( + + {isAnonymizing ? ( + <> + + Anonymizing... + + ) : ( + <> + + Anonymize + + )} + )} - {isMobile && knowledgeNav.total > 0 && ( + {hasNavRow && ( <> + {hasAnonymizeRow && } event.preventDefault()} @@ -269,31 +269,38 @@ export function KnowledgeHeader({ /> - )} - {onModeChange ? ( - event.preventDefault()} - > - View - - - ) : null} {canShowActions && ( <> - {onModeChange ? : null} + {(hasAnonymizeRow || hasNavRow) && } Rename + + )} + {onModeChange ? ( + <> + {!canShowActions && (hasAnonymizeRow || hasNavRow) && } + event.preventDefault()} + > + View + + + + ) : null} + {canShowActions && ( + <> + setIsDeleteDialogOpen(true)} diff --git a/frontend/src/pages/settings/settings-prompt.tsx b/frontend/src/pages/settings/settings-prompt.tsx index 4d44385b..570fab67 100644 --- a/frontend/src/pages/settings/settings-prompt.tsx +++ b/frontend/src/pages/settings/settings-prompt.tsx @@ -858,21 +858,8 @@ function SettingsPrompt() { align="end" className="min-w-24" > - event.preventDefault()} - > - View - - {hasOverride && ( <> - setIsDiffDialogOpen(true)}> Diff @@ -888,8 +875,21 @@ function SettingsPrompt() { )} {isDeleteLoading ? 'Resetting...' : 'Reset'} + )} + event.preventDefault()} + > + View + + diff --git a/frontend/src/pages/templates/template.tsx b/frontend/src/pages/templates/template.tsx index ce2de4f2..cee2a1dd 100644 --- a/frontend/src/pages/templates/template.tsx +++ b/frontend/src/pages/templates/template.tsx @@ -495,21 +495,8 @@ function Template() { className="min-w-24" onCloseAutoFocus={handleDropdownCloseAutoFocus} > - event.preventDefault()} - > - View - - {canShowActions && ( <> - {isMobile && templateNav.total > 0 && ( <> + + )} + event.preventDefault()} + > + View + + + {canShowActions && ( + <> + setIsDeleteDialogOpen(true)}