Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: infrastructure upgrade #13892

Draft
wants to merge 454 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
454 commits
Select commit Hold shift + click to select a range
f0637ba
fix: create basic app causing internal error when default model is no…
takatost Nov 8, 2024
5fd8208
fix: avoid empty plugin entity
Yeuoly Nov 11, 2024
5cdbfe2
Merge branch 'main' into fix/chore-fix
Yeuoly Nov 11, 2024
bc0724b
chore: fix typo
takatost Nov 11, 2024
1d2118f
fix: hosted moderation
takatost Nov 11, 2024
9a69d03
feat: add icon and labels to plugin install task
Yeuoly Nov 11, 2024
21fd58c
Merge branch 'fix/chore-fix' of github.com:langgenius/dify into fix/c…
Yeuoly Nov 12, 2024
f613642
feat: export dsl with dependencies
Yeuoly Nov 12, 2024
56bd0de
fix: incorrect paths to upgrade plugins
Yeuoly Nov 12, 2024
5828abc
fix: uses to check if the tools are already loaded
Yeuoly Nov 12, 2024
183b943
feat: support check dependencies through url
Yeuoly Nov 13, 2024
d25e79e
feat: support uploading images through plugin
Yeuoly Nov 14, 2024
db68ae4
feat: support upload bundle
Yeuoly Nov 14, 2024
634cb62
feat: sypport batch fetch plugin installations
Yeuoly Nov 14, 2024
a0543ab
Merge branch 'main' into fix/chore-fix
Yeuoly Nov 15, 2024
6300e50
fix: rag
Yeuoly Nov 15, 2024
fb4ee81
fix: agent
Yeuoly Nov 15, 2024
2cb640d
refactor: load tools cache
Yeuoly Nov 15, 2024
97a3727
fix: optimize DEFAULT-USER
Yeuoly Nov 18, 2024
8b30099
fix: convert backwards invocation into BaseBackwardsResponse
Yeuoly Nov 19, 2024
88fac0d
fix: add tenant_id to plugin upload files url
Yeuoly Nov 19, 2024
4492295
fix: remove plugin files
Yeuoly Nov 20, 2024
959d060
fix: remove signature verify
Yeuoly Nov 20, 2024
2473400
Merge branch 'main' into fix/chore-fix
Yeuoly Nov 21, 2024
22df86f
fix: ruff
Yeuoly Nov 21, 2024
a700b49
fix: migration
Yeuoly Nov 21, 2024
a6835ac
fix: add detailed error messages
Yeuoly Nov 21, 2024
cfa7c89
refactor: text-embedding interfaces to returns list[int]
Yeuoly Nov 22, 2024
e63ae36
fix
Yeuoly Nov 22, 2024
1443fd6
optimize: indexing-estimate
Yeuoly Nov 22, 2024
200f9af
optimize error messages
Yeuoly Nov 22, 2024
5ff9cee
Merge branch 'main' into fix/chore-fix
Yeuoly Nov 25, 2024
49bd1a7
fix: riff
Yeuoly Nov 25, 2024
accbbae
cleanup: remove get_interates
Yeuoly Nov 25, 2024
965fabd
fix: rename dependencies
Yeuoly Nov 25, 2024
ba3659a
feat: support delete all install tasks
Yeuoly Nov 25, 2024
c2ce8e6
fix: deleted_tools
Yeuoly Nov 25, 2024
992e1ee
fix: export agent dsl
Yeuoly Nov 25, 2024
08cfcb4
fix: missing marshal fields of leaked+dependencies
Yeuoly Nov 26, 2024
e4b8220
Merge branch 'main' into fix/chore-fix
Yeuoly Nov 26, 2024
db726e0
feat: support multi token count
Yeuoly Nov 26, 2024
e39edda
fix: change to use convert_stream_full_response
Yeuoly Nov 27, 2024
5c6d919
fix: handle detailed error type
Yeuoly Nov 28, 2024
eead6ab
fix: tool image url response
Yeuoly Nov 28, 2024
0452dfd
fix: missing tool invoke messages
Yeuoly Nov 28, 2024
7720091
fix: keep process_data with None if not
Yeuoly Nov 28, 2024
8c5928d
fix: unify error handling
Yeuoly Nov 28, 2024
687455c
fix: tool file id
Yeuoly Nov 29, 2024
6f2d5ff
fix: add tenant_id to invoke tts
Yeuoly Nov 29, 2024
89af726
fix: cot agent
Yeuoly Nov 29, 2024
fb44cd8
fix: image url message
Yeuoly Nov 29, 2024
b10d605
fix: summary and create_file_by_url
Yeuoly Dec 2, 2024
ad89984
fix: workflow loads tool provider icon
Yeuoly Dec 2, 2024
77a62f3
fix: Lookup errors for contextvars used in ToolManager
Yeuoly Dec 2, 2024
632b2ba
fix: invoke-email
Yeuoly Dec 2, 2024
c34877a
fix: update tool provider credentials
Yeuoly Dec 3, 2024
574a6c1
fix: add extension, filename and size to PluginFileEntity
Yeuoly Dec 3, 2024
dcf1954
feat: move audio and webscraper back to dify
Yeuoly Dec 3, 2024
7679a57
fix: agent type errors
Yeuoly Dec 3, 2024
86291c1
Merge branch 'main' into fix/chore-fix
Yeuoly Dec 4, 2024
ee38bd8
refactor: check dependencies
Yeuoly Dec 4, 2024
0af9c4f
chore: reformat
Yeuoly Dec 4, 2024
01efdee
fix: support other file types for Tool
Yeuoly Dec 4, 2024
c1a85b0
fix: add default value to plugin permission field
Yeuoly Dec 5, 2024
b7ac287
fix: use default_factory for list fields
Yeuoly Dec 5, 2024
337eff2
Merge branch 'main' into fix/chore-fix
Yeuoly Dec 6, 2024
c377eb8
fix: unbound variable in tool node
Yeuoly Dec 9, 2024
16b49ac
Merge branch 'main' into fix/chore-fix
Yeuoly Dec 9, 2024
ae72514
feat: support agent node
Yeuoly Dec 9, 2024
4ccd571
fix: ruff
Yeuoly Dec 9, 2024
296fd82
fix: agent node
Yeuoly Dec 9, 2024
a175d6b
feat: agent management
Yeuoly Dec 9, 2024
93786f5
apply ruff
Yeuoly Dec 9, 2024
527c1cf
fix: deduplicate provider id
Yeuoly Dec 9, 2024
c2983ec
fix: rename stream to streaming
Yeuoly Dec 12, 2024
3c628d0
refactor: rename agent to agent strategy
Yeuoly Dec 12, 2024
46bb246
refactor: rename agent to agent strategy
Yeuoly Dec 12, 2024
dedc1b0
refactor: agent strategy parameter
Yeuoly Dec 12, 2024
9a6f120
feat: support agent log event
Yeuoly Dec 12, 2024
63206a7
fix: incorrect use of node execution id
Yeuoly Dec 12, 2024
65a4cb7
refactor: tool entities
Yeuoly Dec 13, 2024
6339706
fix: ruff reformatter
Yeuoly Dec 13, 2024
6357450
feat: support hidden parameters
Yeuoly Dec 13, 2024
93c3699
feat: add label to agent log
Yeuoly Dec 15, 2024
a61da6c
fix: replace Enum with StrEnum
Yeuoly Dec 16, 2024
75fe785
Merge branch 'main' into fix/chore-fix
Yeuoly Dec 16, 2024
636dde9
fix: migrations
Yeuoly Dec 16, 2024
05232d3
fix: add default values to WorkflowAppGenerator
Yeuoly Dec 17, 2024
342d406
fix: add additional parameters to exists tools
Yeuoly Dec 18, 2024
d5c708c
feat: add plugin_model_providers context
takatost Dec 18, 2024
1b21d75
fix: reduce model provider fetchs
Yeuoly Dec 18, 2024
a1cdca0
fix: formatter
Yeuoly Dec 18, 2024
8cc4c10
fix: return types of builtin tools
Yeuoly Dec 18, 2024
bf39e31
fix: add install count
Yeuoly Dec 24, 2024
39656f7
fix: linter and formatter
Yeuoly Dec 24, 2024
4199998
Merge branch 'main' into fix/chore-fix
Yeuoly Dec 24, 2024
5a57dad
fix: linter
Yeuoly Dec 24, 2024
ee68416
fix: migrations and imports recycle
Yeuoly Dec 24, 2024
ee080dd
fix: rebase
Yeuoly Dec 24, 2024
f589397
fix: import Optional
Yeuoly Dec 24, 2024
6ee7ca1
fix: add specific exceptions
Yeuoly Dec 24, 2024
9ee0c7a
merge
Yeuoly Dec 25, 2024
00cf5f3
fix: linters
Yeuoly Dec 25, 2024
fee4dd7
fix: unused stream variable
Yeuoly Dec 25, 2024
80d8e47
fix: skip json transforming if error occurs
Yeuoly Dec 25, 2024
e231cf2
fix: errors occrus during rebasing
Yeuoly Dec 26, 2024
b980c07
fix: ruff formatter
Yeuoly Dec 26, 2024
cbc5045
fix: ruff formatter
Yeuoly Dec 26, 2024
0164d14
migrations for plugins
Yeuoly Dec 26, 2024
430af95
fix: linter
Yeuoly Dec 26, 2024
51cc63d
fix: undefined dereference to ApiTool
Yeuoly Dec 26, 2024
b34d815
feat: support auto generate and template
Yeuoly Dec 26, 2024
2f523dd
optimize: add friendly logs
Yeuoly Dec 26, 2024
0249f15
fix: linter
Yeuoly Dec 26, 2024
23066a9
feat: support extracting plugins into local files
Yeuoly Dec 26, 2024
ac5e3ca
optimize: migrate speed
Yeuoly Dec 26, 2024
e77cd87
fix: linter
Yeuoly Dec 26, 2024
c9eb9c1
fix: block call to flask_app
Yeuoly Dec 26, 2024
8102cee
fix: unbound reference
Yeuoly Dec 27, 2024
598d208
fix: agent error handling
Yeuoly Dec 27, 2024
048e8cf
fix: remove validate credentials
Yeuoly Dec 27, 2024
4507053
fix: linter
Yeuoly Dec 27, 2024
78664c8
Merge branch 'main' into fix/chore-fix
Yeuoly Dec 27, 2024
a5555f9
fix: models
Yeuoly Dec 27, 2024
e359ace
fix: add agent logs
Yeuoly Dec 27, 2024
af2aede
feat: support precision to PluginParameter
Yeuoly Dec 27, 2024
cbf405b
fix: remigrate
Yeuoly Dec 27, 2024
83fdb42
fix: variable message
Yeuoly Dec 27, 2024
05a43e3
fix: rebaseing to main
Yeuoly Dec 30, 2024
63665a5
feat: add conversation_id to invoke
Yeuoly Dec 30, 2024
06412b3
fix: no attribbute identity
Yeuoly Dec 30, 2024
6e73ad2
feat: plugin migrations
Yeuoly Dec 31, 2024
adf7eea
fix: ruff
Yeuoly Dec 31, 2024
107e44c
Merge branch 'main' into fix/chore-fix
Yeuoly Dec 31, 2024
d815c74
fix: ruff
Yeuoly Dec 31, 2024
71e0bfc
fix: updating tool credentials does not works as expected
Yeuoly Jan 3, 2025
5f51a19
fix: allow meta to be None
Yeuoly Jan 3, 2025
d2ff8a2
fix: bugs
Yeuoly Jan 6, 2025
3799d40
feat: support docker deployment for plugin
Yeuoly Jan 6, 2025
aa6452b
fix: use session to manage AppSite
Yeuoly Jan 6, 2025
8d75abc
fix: correct fetch_from for customizable models (#12400)
kurokobo Jan 6, 2025
07c7b7b
fix: remove 5002 port from docker mapping
Yeuoly Jan 6, 2025
9685b9a
refactor: docker-compose-middleware.yaml
Yeuoly Jan 7, 2025
ff3d3f7
fix: use host.docker.internal as the default plugin daemon middleware…
Yeuoly Jan 7, 2025
c3440a2
fix
Yeuoly Jan 7, 2025
fb7b2c8
fix: backwards invoke nodes
Yeuoly Jan 7, 2025
b56d2b7
feat: add fc agent mode support
Jan 7, 2025
fb30946
Merge branch 'main' into fix/chore-fix
Yeuoly Jan 8, 2025
b7d168a
fix: mypy linter
Yeuoly Jan 8, 2025
172c5f1
fix: formatter
Yeuoly Jan 8, 2025
491d641
feat: add agent node log
Jan 9, 2025
5ce4ddc
fix: change the agent strategy category
Jan 9, 2025
76e24d9
fix: migrations
Yeuoly Jan 9, 2025
f748d6c
fix: mypy issues
Yeuoly Jan 9, 2025
d76af08
feat: add agent log icon
Jan 9, 2025
94a62f6
enhancement: remove unrequired deps
Yeuoly Jan 9, 2025
e4c4490
refactor
Yeuoly Jan 9, 2025
3c014f3
Feat/plugins (#12547)
zxhlyh Jan 9, 2025
13f0c01
feat: add ci checks to plugins/beta branch (#12542)
Yeuoly Jan 9, 2025
0d411a0
feat: refactor docker-compose (#12550)
Yeuoly Jan 9, 2025
8efed88
feat: reset parameters when switch agent strategy (#12549)
AkaraChen Jan 9, 2025
17babca
Introducing: Plugin Mechanism (#12553)
Yeuoly Jan 9, 2025
078c151
fix: add-default-console-url (#12558)
Yeuoly Jan 9, 2025
cead13c
plugins: remove middleware.1.yaml (#12559)
Yeuoly Jan 9, 2025
f967180
fix: not show stragry type (#12561)
iamjoel Jan 9, 2025
4deb02f
fix: rename plugin db name to dify_plugin (#12565)
Yeuoly Jan 9, 2025
782abce
bump version to 1.0.0-beta.1 (#12567)
Yeuoly Jan 9, 2025
28edbba
Plugins/bump to 1.0.0 beta.1 (#12568)
Yeuoly Jan 9, 2025
e370045
Fix:screenshots image missed (#12589)
douxc Jan 10, 2025
39ec6c8
Fix/setting model page crash (#12594)
iamjoel Jan 10, 2025
71976f9
fix: marketplace serach bundle (#12581)
zxhlyh Jan 10, 2025
a5e24ff
fix: update language change handling in I18n component (#12596)
WTW0313 Jan 10, 2025
f69220c
fix: add location directive for /explore (#12572)
kurokobo Jan 10, 2025
04dade2
fix: update fetchReleases to use owner and repo from meta (#12590)
fujita-h Jan 10, 2025
c03adcb
Fix: style checks and unittests (#12603)
Yeuoly Jan 10, 2025
4cbd511
fix: ci use pnpm error (#12597)
iamjoel Jan 10, 2025
ac336ff
fix(1.0): add missing environment variable (#12599)
hjlarry Jan 10, 2025
c08b451
fix: marketplace page list style (#12613)
zxhlyh Jan 10, 2025
d56079a
fix: marketplace card i18n (#12623)
zxhlyh Jan 10, 2025
cb8debe
Plugins/fix backend ci errors (#12615)
Yeuoly Jan 10, 2025
5194757
feat: add skip signature verification (#12627)
Yeuoly Jan 10, 2025
f0a3c14
fix: plugins task (#12662)
zxhlyh Jan 13, 2025
98b139c
feat: add agent strategy on node start (#12667)
Nov1c444 Jan 13, 2025
0a6b4d0
fix: save tool not add type (#12712)
iamjoel Jan 14, 2025
e56c051
Fix: tool card info (#12726)
JzoNgKVO Jan 14, 2025
0b32b19
fix: missing tenant_id in get_signed_file_url_for_plugin (#12734)
Yeuoly Jan 14, 2025
1a313c8
fix(1.0): sometimes add tool raise error (#12821)
hjlarry Jan 21, 2025
60427f1
chore(1.0): improve some environment variables (#12814)
hjlarry Jan 21, 2025
de4752a
fix(1.0): unexpected error raise (#12812)
hjlarry Jan 21, 2025
b5accda
fix: correct validation for agent node which is invoked before publis…
kurokobo Jan 21, 2025
357d2e8
fix(1.0): add cross-env to pnpm run dev (#12600)
hjlarry Jan 21, 2025
6ee4eba
fix: change default PLUGIN_DAEMON_URL to http://localhost:5002 (#12915)
Yeuoly Jan 21, 2025
c8b4a76
fix: agent node output vars error (#12931)
iamjoel Jan 22, 2025
15ee1e1
fix: 500 error in Notion integration API (#12934)
nagaihiroki-git Jan 22, 2025
cc1fe70
fix: add adapter for datasets update checking (#12939)
Yeuoly Jan 22, 2025
5f0fa38
fix(1.0): invoke llm raise error (#12753)
hjlarry Jan 22, 2025
8d8d3e3
fix: plugin search api url (#12977)
zxhlyh Jan 23, 2025
899df30
Plugin/merge main to plugin/beta 20250122 (#12962)
Yeuoly Jan 23, 2025
c966bf1
Feat: dark mode of app configure (#13010)
JzoNgKVO Jan 24, 2025
ef1f429
fix(1.0): update github plugin 404 (#13014)
hjlarry Jan 24, 2025
f93bf13
fix(1.0): explore market page empty (#13017)
hjlarry Jan 24, 2025
6887b50
fix: can choose selected tools and show tool name instead of label (#…
iamjoel Jan 24, 2025
62c413a
add sign-content (#13050)
JohnJyong Jan 26, 2025
c044cc5
chore: upgrade next and react
iamjoel Jan 26, 2025
fd5028d
chore: change headlessui api to new
iamjoel Jan 26, 2025
3befbc1
feat: docx image preview (#13057)
WTW0313 Jan 26, 2025
1de84fd
fix: correct env vars for docker deployment (#13055)
kurokobo Jan 27, 2025
2710242
Feat: feature and log dark mode (#13208)
JzoNgKVO Feb 5, 2025
6642fc6
fix: fix fallback route logic (#13199)
WTW0313 Feb 5, 2025
fd11817
fix: select input not show save value (#13218)
iamjoel Feb 5, 2025
1650dbf
Fix: merge error of tracing and web app setting modal (#13219)
JzoNgKVO Feb 5, 2025
24839bb
fix: mismatches dependencies in dockerfile (#13220)
Yeuoly Feb 5, 2025
cdeaf3f
Fix ruff linting error caused by `api/models/dataset.py` (#13221)
BorisPolonsky Feb 5, 2025
4e27d82
improve: remove docker-legacy (#13236)
Yeuoly Feb 5, 2025
beebba0
Unify plugin endpoint configuration for api and worker: An alternativ…
BorisPolonsky Feb 6, 2025
2649f9f
fix: deperacted menu active
iamjoel Feb 6, 2025
087a106
chore: listoptions active
iamjoel Feb 6, 2025
a7575e6
fix: deprecated active
iamjoel Feb 6, 2025
fef2326
fix: transation new
iamjoel Feb 6, 2025
7ddb568
chore: to new transation
iamjoel Feb 6, 2025
470e72c
chore: bump katex version and tweak UI copy (#13280)
nite-knite Feb 7, 2025
a8a8a55
fix: app check dependency (#13320)
zxhlyh Feb 7, 2025
802dc15
fix: update Sentry integration methods and upgrade dependencies
WTW0313 Feb 7, 2025
eeb1ed4
Merge branch 'chore/infrastructure-upgrade' of https://github.com/lan…
WTW0313 Feb 7, 2025
7e1d989
fix: plugins task permission (#13330)
zxhlyh Feb 7, 2025
d4a0980
improve preview document tokenizer (#13328)
JohnJyong Feb 7, 2025
dbd5e8d
chore: change forward ref to new ref
iamjoel Feb 7, 2025
fec3bb4
fix: models sort in model page (#13334)
zxhlyh Feb 7, 2025
3e9c3d0
fix: install installed plugin problem (#13384)
iamjoel Feb 8, 2025
95e2e03
merge plugin/beta
iamjoel Feb 8, 2025
5e57932
fix: anchorRef.current may undefined
iamjoel Feb 8, 2025
688a461
fix: icon ts problem
iamjoel Feb 8, 2025
d062519
fix: use ref not set init value
iamjoel Feb 8, 2025
1e4f3bc
chore: jsx to react to jsx
iamjoel Feb 8, 2025
acb8e80
chore: react element to node
iamjoel Feb 8, 2025
fe78f42
fix: upgrade @antfu/eslint-config to latest & enable tailwind css rules
douxc Feb 10, 2025
dcfadbd
fix: update eslint config
douxc Feb 10, 2025
6653b6e
chore: upgrade swr and so on
iamjoel Feb 11, 2025
52f3236
chore: remove test code
iamjoel Feb 11, 2025
cd3d1a8
fix: disable some tailwindcss eslint rules that cost too much time
douxc Feb 11, 2025
ea7a6e2
fix: update tailwindcss eslint config
douxc Feb 18, 2025
db055b4
merge
iamjoel Feb 18, 2025
e5d43eb
chore: sync to workfows main
iamjoel Feb 18, 2025
79a2a4f
chore: useless change sync to main and global
iamjoel Feb 18, 2025
6bcb8bc
chore: useless change
iamjoel Feb 18, 2025
4dbc4b6
chore: sync main
iamjoel Feb 18, 2025
13d3430
chore: switch ref change
iamjoel Feb 18, 2025
52cfe80
fix: run eslint-plugin-tailwindcss
douxc Feb 18, 2025
30dd37a
fix: update tailwindcss cssFiles settings
douxc Feb 18, 2025
76a5f66
chore: make error icons
iamjoel Feb 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Main from '@/app/components/app/log-annotation'
import { PageType } from '@/app/components/base/features/new-feature-panel/annotation-reply/type'

export type IProps = {
params: { appId: string }
params: Promise<{ appId: string }>
}

const Logs = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import type { Locale } from '@/i18n'
import DevelopMain from '@/app/components/develop'

export type IDevelopProps = {
params: { locale: Locale; appId: string }
params: Promise<{ locale: Locale; appId: string }>
}

const Develop = async ({
params: { appId },
params,
}: IDevelopProps) => {
const appId = (await params).appId
return <DevelopMain appId={appId} />
}

Expand Down
176 changes: 176 additions & 0 deletions web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
'use client'
import type { FC } from 'react'
import { useUnmount } from 'ahooks'
import React, { useCallback, useEffect, useState } from 'react'
import { usePathname, useRouter } from 'next/navigation'
import {
RiDashboard2Fill,
RiDashboard2Line,
RiFileList3Fill,
RiFileList3Line,
RiTerminalBoxFill,
RiTerminalBoxLine,
RiTerminalWindowFill,
RiTerminalWindowLine,
} from '@remixicon/react'
import { useTranslation } from 'react-i18next'
import { useShallow } from 'zustand/react/shallow'
import { useContextSelector } from 'use-context-selector'
import s from './style.module.css'
import cn from '@/utils/classnames'
import { useStore } from '@/app/components/app/store'
import AppSideBar from '@/app/components/app-sidebar'
import type { NavIcon } from '@/app/components/app-sidebar/navLink'
import { fetchAppDetail, fetchAppSSO } from '@/service/apps'
import AppContext, { useAppContext } from '@/context/app-context'
import Loading from '@/app/components/base/loading'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import type { App } from '@/types/app'

export type IAppDetailLayoutProps = {
children: React.ReactNode
appId: string
}

const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
const {
children,
appId, // get appId in path
} = props
const { t } = useTranslation()
const router = useRouter()
const pathname = usePathname()
const media = useBreakpoints()
const isMobile = media === MediaType.mobile
const { isCurrentWorkspaceEditor, isLoadingCurrentWorkspace } = useAppContext()
const { appDetail, setAppDetail, setAppSiderbarExpand } = useStore(useShallow(state => ({
appDetail: state.appDetail,
setAppDetail: state.setAppDetail,
setAppSiderbarExpand: state.setAppSiderbarExpand,
})))
const [isLoadingAppDetail, setIsLoadingAppDetail] = useState(false)
const [appDetailRes, setAppDetailRes] = useState<App | null>(null)
const [navigation, setNavigation] = useState<Array<{
name: string
href: string
icon: NavIcon
selectedIcon: NavIcon
}>>([])
const systemFeatures = useContextSelector(AppContext, state => state.systemFeatures)

const getNavigations = useCallback((appId: string, isCurrentWorkspaceEditor: boolean, mode: string) => {
const navs = [
...(isCurrentWorkspaceEditor
? [{
name: t('common.appMenus.promptEng'),
href: `/app/${appId}/${(mode === 'workflow' || mode === 'advanced-chat') ? 'workflow' : 'configuration'}`,
icon: RiTerminalWindowLine,
selectedIcon: RiTerminalWindowFill,
}]
: []
),
{
name: t('common.appMenus.apiAccess'),
href: `/app/${appId}/develop`,
icon: RiTerminalBoxLine,
selectedIcon: RiTerminalBoxFill,
},
...(isCurrentWorkspaceEditor
? [{
name: mode !== 'workflow'
? t('common.appMenus.logAndAnn')
: t('common.appMenus.logs'),
href: `/app/${appId}/logs`,
icon: RiFileList3Line,
selectedIcon: RiFileList3Fill,
}]
: []
),
{
name: t('common.appMenus.overview'),
href: `/app/${appId}/overview`,
icon: RiDashboard2Line,
selectedIcon: RiDashboard2Fill,
},
]
return navs
}, [t])

useEffect(() => {
if (appDetail) {
document.title = `${(appDetail.name || 'App')} - Dify`
const localeMode = localStorage.getItem('app-detail-collapse-or-expand') || 'expand'
const mode = isMobile ? 'collapse' : 'expand'
setAppSiderbarExpand(isMobile ? mode : localeMode)
// TODO: consider screen size and mode
// if ((appDetail.mode === 'advanced-chat' || appDetail.mode === 'workflow') && (pathname).endsWith('workflow'))
// setAppSiderbarExpand('collapse')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appDetail, isMobile])

useEffect(() => {
setAppDetail()
setIsLoadingAppDetail(true)
fetchAppDetail({ url: '/apps', id: appId }).then((res) => {
setAppDetailRes(res)
}).catch((e: any) => {
if (e.status === 404)
router.replace('/apps')
}).finally(() => {
setIsLoadingAppDetail(false)
})
}, [appId, router, setAppDetail])

useEffect(() => {
if (!appDetailRes || isLoadingCurrentWorkspace || isLoadingAppDetail)
return
const res = appDetailRes
// redirection
const canIEditApp = isCurrentWorkspaceEditor
if (!canIEditApp && (pathname.endsWith('configuration') || pathname.endsWith('workflow') || pathname.endsWith('logs'))) {
router.replace(`/app/${appId}/overview`)
return
}
if ((res.mode === 'workflow' || res.mode === 'advanced-chat') && (pathname).endsWith('configuration')) {
router.replace(`/app/${appId}/workflow`)
}
else if ((res.mode !== 'workflow' && res.mode !== 'advanced-chat') && (pathname).endsWith('workflow')) {
router.replace(`/app/${appId}/configuration`)
}
else {
setAppDetail({ ...res, enable_sso: false })
setNavigation(getNavigations(appId, isCurrentWorkspaceEditor, res.mode))
if (systemFeatures.enable_web_sso_switch_component && canIEditApp) {
fetchAppSSO({ appId }).then((ssoRes) => {
setAppDetail({ ...res, enable_sso: ssoRes.enabled })
})
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appDetailRes, appId, getNavigations, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace, router, setAppDetail, systemFeatures.enable_web_sso_switch_component])

useUnmount(() => {
setAppDetail()
})

if (!appDetail) {
return (
<div className='bg-background-body flex h-full items-center justify-center'>
<Loading />
</div>
)
}

return (
<div className={cn(s.app, 'relative flex', 'overflow-hidden')}>
{appDetail && (
<AppSideBar title={appDetail.name} icon={appDetail.icon} icon_background={appDetail.icon_background as string} desc={appDetail.mode} navigation={navigation} />
)}
<div className="bg-components-panel-bg grow overflow-hidden">
{children}
</div>
</div>
)
}
export default React.memo(AppDetailLayout)
176 changes: 7 additions & 169 deletions web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,176 +1,14 @@
'use client'
import type { FC } from 'react'
import { useUnmount } from 'ahooks'
import React, { useCallback, useEffect, useState } from 'react'
import { usePathname, useRouter } from 'next/navigation'
import {
RiDashboard2Fill,
RiDashboard2Line,
RiFileList3Fill,
RiFileList3Line,
RiTerminalBoxFill,
RiTerminalBoxLine,
RiTerminalWindowFill,
RiTerminalWindowLine,
} from '@remixicon/react'
import { useTranslation } from 'react-i18next'
import { useShallow } from 'zustand/react/shallow'
import { useContextSelector } from 'use-context-selector'
import s from './style.module.css'
import cn from '@/utils/classnames'
import { useStore } from '@/app/components/app/store'
import AppSideBar from '@/app/components/app-sidebar'
import type { NavIcon } from '@/app/components/app-sidebar/navLink'
import { fetchAppDetail, fetchAppSSO } from '@/service/apps'
import AppContext, { useAppContext } from '@/context/app-context'
import Loading from '@/app/components/base/loading'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import type { App } from '@/types/app'
import Main from './layout-main'

export type IAppDetailLayoutProps = {
const AppDetailLayout = async (props: {
children: React.ReactNode
params: { appId: string }
}

const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
params: Promise<{ appId: string }>
}) => {
const {
children,
params: { appId }, // get appId in path
params,
} = props
const { t } = useTranslation()
const router = useRouter()
const pathname = usePathname()
const media = useBreakpoints()
const isMobile = media === MediaType.mobile
const { isCurrentWorkspaceEditor, isLoadingCurrentWorkspace } = useAppContext()
const { appDetail, setAppDetail, setAppSiderbarExpand } = useStore(useShallow(state => ({
appDetail: state.appDetail,
setAppDetail: state.setAppDetail,
setAppSiderbarExpand: state.setAppSiderbarExpand,
})))
const [isLoadingAppDetail, setIsLoadingAppDetail] = useState(false)
const [appDetailRes, setAppDetailRes] = useState<App | null>(null)
const [navigation, setNavigation] = useState<Array<{
name: string
href: string
icon: NavIcon
selectedIcon: NavIcon
}>>([])
const systemFeatures = useContextSelector(AppContext, state => state.systemFeatures)

const getNavigations = useCallback((appId: string, isCurrentWorkspaceEditor: boolean, mode: string) => {
const navs = [
...(isCurrentWorkspaceEditor
? [{
name: t('common.appMenus.promptEng'),
href: `/app/${appId}/${(mode === 'workflow' || mode === 'advanced-chat') ? 'workflow' : 'configuration'}`,
icon: RiTerminalWindowLine,
selectedIcon: RiTerminalWindowFill,
}]
: []
),
{
name: t('common.appMenus.apiAccess'),
href: `/app/${appId}/develop`,
icon: RiTerminalBoxLine,
selectedIcon: RiTerminalBoxFill,
},
...(isCurrentWorkspaceEditor
? [{
name: mode !== 'workflow'
? t('common.appMenus.logAndAnn')
: t('common.appMenus.logs'),
href: `/app/${appId}/logs`,
icon: RiFileList3Line,
selectedIcon: RiFileList3Fill,
}]
: []
),
{
name: t('common.appMenus.overview'),
href: `/app/${appId}/overview`,
icon: RiDashboard2Line,
selectedIcon: RiDashboard2Fill,
},
]
return navs
}, [t])

useEffect(() => {
if (appDetail) {
document.title = `${(appDetail.name || 'App')} - Dify`
const localeMode = localStorage.getItem('app-detail-collapse-or-expand') || 'expand'
const mode = isMobile ? 'collapse' : 'expand'
setAppSiderbarExpand(isMobile ? mode : localeMode)
// TODO: consider screen size and mode
// if ((appDetail.mode === 'advanced-chat' || appDetail.mode === 'workflow') && (pathname).endsWith('workflow'))
// setAppSiderbarExpand('collapse')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appDetail, isMobile])

useEffect(() => {
setAppDetail()
setIsLoadingAppDetail(true)
fetchAppDetail({ url: '/apps', id: appId }).then((res) => {
setAppDetailRes(res)
}).catch((e: any) => {
if (e.status === 404)
router.replace('/apps')
}).finally(() => {
setIsLoadingAppDetail(false)
})
}, [appId, router, setAppDetail])

useEffect(() => {
if (!appDetailRes || isLoadingCurrentWorkspace || isLoadingAppDetail)
return
const res = appDetailRes
// redirection
const canIEditApp = isCurrentWorkspaceEditor
if (!canIEditApp && (pathname.endsWith('configuration') || pathname.endsWith('workflow') || pathname.endsWith('logs'))) {
router.replace(`/app/${appId}/overview`)
return
}
if ((res.mode === 'workflow' || res.mode === 'advanced-chat') && (pathname).endsWith('configuration')) {
router.replace(`/app/${appId}/workflow`)
}
else if ((res.mode !== 'workflow' && res.mode !== 'advanced-chat') && (pathname).endsWith('workflow')) {
router.replace(`/app/${appId}/configuration`)
}
else {
setAppDetail({ ...res, enable_sso: false })
setNavigation(getNavigations(appId, isCurrentWorkspaceEditor, res.mode))
if (systemFeatures.enable_web_sso_switch_component && canIEditApp) {
fetchAppSSO({ appId }).then((ssoRes) => {
setAppDetail({ ...res, enable_sso: ssoRes.enabled })
})
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appDetailRes, appId, getNavigations, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace, router, setAppDetail, systemFeatures.enable_web_sso_switch_component])

useUnmount(() => {
setAppDetail()
})

if (!appDetail) {
return (
<div className='flex h-full items-center justify-center bg-background-body'>
<Loading />
</div>
)
}

return (
<div className={cn(s.app, 'flex relative', 'overflow-hidden')}>
{appDetail && (
<AppSideBar title={appDetail.name} icon={appDetail.icon} icon_background={appDetail.icon_background as string} desc={appDetail.mode} navigation={navigation} />
)}
<div className="bg-components-panel-bg grow overflow-hidden">
{children}
</div>
</div>
)
return <Main appId={(await params).appId}>{children}</Main>
}
export default React.memo(AppDetailLayout)
export default AppDetailLayout
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const CardView: FC<ICardViewProps> = ({ appId, isInPanel, className }) => {
return <Loading />

return (
<div className={className || 'grid gap-6 grid-cols-1 xl:grid-cols-2 w-full mb-6'}>
<div className={className || 'mb-6 grid w-full grid-cols-1 gap-6 xl:grid-cols-2'}>
<AppCard
appInfo={appDetail}
cardType="webapp"
Expand Down
Loading
Loading