mirror of
https://github.com/langgenius/dify.git
synced 2026-05-31 22:26:19 +08:00
fix(workflow-generator): satisfy knip + update slash command registry test
- Drop the export on apply.ts:deriveAppName — it's only used internally by applyToNewApp, and knip was flagging the unused public export. - Extend the slash.spec registration assertion to include the new 'create' command so SlashCommandProvider's mount/unmount checks pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -106,6 +106,7 @@ describe('SlashCommandProvider', () => {
|
||||
'account',
|
||||
'zen',
|
||||
'go',
|
||||
'create',
|
||||
])
|
||||
expect(mockRegister).toHaveBeenCalledWith(expect.objectContaining({ name: 'theme' }), { setTheme: mockSetTheme })
|
||||
expect(mockRegister).toHaveBeenCalledWith(expect.objectContaining({ name: 'language' }), { setLocale: mockSetLocale })
|
||||
@ -121,6 +122,7 @@ describe('SlashCommandProvider', () => {
|
||||
'account',
|
||||
'zen',
|
||||
'go',
|
||||
'create',
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@ -8,13 +8,9 @@ const MODE_TO_APP_MODE: Record<WorkflowGeneratorMode, AppModeEnum> = {
|
||||
'advanced-chat': AppModeEnum.ADVANCED_CHAT,
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive a sane App name from the user's instruction.
|
||||
* - Trims whitespace.
|
||||
* - Caps length at 40 chars.
|
||||
* - Strips trailing punctuation.
|
||||
*/
|
||||
export const deriveAppName = (instruction: string): string => {
|
||||
// Derive a sane App name from the user's instruction: trim, cap at 40 chars,
|
||||
// strip trailing punctuation.
|
||||
const deriveAppName = (instruction: string): string => {
|
||||
const trimmed = instruction.trim().slice(0, 40)
|
||||
return trimmed.replace(/[.,!?;:。,!?;:]+$/, '').trim() || 'Generated Workflow'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user