Skip to content

Commit 9ef6f94

Browse files
[fix] Enable AUDIO_RECORD widget in both LiteGraph and Vue nodes modes (#6094)
Fixed the AUDIO_RECORD widget to display correctly in both rendering modes: - Removed conflicting AUDIO_RECORD registration from ComfyWidgets that was blocking the custom widget implementation in uploadAudio.ts extension - Changed canvasOnly flags from true to false on both audioUIWidget and recordWidget to enable Vue nodes rendering - Added type override (recordWidget.type = 'audiorecord') after widget creation to enable Vue component lookup while preserving LiteGraph button rendering - Removed unused IAudioRecordWidget type definition The widget now works correctly: - LiteGraph mode: Displays as a functional button - Vue nodes mode: Displays full recording UI with waveform visualization ## Summary <!-- One sentence describing what changed and why. --> ## Changes - **What**: <!-- Core functionality added/modified --> - **Breaking**: <!-- Any breaking changes (if none, remove this line) --> - **Dependencies**: <!-- New dependencies (if none, remove this line) --> ## Review Focus <!-- Critical design decisions or edge cases that need attention --> <!-- If this PR fixes an issue, uncomment and update the line below --> <!-- Fixes #ISSUE_NUMBER --> ## Screenshots (if applicable) <!-- Add screenshots or video recording to help explain your changes --> https://github.com/user-attachments/assets/cf6513d4-0a4b-4210-88e2-a948855b5206 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6094-fix-Enable-AUDIO_RECORD-widget-in-both-LiteGraph-and-Vue-nodes-modes-28e6d73d365081faa879f53e3e2dddad) by [Unito](https://www.unito.io) --------- Co-authored-by: bymyself <[email protected]>
1 parent 598d170 commit 9ef6f94

File tree

7 files changed

+33
-44
lines changed

7 files changed

+33
-44
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect } from '@playwright/test'
2+
3+
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
4+
5+
test.beforeEach(async ({ comfyPage }) => {
6+
await comfyPage.setSetting('Comfy.UseNewMenu', 'Disabled')
7+
})
8+
9+
test.describe('Record Audio Node', () => {
10+
test('should add a record audio node and take a screenshot', async ({
11+
comfyPage
12+
}) => {
13+
// Open the search box by double clicking on the canvas
14+
await comfyPage.doubleClickCanvas()
15+
await expect(comfyPage.searchBox.input).toHaveCount(1)
16+
17+
// Search for and add the RecordAudio node
18+
await comfyPage.searchBox.fillAndSelectFirstNode('RecordAudio')
19+
await comfyPage.nextFrame()
20+
21+
// Verify the RecordAudio node was added
22+
const recordAudioNodes = await comfyPage.getNodeRefsByType('RecordAudio')
23+
expect(recordAudioNodes.length).toBe(1)
24+
25+
// Take a screenshot of the canvas with the RecordAudio node
26+
await expect(comfyPage.canvas).toHaveScreenshot('record_audio_node.png')
27+
})
28+
})
100 KB
Loading

src/extensions/core/uploadAudio.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ app.registerExtension({
253253
audio.setAttribute('name', 'media')
254254
const audioUIWidget: DOMWidget<HTMLAudioElement, string> =
255255
node.addDOMWidget(inputName, /* name=*/ 'audioUI', audio)
256-
audioUIWidget.options.canvasOnly = true
256+
audioUIWidget.options.canvasOnly = false
257257

258258
let mediaRecorder: MediaRecorder | null = null
259259
let isRecording = false
@@ -376,10 +376,12 @@ app.registerExtension({
376376
mediaRecorder.stop()
377377
}
378378
},
379-
{ serialize: false, canvasOnly: true }
379+
{ serialize: false, canvasOnly: false }
380380
)
381381

382382
recordWidget.label = t('g.startRecording')
383+
// Override the type for Vue rendering while keeping 'button' for LiteGraph
384+
recordWidget.type = 'audiorecord'
383385

384386
const originalOnRemoved = node.onRemoved
385387
node.onRemoved = function () {

src/lib/litegraph/src/types/widgets.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export type IWidget =
7979
| ISelectButtonWidget
8080
| ITextareaWidget
8181
| IAssetWidget
82-
| IAudioRecordWidget
8382

8483
export interface IBooleanWidget extends IBaseWidget<boolean, 'toggle'> {
8584
type: 'toggle'
@@ -228,11 +227,6 @@ export interface ITextareaWidget extends IBaseWidget<string, 'textarea'> {
228227
value: string
229228
}
230229

231-
export interface IAudioRecordWidget extends IBaseWidget<string, 'audiorecord'> {
232-
type: 'audiorecord'
233-
value: string
234-
}
235-
236230
export interface IAssetWidget
237231
extends IBaseWidget<string, 'asset', IWidgetOptions<string[]>> {
238232
type: 'asset'

src/renderer/extensions/vueNodes/widgets/composables/useAudioRecordWidget.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/schemas/nodeDef/nodeDefSchemaV2.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,6 @@ const zTextareaInputSpec = zBaseInputOptions.extend({
152152
.optional()
153153
})
154154

155-
const zAudioRecordInputSpec = zBaseInputOptions.extend({
156-
type: z.literal('AUDIORECORD'),
157-
name: z.string(),
158-
isOptional: z.boolean().optional(),
159-
options: z.record(z.unknown()).optional()
160-
})
161-
162155
const zCustomInputSpec = zBaseInputOptions.extend({
163156
type: z.string(),
164157
name: z.string(),
@@ -174,7 +167,6 @@ const zInputSpec = z.union([
174167
zColorInputSpec,
175168
zFileUploadInputSpec,
176169
zImageInputSpec,
177-
zAudioRecordInputSpec,
178170
zImageCompareInputSpec,
179171
zMarkdownInputSpec,
180172
zTreeSelectInputSpec,
@@ -230,7 +222,6 @@ export type GalleriaInputSpec = z.infer<typeof zGalleriaInputSpec>
230222
export type SelectButtonInputSpec = z.infer<typeof zSelectButtonInputSpec>
231223
export type TextareaInputSpec = z.infer<typeof zTextareaInputSpec>
232224
export type CustomInputSpec = z.infer<typeof zCustomInputSpec>
233-
export type AudioRecordInputSpec = z.infer<typeof zAudioRecordInputSpec>
234225

235226
export type InputSpec = z.infer<typeof zInputSpec>
236227
export type OutputSpec = z.infer<typeof zOutputSpec>

src/scripts/widgets.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {
66
IStringWidget
77
} from '@/lib/litegraph/src/types/widgets'
88
import { useSettingStore } from '@/platform/settings/settingStore'
9-
import { useAudioRecordWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useAudioRecordWidget'
109
import { useBooleanWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget'
1110
import { useChartWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useChartWidget'
1211
import { useColorWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useColorWidget'
@@ -305,6 +304,5 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
305304
CHART: transformWidgetConstructorV2ToV1(useChartWidget()),
306305
GALLERIA: transformWidgetConstructorV2ToV1(useGalleriaWidget()),
307306
SELECTBUTTON: transformWidgetConstructorV2ToV1(useSelectButtonWidget()),
308-
TEXTAREA: transformWidgetConstructorV2ToV1(useTextareaWidget()),
309-
AUDIO_RECORD: transformWidgetConstructorV2ToV1(useAudioRecordWidget())
307+
TEXTAREA: transformWidgetConstructorV2ToV1(useTextareaWidget())
310308
}

0 commit comments

Comments
 (0)