mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 02:58:19 +00:00
* feat(agent): add nested agents.md support across backend and webui * fix(webui): update agentsmd route paths and unnest folder agentsmd route * fix(agent): flush agents.md autosave on close and address review feedback - Flush pending debounced AGENTS.md autosave on close/unmount so edits made within 750ms of navigating away are no longer silently lost - Serialize autosaves through a promise chain so an older in-flight request can never overwrite newer content on the server - Internationalize the hardcoded "Failed to save" and "Loading AGENTS.md..." strings (en + zh) - Validate that AGENTS.md is only stored on folder/root assets in AssetService, preventing bogus virtual paths for file assets - Cap updateAgentsMd content at 100k chars via Zod validation - Remove unused getAgentsMd/updateAgentsMd response DTO schemas - Drop unused teamId prop from AgentsMdEditor - Add tests: non-folder asset rejection, oversized content 400, and agent-chat workflow assetId passthrough * refactor(db): isolate AGENTS.md content in dedicated 1:1 AssetAgentMd table * style(webui): unify top bar button hover styles and add wand icon to agentsmd button * style(webui): update agentsmd button state colors and remove presence dot * fix(webui): fix close button overflow and stabilize debounced autosave in agentsmd editor * fix(webui): update debounce to 1s and await pending save before closing agentsmd editor * feat(webui): add terminal AGENTS.md breadcrumb on agentsmd editor page * fix(webui): use ScrollArea for markdown editor scrolling
144 lines
4.5 KiB
TypeScript
144 lines
4.5 KiB
TypeScript
import { useTopNavStore } from '@/ui/stores/top-nav'
|
|
import { BreadcrumbNav } from './breadcrumb-nav'
|
|
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
|
import { useUiStore } from '@/ui/stores/ui'
|
|
import { useChatbotStore } from '@/ui/stores/chatbot'
|
|
|
|
export function TopNav() {
|
|
const { projectState } = useTopNavStore()
|
|
const uiStore = useUiStore()
|
|
const { isChatbotOpen, setIsChatbotOpen } = useChatbotStore()
|
|
|
|
if (!projectState) {
|
|
return <TeamHeader />
|
|
}
|
|
|
|
const {
|
|
teamId,
|
|
projectId,
|
|
projectName,
|
|
ancestorFolders,
|
|
currentAsset,
|
|
isRootFolder,
|
|
customTerminalBreadcrumb,
|
|
fileId,
|
|
downloadInfo,
|
|
versions,
|
|
isPublic,
|
|
shareId,
|
|
allowDownload,
|
|
onFolderClick,
|
|
onRename,
|
|
onDelete,
|
|
compareMode,
|
|
canCompareVersions,
|
|
onCompareVersions,
|
|
} = projectState
|
|
|
|
const isFileView = !!fileId
|
|
const isAgentsMd = !!customTerminalBreadcrumb
|
|
|
|
const isShareConfig = !!shareId && !isFileView
|
|
|
|
const isLeftSidebarCollapsed = isFileView
|
|
? uiStore.fileViewLeftSidebarCollapsed
|
|
: isShareConfig
|
|
? uiStore.shareConfigLeftSidebarCollapsed
|
|
: uiStore.fileListLeftSidebarCollapsed
|
|
const onLeftSidebarToggle = isPublic
|
|
? undefined
|
|
: () =>
|
|
isFileView
|
|
? uiStore.setFileViewLeftSidebarCollapsed(!uiStore.fileViewLeftSidebarCollapsed)
|
|
: isShareConfig
|
|
? uiStore.setShareConfigLeftSidebarCollapsed(!uiStore.shareConfigLeftSidebarCollapsed)
|
|
: uiStore.setFileListLeftSidebarCollapsed(!uiStore.fileListLeftSidebarCollapsed)
|
|
|
|
const isRightSidebarCollapsed =
|
|
isPublic && projectState.isRightSidebarCollapsed !== undefined
|
|
? projectState.isRightSidebarCollapsed
|
|
: isFileView
|
|
? uiStore.fileViewRightSidebarCollapsed
|
|
: isShareConfig
|
|
? uiStore.shareConfigRightSidebarCollapsed
|
|
: uiStore.fileListRightSidebarCollapsed
|
|
const onRightSidebarToggle =
|
|
isPublic && projectState.onRightSidebarToggle
|
|
? projectState.onRightSidebarToggle
|
|
: () => {
|
|
if (!isPublic && isChatbotOpen) {
|
|
setIsChatbotOpen(false)
|
|
if (isFileView) {
|
|
uiStore.setFileViewRightSidebarCollapsed(false)
|
|
} else if (isShareConfig) {
|
|
uiStore.setShareConfigRightSidebarCollapsed(false)
|
|
} else {
|
|
uiStore.setFileListRightSidebarCollapsed(false)
|
|
}
|
|
} else {
|
|
if (isFileView) {
|
|
uiStore.setFileViewRightSidebarCollapsed(!uiStore.fileViewRightSidebarCollapsed)
|
|
} else if (isShareConfig) {
|
|
uiStore.setShareConfigRightSidebarCollapsed(!uiStore.shareConfigRightSidebarCollapsed)
|
|
} else {
|
|
uiStore.setFileListRightSidebarCollapsed(!uiStore.fileListRightSidebarCollapsed)
|
|
}
|
|
}
|
|
}
|
|
|
|
const onChatbotToggle = isPublic
|
|
? undefined
|
|
: () => {
|
|
setIsChatbotOpen(!isChatbotOpen)
|
|
}
|
|
|
|
const displayStyle = projectId ? (uiStore.viewModes[projectId] ?? 'card') : 'card'
|
|
const onDisplayStyleChange = isPublic
|
|
? undefined
|
|
: (style: 'card' | 'list') => {
|
|
if (projectId) uiStore.setViewMode(projectId, style)
|
|
}
|
|
|
|
return (
|
|
<BreadcrumbNav
|
|
teamId={teamId}
|
|
projectId={projectId}
|
|
projectName={projectName}
|
|
ancestorFolders={ancestorFolders}
|
|
currentAsset={currentAsset}
|
|
isRootFolder={isRootFolder}
|
|
customTerminalBreadcrumb={customTerminalBreadcrumb}
|
|
displayStyle={isFileView || isShareConfig || isAgentsMd ? undefined : displayStyle}
|
|
onDisplayStyleChange={
|
|
isFileView || isShareConfig || isAgentsMd ? undefined : onDisplayStyleChange
|
|
}
|
|
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
|
onLeftSidebarToggle={onLeftSidebarToggle}
|
|
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
|
onRightSidebarToggle={onRightSidebarToggle}
|
|
isChatbotOpen={!isPublic && isChatbotOpen}
|
|
onChatbotToggle={onChatbotToggle}
|
|
isPublic={isPublic}
|
|
shareId={shareId}
|
|
allowDownload={allowDownload}
|
|
fileId={fileId}
|
|
downloadInfo={downloadInfo}
|
|
versions={versions}
|
|
onFolderClick={onFolderClick}
|
|
onRename={onRename}
|
|
onDelete={onDelete}
|
|
compareMode={compareMode}
|
|
canCompareVersions={canCompareVersions}
|
|
onCompareVersions={onCompareVersions}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function TeamHeader() {
|
|
return (
|
|
<div className="flex h-14 flex-wrap items-center justify-center gap-2 border-b border-border bg-card px-4 py-2 flex-shrink-0">
|
|
<ShumaiLogo className="w-10 h-10 text-orange-600" />
|
|
</div>
|
|
)
|
|
}
|