From aa72c522c2f04a88047af8ac4c14a6fa69170f2c Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Wed, 5 Aug 2026 10:00:16 +0800 Subject: [PATCH] feat(frontend): implement SectionAnchorTabs for improved navigation - Replaced the existing navigation in PromptEditor and PanelAnchorNavigation with the new SectionAnchorTabs component for better code reuse and consistency. - The SectionAnchorTabs component provides a shared interface for section navigation with equal-width columns and an active state indicator. --- .../assistant-editor/prompt-editor.tsx | 42 ++++------ .../components/editor/section-anchor-tabs.tsx | 78 +++++++++++++++++++ .../workflow/panels/PanelAnchorNavigation.tsx | 36 +++------ 3 files changed, 100 insertions(+), 56 deletions(-) create mode 100644 frontend/src/components/editor/section-anchor-tabs.tsx diff --git a/frontend/src/components/assistant-editor/prompt-editor.tsx b/frontend/src/components/assistant-editor/prompt-editor.tsx index ac87add..08a5474 100644 --- a/frontend/src/components/assistant-editor/prompt-editor.tsx +++ b/frontend/src/components/assistant-editor/prompt-editor.tsx @@ -30,6 +30,7 @@ import { ToolPicker, } from "@/components/assistant-editor/editor-controls"; import type { AssistantForm } from "@/components/assistant-editor/types"; +import { SectionAnchorTabs } from "@/components/editor/section-anchor-tabs"; import { SectionCard } from "@/components/editor/section-card"; import { VisionConfigSection } from "@/components/editor/vision-config-section"; import { TurnConfigEditor } from "@/components/turn-config-editor"; @@ -315,35 +316,18 @@ export function PromptEditor({ className="flex h-full min-h-0 overflow-hidden bg-background" >
- + + scrollToSection(sectionId as PromptSectionId) + } + className="bg-background px-4 pt-3 sm:px-6 sm:pt-4 lg:px-8" + contentClassName={ + debugOpen ? "w-full" : "mx-auto w-full max-w-7xl" + } + />
void; + className?: string; + /** Optional width/centering wrapper around the tab row (prompt page uses max-w-7xl). */ + contentClassName?: string; +}) { + if (sections.length === 0) return null; + + const list = ( +
+ {sections.map((section) => { + const active = activeSectionId === section.id; + + return ( + + ); + })} +
+ ); + + return ( + + ); +} diff --git a/frontend/src/components/workflow/panels/PanelAnchorNavigation.tsx b/frontend/src/components/workflow/panels/PanelAnchorNavigation.tsx index 0294dd0..c3922fa 100644 --- a/frontend/src/components/workflow/panels/PanelAnchorNavigation.tsx +++ b/frontend/src/components/workflow/panels/PanelAnchorNavigation.tsx @@ -3,6 +3,8 @@ import type { ReactNode } from "react"; import { useEffect, useRef, useState } from "react"; +import { SectionAnchorTabs } from "@/components/editor/section-anchor-tabs"; + export type PanelAnchorSection = { id: string; label: string; @@ -128,33 +130,13 @@ export function PanelAnchorNavigation({ return (
{sections.length > 1 && ( - + )}