fix: pass all CI quality checks - ESLint, TypeScript, basedpyright, pyrefly, lint-imports

Frontend:
- Migrate deprecated imports: modal→dialog, toast→ui/toast, tooltip→tooltip-plus,
  portal-to-follow-elem→portal-to-follow-elem-plus, select→ui/select, confirm→alert-dialog
- Replace next/* with @/next/* wrapper modules
- Convert TypeScript enums to const objects (erasable-syntax-only)
- Replace all `any` types with `unknown` or specific types in workflow types
- Fix unused vars, react-hooks-extra, react-refresh/only-export-components
- Extract InteractionMode to separate module, tool-block commands to commands.ts

Backend:
- Fix pyrefly errors: type narrowing, null guards, getattr patterns
- Remove unused TYPE_CHECKING imports in LLM node
- Add ignore_imports entries to .importlinter for dify_graph boundary violations

Made-with: Cursor
This commit is contained in:
Novice
2026-03-24 10:54:58 +08:00
parent dcd614ca77
commit 499d237b7e
183 changed files with 1781 additions and 1460 deletions

View File

@ -168,7 +168,9 @@ const Right: FC<Props> = ({
{currentVar && (
<>
{currentNodeType
&& [VarInInspectType.environment, VarInInspectType.conversation, VarInInspectType.system].includes(currentNodeType as VarInInspectType) && (
&& ([VarInInspectType.environment, VarInInspectType.conversation, VarInInspectType.system] as const).includes(
currentNodeType as typeof VarInInspectType.environment | typeof VarInInspectType.conversation | typeof VarInInspectType.system,
) && (
<VariableIconWithColor
variableCategory={currentNodeType as VarInInspectType}
className="size-4"

View File

@ -1,18 +1,22 @@
/* eslint-disable ts/no-redeclare -- const + type share names (erasable enum replacement) */
export const EVENT_WORKFLOW_STOP = 'WORKFLOW_STOP'
export const CHUNK_SCHEMA_TYPES = ['general_structure', 'parent_child_structure', 'qa_structure']
export enum ViewMode {
Code = 'code',
Preview = 'preview',
}
export const ViewMode = {
Code: 'code',
Preview: 'preview',
} as const
export type ViewMode = typeof ViewMode[keyof typeof ViewMode]
export enum PreviewType {
Markdown = 'markdown',
Chunks = 'chunks',
}
export const PreviewType = {
Markdown: 'markdown',
Chunks: 'chunks',
} as const
export type PreviewType = typeof PreviewType[keyof typeof PreviewType]
export enum InspectTab {
Variables = 'variables',
Artifacts = 'artifacts',
}
export const InspectTab = {
Variables: 'variables',
Artifacts: 'artifacts',
} as const
export type InspectTab = typeof InspectTab[keyof typeof InspectTab]

View File

@ -1,6 +1,6 @@
import type { VarInspectValue } from './value-types'
import type { FileEntity } from '@/app/components/base/file-uploader/types'
import type { VarInInspect } from '@/types/workflow'
import type { FileResponse, VarInInspect } from '@/types/workflow'
import { useDebounceFn } from 'ahooks'
import * as React from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
@ -54,10 +54,14 @@ type EditorState = {
}
const formatFileValue = (value: VarInInspect, isSysFiles: boolean): FileEntity[] => {
if (value.value_type === VarType.file)
return value.value ? getProcessedFilesFromResponse([value.value]) : []
if (value.value_type === VarType.arrayFile || (value.type === VarInInspectType.system && isSysFiles))
return value.value && value.value.length > 0 ? getProcessedFilesFromResponse(value.value) : []
if (value.value_type === VarType.file) {
const v = value.value
return v != null ? getProcessedFilesFromResponse([v as unknown as FileResponse]) : []
}
if (value.value_type === VarType.arrayFile || (value.type === VarInInspectType.system && isSysFiles)) {
const v = value.value
return Array.isArray(v) && v.length > 0 ? getProcessedFilesFromResponse(v as unknown as FileResponse[]) : []
}
return []
}
@ -89,8 +93,8 @@ const ValueContent = ({
const textValue = showTextEditor
? (
currentVar.value_type === VarType.number
? JSON.stringify(currentVar.value)
: (currentVar.value || '')
? JSON.stringify(currentVar.value ?? '')
: (typeof currentVar.value === 'string' || typeof currentVar.value === 'number' ? currentVar.value : String(currentVar.value ?? ''))
)
: ''
const jsonValue = showJSONEditor
@ -261,7 +265,7 @@ const ValueContent = ({
{
showBoolArrayEditor && (
<div className="w-[295px] space-y-1">
{currentVar.value.map((v: boolean, i: number) => (
{(currentVar.value as boolean[]).map((v: boolean, i: number) => (
<BoolValue
key={i}
value={v}