This commit is contained in:
xds
2026-02-06 18:50:21 +03:00
parent fb701911d7
commit 86646ff8e5
2 changed files with 63 additions and 45 deletions

View File

@@ -420,13 +420,22 @@ const reusePrompt = (gen) => {
}
const reuseAsset = (gen) => {
if (gen.input_assets && Array.isArray(gen.input_assets)) {
selectedAssets.value = gen.input_assets.map(id => ({
const assetIds = gen.assets_list || gen.input_assets || []
if (assetIds && assetIds.length > 0) {
selectedAssets.value = assetIds.map(id => {
// Check if we have it in characterAssets
const existing = characterAssets.value.find(a => a.id === id)
if (existing) return existing
return {
id,
url: `/assets/${id}`
}))
url: `/assets/${id}`,
name: 'Asset ' + id.substring(0, 6)
}
})
} else {
console.warn("Input assets not found in history object:", gen)
console.warn("No linked/input assets found in history object:", gen)
}
}

View File

@@ -383,21 +383,30 @@ const reuseAsset = (gen) => {
// Attempt to access input assets if available, otherwise warn or try to fetch.
// NOTE: In many systems, the input assets are stored in metadata.
if (gen.input_assets && Array.isArray(gen.input_assets)) {
selectedAssets.value = gen.input_assets.map(id => ({
id,
url: `/assets/${id}` // Construct URL
}))
} else {
// Fallback or todo: Backend might need to provide `input_assets` in history.
// For now, let's toast or log.
console.warn("Input assets not found in history object:", gen)
// If the user meant the generated asset (the prompt is slightly ambiguous "associated asset" vs "result"),
// but point 3 is explicitly "use result".
}
}
const reuseAsset = (gen) => {
// Try to find input assets field from history object
// We check linked_assets or input_assets, and fallback to empty array if not found
const assetIds = gen.linked_assets || gen.input_assets || []
const useResultAsReference = (gen) => {
if (assetIds && assetIds.length > 0) {
selectedAssets.value = assetIds.map(id => {
// Check if we already have the full asset object loaded to get the name/type
const existing = allAssets.value.find(a => a.id === id)
if (existing) return existing
// Fallback: Construct object to display thumbnail
return {
id,
url: `/assets/${id}`,
name: 'Asset ' + id.substring(0, 6) // Placeholder name
}
})
} else {
console.warn("No linked/input assets found in history object:", gen)
}
}
const useResultAsReference = (gen) => {
if (gen.assets_list && gen.assets_list.length > 0) {
// Appends the generated assets to the selection
const newAssets = gen.assets_list.map(id => ({
@@ -413,23 +422,23 @@ const useResultAsReference = (gen) => {
}
})
}
}
}
// --- Utils ---
// --- Utils ---
const copyToClipboard = () => {
const copyToClipboard = () => {
// Implement if needed for prompt copying
}
}
const handleLogout = () => {
const handleLogout = () => {
localStorage.removeItem('auth_code')
router.push('/login')
}
}
// --- Lifecycle ---
onMounted(() => {
// --- Lifecycle ---
onMounted(() => {
loadHistory()
})
})
</script>
<template>