Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/areas/workflows/workflowRunStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { create } from 'zustand'
import axios, { AxiosInstance } from 'axios'
import { useAppStore } from '@shared/stores/appStore'
import { getWorkflowExtension } from './mockExtensions'
import { playCompletionSound } from '@shared/utils/sound'
import type { WorkflowExtension } from './mockExtensions'
import type { Workflow, WFNode, WFEdge } from '@shared/types/electron.d'
import { isBranchStarter, isSceneOutput, resolveDataSource, reachesSceneOutput, nearestUpstreamWaits } from './nodeBehaviors'
Expand Down Expand Up @@ -392,6 +393,7 @@ export const useWorkflowRunStore = create<WorkflowRunStore>((set, get) => {
},
}))
useAppStore.getState().updateCurrentJob({ status: 'done', progress: 100, outputUrl })
playCompletionSound()
}

return {
Expand Down
2 changes: 2 additions & 0 deletions src/shared/hooks/useGeneration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useRef } from 'react'
import { useAppStore } from '@shared/stores/appStore'
import { useApi } from './useApi'
import { playCompletionSound } from '@shared/utils/sound'

export function useGeneration() {
const { currentJob, setCurrentJob, updateCurrentJob, generationOptions, selectedImageData, pushMeshUrl, clearMeshHistory } = useAppStore()
Expand Down Expand Up @@ -77,6 +78,7 @@ export function useGeneration() {
if (result.status === 'done') {
updateCurrentJob({ status: 'done', progress: 100, outputUrl: result.outputUrl, originalOutputUrl: result.outputUrl })
if (result.outputUrl) pushMeshUrl(result.outputUrl)
playCompletionSound()
break
}

Expand Down
17 changes: 17 additions & 0 deletions src/shared/utils/sound.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export function playCompletionSound() {
try {
const ctx = new AudioContext()
const oscillator = ctx.createOscillator()
const gain = ctx.createGain()
oscillator.connect(gain)
gain.connect(ctx.destination)
oscillator.type = 'sine'
oscillator.frequency.setValueAtTime(880, ctx.currentTime)
gain.gain.setValueAtTime(0.3, ctx.currentTime)
gain.gain.exponentialRampToValueAtTime(0.01, ctx.currentTime + 0.3)
oscillator.start(ctx.currentTime)
oscillator.stop(ctx.currentTime + 0.3)
} catch {
// Audio not available
}
}