Files
shumai/packages/webui/stores/top-nav.ts
T
Yiling-J dd0ea05a88 feat(asset): record and display agent provenance on assets and audit logs (#380)
* feat(asset): record and display agent provenance on assets and audit logs

* style(webui): apply 30% translucent frosted glass background to bot badges

* style(webui): match bot icon badge style to thumbnail media overlay (bg-black/60 text-white)

* style(webui): use "AI" text badge with pdf overlay style instead of bot icon
2026-09-04 11:27:52 +08:00

76 lines
1.9 KiB
TypeScript

import { create } from 'zustand'
import type { AncestorFolder } from '@shumai/dtos'
export interface TopNavProjectState {
teamId: string
projectId: string
projectName: string
rootFolderId?: string
ancestorFolders: AncestorFolder[]
currentAsset: {
id?: string
name?: string
type: 'file' | 'folder'
version?: number
proxyType?: 'image' | 'video' | 'audio' | 'pdf' | null
}
isRootFolder: boolean
customTerminalBreadcrumb?: string
fileId?: string
downloadInfo?: {
originalKey?: string
videoTranscodes?: Array<{
key: string
width: number
height: number
}>
}
versions?: Array<{
id: string
version: number
name?: string | null
previewUrl?: string | null
creator?: { id: string; name: string | null } | null
agent?: { id: string; name: string } | null
}>
isPublic?: boolean
shareId?: string
/** When false, the public share hides download affordances. Defaults to true. */
allowDownload?: boolean
onFolderClick?: (folderId: string) => void
onRename?: () => void
onDelete?: () => void
isRightSidebarCollapsed?: boolean
onRightSidebarToggle?: () => void
// Compare Versions
compareMode?: boolean
canCompareVersions?: boolean
onCompareVersions?: () => void
}
interface TopNavStore {
projectState: TopNavProjectState | null
setProjectState: (state: TopNavProjectState | null) => void
clearProjectState: () => void
}
let timeoutId: ReturnType<typeof setTimeout> | null = null
export const useTopNavStore = create<TopNavStore>((set) => ({
projectState: null,
setProjectState: (state) => {
if (timeoutId) {
clearTimeout(timeoutId)
timeoutId = null
}
set({ projectState: state })
},
clearProjectState: () => {
if (timeoutId) clearTimeout(timeoutId)
timeoutId = setTimeout(() => {
set({ projectState: null })
timeoutId = null
}, 10) // Small debounce to prevent flicker during transitions
},
}))