fix(webui,core): center breadcrumb menu on chevron and fix proxy download filename (#417)

This commit is contained in:
Yiling-J
2026-09-18 23:14:54 +08:00
committed by GitHub
parent a91d8c4521
commit 145aa6bfb4
5 changed files with 125 additions and 14 deletions
+5
View File
@@ -12,6 +12,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- **release**: Automatically populate GitHub release bodies from CHANGELOG.md and promote unreleased notes during version bumps
- **settings**: Add FFmpeg threads slider to team media processing settings
### Fixed
- **asset**: Fix proxy download filename using original file extension instead of proxy extension
- **webui**: Center breadcrumb file action popup menu on the chevron icon
## [0.4.6] - 2026-09-17
### Added
+47 -1
View File
@@ -3116,7 +3116,53 @@ describe('AssetService — natural sort by name', () => {
'files/01TESTULID000000000000000/test-720p.mp4',
'GET',
true,
'test.mp4',
'test-720p.mp4',
)
})
it('downloading video proxy for test.mov should use proxy filename with mp4 extension instead of test.mov', async () => {
const asset = await prisma.asset.create({
data: {
name: 'test.mov',
type: AssetType.file,
status: AssetStatus.uploaded,
storageKey: {
create: { key: 'files/01TESTULID000000000000000/test.mov' },
},
},
})
await assetService.getDownloadUrl(asset.id, 'files/01TESTULID000000000000000/test-1080p.mp4')
expect(s3Service.presign).toHaveBeenCalledWith(
expect.any(String),
'files/01TESTULID000000000000000/test-1080p.mp4',
'GET',
true,
'test-1080p.mp4',
)
})
it('downloading proxy for a renamed asset should preserve new stem with proxy resolution and extension', async () => {
const asset = await prisma.asset.create({
data: {
name: 'awesome.mov',
type: AssetType.file,
status: AssetStatus.uploaded,
storageKey: {
create: { key: 'files/01TESTULID000000000000000/test.mov' },
},
},
})
await assetService.getDownloadUrl(asset.id, 'files/01TESTULID000000000000000/test-1080p.mp4')
expect(s3Service.presign).toHaveBeenCalledWith(
expect.any(String),
'files/01TESTULID000000000000000/test-1080p.mp4',
'GET',
true,
'awesome-1080p.mp4',
)
})
+36 -8
View File
@@ -46,6 +46,8 @@ import { getAgentRequiredLevel, getRoleLevel } from '@shumai/core/src/agent/perm
import { resolveEffectiveRole } from '@shumai/core/src/authz/authz'
import { metadataService } from '@shumai/core/src/metadata/metadata'
import { uploadService } from '@shumai/core/src/upload/upload'
import path from 'path'
import { stemFromKey } from '@shumai/core/src/utils/filename'
export const assetInclude = {
creator: true,
@@ -2594,6 +2596,7 @@ export class AssetService {
let storageKey = asset.storageKey.key
let assetDir = storageKey.substring(0, storageKey.lastIndexOf('/') + 1)
let targetName = asset.name
if (!key.startsWith(assetDir) && asset.parentId) {
// Check if requested key belongs to another version in the same version stack
@@ -2603,11 +2606,14 @@ export class AssetService {
isDeleted: false,
storageKey: { key: { startsWith: key.substring(0, key.lastIndexOf('/') + 1) } },
},
select: { storageKey: { select: { key: true } } },
select: { name: true, storageKey: { select: { key: true } } },
})
if (sibling?.storageKey?.key) {
storageKey = sibling.storageKey.key
assetDir = storageKey.substring(0, storageKey.lastIndexOf('/') + 1)
if (sibling.name) {
targetName = sibling.name
}
}
}
@@ -2615,13 +2621,35 @@ export class AssetService {
throw new Error('Key does not belong to this asset')
}
return s3Service.presign(
process.env.S3_BUCKET || 'shumai',
key,
'GET',
true,
asset.name ?? undefined,
)
let downloadFilename: string | undefined
if (key === storageKey) {
downloadFilename = targetName ?? undefined
} else {
const keyBasename = path.posix.basename(key)
const originalStem = stemFromKey(storageKey)
const assetStem = targetName ? stemFromKey(targetName) : originalStem
if (
originalStem &&
assetStem &&
originalStem !== assetStem &&
keyBasename.startsWith(originalStem + '-')
) {
downloadFilename = assetStem + keyBasename.slice(originalStem.length)
} else if (
originalStem &&
assetStem &&
originalStem !== assetStem &&
keyBasename.startsWith('watermark-' + originalStem + '-')
) {
downloadFilename =
'watermark-' + assetStem + keyBasename.slice(('watermark-' + originalStem).length)
} else {
downloadFilename = keyBasename
}
}
return s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET', true, downloadFilename)
}
async toPreviewInfo(
@@ -144,4 +144,20 @@ describe('BreadcrumbNav component', () => {
expect(container.querySelector('.lucide-bot')).toBeNull()
})
it('renders file actions dropdown trigger button and opens on click', () => {
render(
<QueryClientProvider client={queryClient}>
<BreadcrumbNav
{...baseProps}
fileId="file-1"
currentAsset={{ id: 'file-1', name: 'sample.mov', type: 'file', version: 1 }}
allowDownload={true}
/>
</QueryClientProvider>,
)
const triggerButton = screen.getByRole('button', { name: 'sample.mov' })
expect(triggerButton).toBeDefined()
})
})
+21 -5
View File
@@ -133,6 +133,7 @@ export function BreadcrumbNav({
const { openMobileMenu } = useDualSidebarStore()
const [isManageVersionsOpen, setIsManageVersionsOpen] = useState(false)
const [isLinkedTasksOpen, setIsLinkedTasksOpen] = useState(false)
const [isFileMenuOpen, setIsFileMenuOpen] = useState(false)
const targetAssetId = fileId || currentAsset.id
const isRecentlyDeleted = currentAsset.name === 'Recently Deleted'
@@ -249,17 +250,32 @@ export function BreadcrumbNav({
}
return (
<DropdownMenu modal={false}>
<DropdownMenuTrigger className="flex items-center gap-1 truncate rounded px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground">
<DropdownMenu modal={false} open={isFileMenuOpen} onOpenChange={setIsFileMenuOpen}>
<div
className="flex items-center gap-1 truncate rounded px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground cursor-pointer select-none"
onClick={() => setIsFileMenuOpen((prev) => !prev)}
>
<span className="truncate">{currentAsset.name}</span>
{currentAsset.version !== undefined && (
<Badge variant="outline" className="px-1 py-0 text-xs shrink-0">
v{currentAsset.version}
</Badge>
)}
<ChevronDown className="h-4 w-4 shrink-0" />
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56" align="start">
<DropdownMenuTrigger
asChild
onClick={(e) => e.stopPropagation()}
onPointerDown={(e) => e.stopPropagation()}
>
<button
type="button"
aria-label={currentAsset.name}
className="flex items-center justify-center p-0.5 rounded shrink-0 focus:outline-none"
>
<ChevronDown className="h-4 w-4 shrink-0" />
</button>
</DropdownMenuTrigger>
</div>
<DropdownMenuContent className="w-56" align="center">
{allowDownload &&
(hasVideoTranscodes ? (
<DropdownMenuSub>