refactor: type event emitter payloads

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-Claude)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
zhsama
2026-01-31 00:00:09 +08:00
parent f880ef0052
commit 473262d70e
6 changed files with 9 additions and 8 deletions

View File

@ -61,7 +61,7 @@ const InstructionEditor: FC<Props> = ({
)
const handleInsertVariable = () => {
eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId: editorKey } as any)
eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId: editorKey })
}
return (

View File

@ -157,7 +157,7 @@ const Editor: FC<Props> = ({
const handleInsertVariable = () => {
setFocus()
eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId } as any)
eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId })
}
const getVarType = useWorkflowVariableType()

View File

@ -143,7 +143,7 @@ const Right: FC<Props> = ({
type: PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER,
instanceId: `${nodeId}-chat-workflow-llm-prompt-editor`,
payload: res.modified,
} as any)
})
handleHidePromptGenerator()
}, [setInputs, blockType, nodeId, node?.data, handleHidePromptGenerator])

View File

@ -49,7 +49,7 @@ const VariableInspectTrigger: FC = () => {
const handleStop = () => {
eventEmitter?.emit({
type: EVENT_WORKFLOW_STOP,
} as any)
})
}
const handleClearAll = () => {

View File

@ -127,8 +127,7 @@ const VariablesTab: FC<InspectHeaderProps> = (headerProps) => {
const { eventEmitter } = useEventEmitterContextContext()
const onStopListening = useCallback(() => {
// eslint-disable-next-line ts/no-explicit-any -- EventEmitter is typed as string but project-wide convention passes { type } objects
eventEmitter?.emit({ type: EVENT_WORKFLOW_STOP } as any)
eventEmitter?.emit({ type: EVENT_WORKFLOW_STOP })
}, [eventEmitter])
useEffect(() => {

View File

@ -4,7 +4,9 @@ import type { EventEmitter } from 'ahooks/lib/useEventEmitter'
import { useEventEmitter } from 'ahooks'
import { createContext, useContext } from 'use-context-selector'
const EventEmitterContext = createContext<{ eventEmitter: EventEmitter<string> | null }>({
export type EventPayload = string | ({ type: string } & Record<string, unknown>)
const EventEmitterContext = createContext<{ eventEmitter: EventEmitter<EventPayload> | null }>({
eventEmitter: null,
})
@ -16,7 +18,7 @@ type EventEmitterContextProviderProps = {
export const EventEmitterContextProvider = ({
children,
}: EventEmitterContextProviderProps) => {
const eventEmitter = useEventEmitter<string>()
const eventEmitter = useEventEmitter<EventPayload>()
return (
<EventEmitterContext.Provider value={{ eventEmitter }}>