Skip to content

enhancement(transcriber/frontend): extract file download blob pattern into useFileDownload() composable #9204

Closed

Description

@mrveiss

Summary

ExportMenu.vue:21–38 implements a blob-to-file download pattern (fetch blob → createObjectURL → click → revokeObjectURL) inline. This pattern is likely to be needed elsewhere and should be a shared composable.

Current Code (ExportMenu.vue:21–38)

const blob = await resp.blob()
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `${props.filename}.${format}`
a.click()
URL.revokeObjectURL(url)

Fix

Create autobot-frontend/src/composables/useFileDownload.ts:

export function useFileDownload() {
  function download(blob: Blob, filename: string) {
    const url = URL.createObjectURL(blob)
    const a = document.createElement('a')
    a.href = url; a.download = filename; a.click()
    URL.revokeObjectURL(url)
  }
  return { download }
}

Check existing composables to confirm no equivalent already exists before implementing.

Part of #9044.

Activity

  1. self-assigned this
    on Jun 4, 2026
  2. mrveiss commented on Jun 5, 2026

    @mrveiss
    OwnerAuthor

    ✅ Implemented in commit c7a6980f2

    Created autobot-frontend/src/composables/useFileDownload.ts with:

    • download(blob, filename) - core download function
    • downloadText(content, filename, mimeType?) - convenience wrapper

    Refactored ExportMenu.vue to use the composable, reducing inline code from 7 lines to 1.

    Additional candidates for future refactoring (out of scope for this issue):

    • DocumentExportModal.vue
    • useEvolution.ts
    • useConversationFiles.ts
    • useCodebaseExport.ts
    • useAuditApi.ts

    Part of #9044.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions